12345678910111213141516171819202122232425262728293031323334 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type SysGroupAddReq struct {
- DepartmentId int `description:"部门Id"`
- GroupName string `description:"分组名称,多个用英文逗号隔开"`
- }
- type SysGroup struct {
- GroupId int `orm:"column(group_id);pk" description:"分组ID"`
- DepartmentId int `description:"部门Id"`
- ParentId int `description:"父级Id"`
- GroupName string `description:"分组名称"`
- Sort int `description:"排序"`
- CreateTime time.Time `description:"创建时间"`
- }
- func GetSysGroupAll() (list []*SysGroup, err error) {
- sql := `SELECT * FROM sys_group `
- o := orm.NewOrm()
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- func GetSysDeptGroup(departmentName, groupName string) (item *SysGroup, err error) {
- 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 = ? ; `
- o := orm.NewOrm()
- err = o.Raw(sql, departmentName, groupName).QueryRow(&item)
- return
- }
|