Files
2021-11-01 11:19:49 +08:00

74 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
}
}
}