seller_company_permission.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package company
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type SellerCompanyPermission struct {
  8. Id int `orm:"column(id);pk" description:"自增序号ID"`
  9. AdminId int `orm:"column(admin_id)" description:"系统用户id"`
  10. Enabled int `orm:"column(enabled)" description:"权限状态1:开放权限,0:禁用权限"`
  11. CreateTime time.Time `orm:"column(create_time)" description:"创建时间"`
  12. ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
  13. PermissionType int `orm:"column(permission_type)" description:"权限类型(1:添加用户权限)"`
  14. }
  15. // ReceiveGroupSellersResp 销售列表(根据部门、分组来)
  16. type ReceiveGroupSellersResp struct {
  17. List []ReceiveGroupSellers
  18. }
  19. type ReceiveGroupSellers struct {
  20. AdminId string `description:"系统用户id"`
  21. RealName string `description:"用户真实名称"`
  22. ChildrenList []ReceiveGroupSellers `description:"销售列表"`
  23. }
  24. type ReceiveSellerListResp struct {
  25. List []*ReceiveSellerItemResp
  26. Paging *paging.PagingItem
  27. }
  28. type ReceiveSellerItemResp struct {
  29. AdminId int `description:"销售id"`
  30. Enabled int `description:"权限状态1:开放权限,0:禁用权限"`
  31. DepartmentGroup string `description:"所属分组"`
  32. RealName string `description:"销售姓名"`
  33. }
  34. type ChangeReceivePermissionReq struct {
  35. AdminId int `description:"销售id"`
  36. Enabled int `description:"权限状态1:开放权限,0:禁用权限"`
  37. }
  38. // 新增权限记录
  39. func AddSellerCompanyPermission(permission *SellerCompanyPermission) (err error) {
  40. o := orm.NewOrm()
  41. _, err = o.Insert(permission)
  42. return
  43. }
  44. // GetSellerCompanyPermissionByAdminIdType 根据权限类型查询销售的权限详情
  45. func GetSellerCompanyPermissionByAdminIdType(adminId, permissionType int) (item *SellerCompanyPermission, err error) {
  46. o := orm.NewOrm()
  47. sql := ` select * FROM seller_company_permission WHERE admin_id=? and permission_type=?`
  48. err = o.Raw(sql, adminId, permissionType).QueryRow(&item)
  49. return
  50. }
  51. // GetSellerCompanyPermissionByAdminIdsType 根据权限类型查询销售的权限详情
  52. func GetSellerCompanyPermissionByAdminIdsType(adminIds string, permissionType int) (list []*SellerCompanyPermission, err error) {
  53. o := orm.NewOrm()
  54. sql := ` select * FROM seller_company_permission WHERE admin_id in (`+adminIds+`) and permission_type=?`
  55. _, err = o.Raw(sql, permissionType).QueryRows(&list)
  56. return
  57. }
  58. //UpdateSellerCompanyPermissionEnabledById 启用或禁用销售的某种类型的权限
  59. func UpdateSellerCompanyPermissionEnabledById(id, enabled int) (err error) {
  60. o := orm.NewOrm()
  61. msql := " UPDATE seller_company_permission SET enabled = ?,modify_time=NOW() WHERE id = ? "
  62. _, err = o.Raw(msql, enabled, id).Exec()
  63. return
  64. }