Files

74 lines
1.8 KiB
Go
Raw Normal View History

2021-10-15 15:01:21 +08:00
package identity
import (
2021-10-27 13:27:01 +08:00
"SciencesServer/app/api/enterprise/model"
2021-10-15 15:06:02 +08:00
"SciencesServer/app/api/manage/controller"
2021-11-01 11:19:49 +08:00
"SciencesServer/app/basic/config"
2021-10-27 13:27:01 +08:00
model2 "SciencesServer/app/common/model"
2021-10-15 15:01:21 +08:00
"SciencesServer/app/service"
2021-11-01 11:19:49 +08:00
"strings"
2021-10-15 15:01:21 +08:00
)
type Instance struct {
*service.SessionEnterprise
local string
}
type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance
2021-10-27 13:27:01 +08:00
type (
// InstanceForExpert 专家信息
InstanceForExpert struct {
*model.UserManageForExpert
2021-11-01 11:19:49 +08:00
ID string `json:"id"`
Industry string `json:"industry"`
2021-10-27 13:27:01 +08:00
}
)
2021-10-15 15:01:21 +08:00
// Expert 专家列表
func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.ReturnPages, error) {
2021-10-27 13:27:01 +08:00
mUserManage := model.NewUserManage()
where := make([]*model2.ModelWhere, 0)
if name != "" {
where = append(where, model2.NewWhereLike("m.name", name))
}
if mobile != "" {
where = append(where, model2.NewWhereLike("u.mobile", mobile))
}
var count int64
out, err := mUserManage.Expert(page, pageSize, &count, where...)
if err != nil {
return nil, err
}
list := make([]*InstanceForExpert, 0)
for _, v := range out {
mUserManage.ID = v.ID
2021-11-01 11:19:49 +08:00
mUserManage.IdentityInfo = v.IdentityInfo
obj := mUserManage.GetIdentityInfoAttribute().(*model2.UserIdentityForExpert)
industry := make([]string, 0)
for _, v := range strings.Split(obj.Industry, ";") {
industry = append(industry, config.GetIndustryInfo(v, "-"))
}
2021-10-27 13:27:01 +08:00
list = append(list, &InstanceForExpert{
2021-11-01 11:19:49 +08:00
UserManageForExpert: v, ID: mUserManage.GetEncodeID(), Industry: strings.Join(industry, ""),
2021-10-27 13:27:01 +08:00
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
2021-10-15 15:01:21 +08:00
}
2021-10-27 13:27:01 +08:00
func NewInstance() InstanceHandle {
2021-10-15 15:01:21 +08:00
return func(enterprise *service.SessionEnterprise, local string) *Instance {
return &Instance{
SessionEnterprise: enterprise,
local: local,
}
}
}