package business_trip import ( "github.com/beego/beego/v2/client/orm" ) type BusinessTripCalendarAdmin struct { AdminId int `description:"研究员id"` RealName string `description:"研究员名称"` BusinessTripList []*BusinessTripCalendar } type BusinessTripCalendar struct { BusinessApplyId int `description:"出差申请id"` Status string `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"` WeekDate string `description:"开始日期"` City string `description:"城市"` Week string `description:"周"` WeekType string `description:"当前周:current,下一周:next"` } // GetResearcherV2 获取研究员列表(冻结的也要) func GetBusinessTripCalendar(departmentId string) (list []*BusinessTripCalendarAdmin, err error) { o := orm.NewOrm() sql := ` SELECT a.admin_id,a.real_name FROM admin AS a INNER JOIN sys_group AS b ON a.group_id=b.group_id WHERE a.enabled=1 AND b.department_id IN(?) ORDER BY a.admin_id ASC ` _, err = o.Raw(sql, departmentId).QueryRows(&list) return } type BusinessTripCalendarGroup struct { GroupId int `description:"分组id"` GroupName string `description:"分组名称"` DepartmentId string `json:"-" description:"部门id"` AdminList []*BusinessTripCalendarAdmin } type BusinessTripCalendarResp struct { GroupList []*BusinessTripCalendarGroup } func GetBusinessTripList(adminId, startDate, endDate string) (list []*BusinessApplyView, err error) { o := orm.NewOrm() sql := ` SELECT * FROM business_apply AS a WHERE a.status IN('待审批','已审批') AND ((a.arrive_date>=? AND a.arrive_date<=?) OR (a.return_date>=? AND a.return_date<=?)) ` if adminId != "" { sql += ` AND a.apply_admin_id IN (` + adminId + `)` sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC ` } else { sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC ` } _, err = o.Raw(sql, startDate, endDate, startDate, endDate).QueryRows(&list) return }