Files

76 lines
1.6 KiB
Go
Raw Normal View History

2021-11-02 10:02:52 +08:00
package user
import (
2021-11-02 17:28:19 +08:00
model2 "ArmedPolice/app/common/model"
2021-11-02 16:22:07 +08:00
"ArmedPolice/app/controller/basic"
2021-11-02 17:01:04 +08:00
"ArmedPolice/app/model"
2021-11-02 10:02:52 +08:00
"ArmedPolice/app/service"
)
2021-11-02 16:22:07 +08:00
type Instance struct{ *service.Session }
2021-11-02 10:02:52 +08:00
type InstanceHandle func(session *service.Session) *Instance
2021-11-02 17:01:04 +08:00
type (
// InstanceBasic 基本信息
InstanceBasic struct {
Name string `json:"name"`
Avatar string `json:"avatar"`
}
// InstanceInfo 用户信息
InstanceInfo struct {
ID string `json:"id"`
*model.SysUserInfo
}
)
// Info 基本信息
func (c *Instance) Info() *InstanceBasic {
return &InstanceBasic{Name: c.Name, Avatar: c.Avatar}
}
// List 列表信息
2021-11-02 17:28:19 +08:00
func (c *Instance) List(name, mobile string, tenantID uint64, page, pageSize int) (*basic.PageDataResponse, error) {
2021-11-02 17:01:04 +08:00
mSysUser := model.NewSysUser()
2021-11-02 17:28:19 +08:00
where := make([]*model2.ModelWhere, 0)
if name != "" {
where = append(where, model2.NewWhereLike("u.name", name))
}
if mobile != "" {
where = append(where, model2.NewWhereLike("u.mobile", mobile))
}
if tenantID > 0 {
where = append(where, model2.NewWhere("u.tenant_id", tenantID))
}
2021-11-02 17:01:04 +08:00
var count int64
out, err := mSysUser.Users(page, pageSize, &count)
if err != nil {
return nil, err
}
list := make([]*InstanceInfo, 0)
for _, v := range out {
list = append(list, &InstanceInfo{ID: v.GetEncodeID(), SysUserInfo: v})
}
return &basic.PageDataResponse{Data: list, Count: count}, nil
2021-11-02 10:02:52 +08:00
}
2021-11-02 16:22:07 +08:00
func (c *Instance) Form() error {
2021-11-02 10:02:52 +08:00
return nil
}
2021-11-02 16:22:07 +08:00
func (c *Instance) Delete() error {
return nil
2021-11-02 10:02:52 +08:00
}
func NewInstance() InstanceHandle {
return func(session *service.Session) *Instance {
2021-11-02 16:22:07 +08:00
return &Instance{session}
2021-11-02 10:02:52 +08:00
}
}