74 lines
1.8 KiB
Go
74 lines
1.8 KiB
Go
package identity
|
||
|
||
import (
|
||
"SciencesServer/app/api/enterprise/model"
|
||
"SciencesServer/app/api/manage/controller"
|
||
"SciencesServer/app/basic/config"
|
||
model2 "SciencesServer/app/common/model"
|
||
"SciencesServer/app/service"
|
||
"strings"
|
||
)
|
||
|
||
type Instance struct {
|
||
*service.SessionEnterprise
|
||
local string
|
||
}
|
||
|
||
type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance
|
||
|
||
type (
|
||
// InstanceForExpert 专家信息
|
||
InstanceForExpert struct {
|
||
*model.UserManageForExpert
|
||
ID string `json:"id"`
|
||
Industry string `json:"industry"`
|
||
}
|
||
)
|
||
|
||
// Expert 专家列表
|
||
func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.ReturnPages, error) {
|
||
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
|
||
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, "-"))
|
||
}
|
||
list = append(list, &InstanceForExpert{
|
||
UserManageForExpert: v, ID: mUserManage.GetEncodeID(), Industry: strings.Join(industry, ";"),
|
||
})
|
||
}
|
||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||
}
|
||
|
||
func NewInstance() InstanceHandle {
|
||
return func(enterprise *service.SessionEnterprise, local string) *Instance {
|
||
return &Instance{
|
||
SessionEnterprise: enterprise,
|
||
local: local,
|
||
}
|
||
}
|
||
}
|