| | |
| | | return |
| | | } |
| | | |
| | | errCode, data := allDataServer.GetAllData() |
| | | errCode, data := allDataServer.GetAllData(c) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | IDs []int |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *UserSearch) SetUserIds(userIds []int) *UserSearch { |
| | | slf.IDs = userIds |
| | | return slf |
| | | } |
| | | |
| | | func (slf *UserSearch) SetUserName(username string) *UserSearch { |
| | | slf.Username = username |
| | | return slf |
| | |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | |
| | | if len(slf.IDs) > 0 { |
| | | db = db.Where("id in ?", slf.IDs) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/utils" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type DataServer struct{} |
| | | |
| | | func (DataServer) GetAllData() (errCode int, data response.DataResponse) { |
| | | func (DataServer) GetAllData(c *gin.Context) (errCode int, data response.DataResponse) { |
| | | // get country list |
| | | countryList, _ := ServiceGroup.GetCountryList() |
| | | data.Country = countryList |
| | |
| | | data.RegularCustomers = regularCustomerList |
| | | |
| | | // get Member list |
| | | memberList, _ := ServiceGroup.GetUserList() |
| | | |
| | | var memberIds []int |
| | | userInfo := utils.GetUserInfo(c) |
| | | if userInfo.UserType == constvar.UserTypeSub { |
| | | memberIds = userInfo.SubUserIds |
| | | } |
| | | |
| | | memberList, _ := ServiceGroup.GetUserList(memberIds) |
| | | data.Member = memberList |
| | | |
| | | // get Department list |
| | |
| | | }) |
| | | } |
| | | |
| | | func (userService *UserService) GetUserList() (userList []*model.User, err error) { |
| | | return model.NewUserSearch(nil).FindAll() |
| | | func (userService *UserService) GetUserList(userIds []int) (userList []*model.User, err error) { |
| | | return model.NewUserSearch(nil).SetUserIds(userIds).FindAll() |
| | | } |
| | | |
| | | func (userService *UserService) UUID2CrmUserId(uuids []string) (crmUserIds []int, m map[string]int, err error) { |