12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package system
- 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:"分组名称"`
- CreateTime time.Time `description:"创建时间"`
- }
- type SysGroupEditReq struct {
- GroupId int `description:"分组ID"`
- GroupName string `description:"分组名称"`
- }
- type SysGroupDeleteReq struct {
- GroupId int `description:"分组ID"`
- }
- func DeleteSysGroup(groupId int) (err error) {
- sql := `DELETE FROM sys_group WHERE group_id=? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, groupId).Exec()
- return
- }
- // 因前端显示需要,TopId字段用来当做一级部门id,DepartmentId为当前分组id
- type SysGroupList struct {
- GroupId int `orm:"column(group_id);pk" json:"DepartmentId" description:"分组ID"`
- ParentId int `json:"ParentId" description:"父级ID"`
- DepartmentId int `json:"TopId" description:"部门Id"`
- GroupName string `json:"DepartmentName" description:"分组名称"`
- Child []*SysTeamList `description:"小组"`
- CreateTime time.Time `description:"创建时间"`
- IsGroup bool `description:"是否为二级部门"`
- }
- type SysFullGroup struct {
- GroupId int `orm:"column(group_id);pk" description:"分组ID"`
- DepartmentId int `description:"部门Id"`
- ParentId int `description:"父级Id"`
- GroupName string `description:"分组名称"`
- ParentGroupName string `description:"父级分组名称"`
- DepartmentName string `description:"部门名称"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetFullGroup 获取完整的分组信息
- func GetFullGroup() (list []*SysFullGroup, err error) {
- sql := `SELECT s.*,g.group_name as parent_group_name , d.department_name
- from sys_group s
- LEFT JOIN sys_group g on s.parent_id=g.group_id
- LEFT JOIN sys_department d on s.department_id=d.department_id`
- o := orm.NewOrm()
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
|