76 lines
1.6 KiB
Go
76 lines
1.6 KiB
Go
package user
|
|
|
|
import (
|
|
model2 "ArmedPolice/app/common/model"
|
|
"ArmedPolice/app/controller/basic"
|
|
"ArmedPolice/app/model"
|
|
"ArmedPolice/app/service"
|
|
)
|
|
|
|
type Instance struct{ *service.Session }
|
|
|
|
type InstanceHandle func(session *service.Session) *Instance
|
|
|
|
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 列表信息
|
|
func (c *Instance) List(name, mobile string, tenantID uint64, page, pageSize int) (*basic.PageDataResponse, error) {
|
|
mSysUser := model.NewSysUser()
|
|
|
|
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))
|
|
}
|
|
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
|
|
}
|
|
|
|
func (c *Instance) Form() error {
|
|
return nil
|
|
}
|
|
|
|
func (c *Instance) Delete() error {
|
|
return nil
|
|
}
|
|
|
|
func NewInstance() InstanceHandle {
|
|
return func(session *service.Session) *Instance {
|
|
return &Instance{session}
|
|
}
|
|
}
|