sys_group.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type SysGroupAddReq struct {
  7. DepartmentId int `description:"部门Id"`
  8. GroupName string `description:"分组名称,多个用英文逗号隔开"`
  9. }
  10. type SysGroup struct {
  11. GroupId int `orm:"column(group_id);pk" description:"分组ID"`
  12. DepartmentId int `description:"部门Id"`
  13. ParentId int `description:"父级Id"`
  14. GroupName string `description:"分组名称"`
  15. Sort int `description:"排序"`
  16. CreateTime time.Time `description:"创建时间"`
  17. }
  18. func GetSysGroupAll() (list []*SysGroup, err error) {
  19. sql := `SELECT * FROM sys_group `
  20. o := orm.NewOrm()
  21. _, err = o.Raw(sql).QueryRows(&list)
  22. return
  23. }
  24. func GetSysDeptGroup(departmentName, groupName string) (item *SysGroup, err error) {
  25. sql := `SELECT * FROM sys_group AS a INNER JOIN sys_department AS b ON a.department_id=b.department_id WHERE b.department_name = ? AND a.group_name = ? ; `
  26. o := orm.NewOrm()
  27. err = o.Raw(sql, departmentName, groupName).QueryRow(&item)
  28. return
  29. }