Files

65 lines
1.4 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-10-27 13:27:01 +08:00
model2 "SciencesServer/app/common/model"
2021-11-24 10:50:09 +08:00
"SciencesServer/app/session"
2021-10-15 15:01:21 +08:00
)
type Instance struct {
2021-11-24 10:50:09 +08:00
*session.Enterprise
2021-10-15 15:01:21 +08:00
local string
}
2021-11-24 10:50:09 +08:00
type InstanceHandle func(session *session.Enterprise, local string) *Instance
2021-10-15 15:01:21 +08:00
2021-10-27 13:27:01 +08:00
type (
// InstanceForExpert 专家信息
InstanceForExpert struct {
2021-12-01 14:12:23 +08:00
ID string `json:"id"`
*model.UserIdentityForExpert
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-12-01 14:12:23 +08:00
mUserIdentity := model.NewUserIdentity()
2021-10-27 13:27:01 +08:00
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
2021-12-01 14:12:23 +08:00
out, err := mUserIdentity.Expert(page, pageSize, &count, where...)
2021-10-27 13:27:01 +08:00
if err != nil {
return nil, err
}
list := make([]*InstanceForExpert, 0)
for _, v := range out {
2021-12-01 14:12:23 +08:00
mUserIdentity.ID = v.ID
2021-11-01 11:19:49 +08:00
2021-10-27 13:27:01 +08:00
list = append(list, &InstanceForExpert{
2021-12-01 14:12:23 +08:00
ID: mUserIdentity.GetEncodeID(), UserIdentityForExpert: v,
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-11-24 10:50:09 +08:00
return func(session *session.Enterprise, local string) *Instance {
2021-10-15 15:01:21 +08:00
return &Instance{
2021-11-24 10:50:09 +08:00
Enterprise: session,
local: local,
2021-10-15 15:01:21 +08:00
}
}
}