role_request.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package req
  2. import (
  3. "github.com/druidcaesa/gotool"
  4. "ulink-admin/pkg/base"
  5. "xorm.io/xorm"
  6. )
  7. // RoleQuery 角色Get请求参数
  8. type RoleQuery struct {
  9. base.GlobalQuery
  10. RoleName string `form:"roleName"` //角色名称
  11. Status string `form:"status"` //角色状态
  12. RoleKey string `form:"roleKey"` //角色Key
  13. //fun base.TableFunc
  14. }
  15. func (this *RoleQuery) Page() int {
  16. return this.PageNum
  17. }
  18. func (this *RoleQuery) Size() int {
  19. return this.PageSize
  20. }
  21. func (this *RoleQuery) Where(session *xorm.Session) {
  22. if !gotool.StrUtils.HasEmpty(this.RoleName) {
  23. session.And("role_name like concat('%', ?, '%')", this.RoleName)
  24. }
  25. if !gotool.StrUtils.HasEmpty(this.Status) {
  26. session.And("status = ?", this.Status)
  27. }
  28. if !gotool.StrUtils.HasEmpty(this.RoleKey) {
  29. session.And("role_key like concat('%', ?, '%')", this.RoleKey)
  30. }
  31. if !gotool.StrUtils.HasEmpty(this.BeginTime) {
  32. session.And("create_time >= date_format(?,'%y%m%d')", this.BeginTime)
  33. }
  34. if !gotool.StrUtils.HasEmpty(this.EndTime) {
  35. session.And("create_time,'%y%m%d') <= date_format(?,'%y%m%d')", this.EndTime)
  36. }
  37. }
  38. /*func (this *RoleQuery) Table(session *xorm.Session) {
  39. this.fun(session)
  40. }*/
  41. /*func (this *RoleQuery) SetTable(f base.TableFunc) {
  42. this.fun = f
  43. }*/
  44. /*func (this *RoleQuery) (session *xorm.Session) {
  45. session.Table([]string{model.SysRole{}.TableName(), "r"}).
  46. Join("LEFT", []string{"sys_user_role", "ur"}, "ur.role_id = r.id").
  47. Join("LEFT", []string{"sys_user", "u"}, "u.id = ur.user_id").
  48. Join("LEFT", []string{"sys_dept", "d"}, "u.dept_id = d.id")
  49. }*/
  50. // RoleBody 角色Post和Put参数
  51. type RoleBody struct {
  52. Id int64 `json:"id"`
  53. Status string `json:"status"`
  54. }