| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package system
- import (
- "lims_adapter/dao"
- "lims_adapter/model"
- "strconv"
- )
- type Service struct {
- Dao *dao.BaseItemdetailsDao
- Tenant string
- }
- // NewSrv 服务初始化
- func NewSrv(tenant string) Service {
- return Service{Dao: dao.NewBaseItemdetailsDao(tenant), Tenant: tenant}
- }
- // DictInfo 获取字典数据
- func(s Service) DictInfo(req *model.DictReq) (dictInfo []model.BaseItemdetails, err error) {
- where := "DictCode = '" + req.DictCode + "' and Enabled = 1"
- if req.ItemName != "" {
- where += " and ItemName = '" + req.ItemName + "'"
- }
- if req.ItemValue != "" {
- where += " and ItemValue = '" + req.ItemValue + "'"
- }
- if req.SortCode != "" {
- where += " and SortCode = '" + req.SortCode + "'"
- }
- err = s.Dao.M.Where(where).Scan(&dictInfo)
- if err != nil {
- return dictInfo, err
- }
- return dictInfo, nil
- }
- // UserList 获取用户信息
- func (s Service) UserList(req *model.UserInfoReq) (userInfos model.UserInfoRsp,err error) {
- where := "Enabled = 1"
- departmentId := strconv.Itoa(req.DepartmentId)
- instrumentId := strconv.Itoa(req.InstrumentId)
- current:= req.PageNun
- size:= req.PageSize
- count := 0
- model := s.Dao.DB.Model("base_user a")
- if departmentId != "" && departmentId != "0"{
- where += " and DepartmentId = " + departmentId
- }
- if req.ReqType == 1 { // 预约资格
- count, err = model.Where(where).Count()
- }else if req.ReqType == 2 { // 优先预约权
- where += " and Id not in(select UserId from base_equipment_qualification where EquipmentId = "+
- instrumentId +" and Qualification in (0,3))"
- count, err = model.Where(where).Count()
- }
- if err != nil {
- return userInfos, err
- }
- userInfos.Total = count
- model.Page(current, size).Scan(&userInfos.Records)
- return userInfos, nil
- }
|