sys_auth_rule.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // ============================================================================
  2. // This is auto-generated by gf cli tool only once. Fill this file as you wish.
  3. // ============================================================================
  4. package dao
  5. import (
  6. "gfast/app/system/dao/internal"
  7. "gfast/app/system/model"
  8. "github.com/gogf/gf/frame/g"
  9. "github.com/gogf/gf/frame/gmvc"
  10. )
  11. // sysAuthRuleDao is the manager for logic model data accessing
  12. // and custom defined data operations functions management. You can define
  13. // methods on it to extend its functionality as you wish.
  14. type sysAuthRuleDao struct {
  15. internal.SysAuthRuleDao
  16. }
  17. var (
  18. // SysAuthRule is globally public accessible object for table sys_auth_rule operations.
  19. SysAuthRule = sysAuthRuleDao{
  20. internal.SysAuthRule,
  21. }
  22. )
  23. func (d *sysAuthRuleDao) Scope(f func(m gmvc.M) gmvc.M) *sysAuthRuleDao {
  24. nd := *d
  25. if m := f(d.M); m != nil {
  26. nd.M = m
  27. }
  28. return &nd
  29. }
  30. // Fill with you ideas below.
  31. func (d *sysAuthRuleDao) GetMenuList() (list []*model.SysAuthRuleInfoRes, err error) {
  32. err = d.Fields(model.SysAuthRuleInfoRes{}).Order("weigh desc,id asc").Scan(&list)
  33. return
  34. }
  35. func (d *sysAuthRuleDao) CheckMenuNameUnique(name string, id int) bool {
  36. m := d.Where("name=?", name)
  37. if id != 0 {
  38. m = m.And("id!=?", id)
  39. }
  40. c, err := m.Count()
  41. if err != nil {
  42. g.Log().Error(err)
  43. return false
  44. }
  45. return c == 0
  46. }
  47. //检查菜单路由地址是否已经存在
  48. func (d *sysAuthRuleDao) CheckMenuPathUnique(path string, id int) bool {
  49. model := d.Where("path=?", path).Where("menu_type<>?", 2)
  50. if id != 0 {
  51. model = model.And("id!=?", id)
  52. }
  53. c, err := model.Count()
  54. if err != nil {
  55. g.Log().Error(err)
  56. return false
  57. }
  58. return c == 0
  59. }