feat:完善后台经纪人审核信息
This commit is contained in:
138
app/api/admin/controller/manage/agent.go
Normal file
138
app/api/admin/controller/manage/agent.go
Normal file
@ -0,0 +1,138 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type AgentHandle func(session *session.Admin) *Agent
|
||||
|
||||
type (
|
||||
// AgentInfo 经纪人信息
|
||||
AgentInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
Industrys []string `json:"industrys"`
|
||||
CredentialImage string `json:"credential_image"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Area string `json:"area"`
|
||||
Demand struct {
|
||||
Total int `json:"total"`
|
||||
Complete int `json:"complete"`
|
||||
} `json:"detail"`
|
||||
model2.Examine
|
||||
}
|
||||
// AgentDetail 经纪人详细信息
|
||||
AgentDetail struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ManageAgent
|
||||
IDImage *model2.ManageAgentIDImage `json:"id_image"`
|
||||
}
|
||||
// AgentParams 经纪人参数信息
|
||||
AgentParams struct {
|
||||
ID, TenantID uint64
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Agent) Instance(tenantID uint64, name string, status int, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageAgent := model.NewManageAgent()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("a.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("a.tenant_id", tenantID))
|
||||
}
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("a.name", name))
|
||||
}
|
||||
if status > 0 {
|
||||
where = append(where, model2.NewWhere("a.examine_status", status))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageAgent.Agents(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*AgentInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
industrys := make([]string, 0)
|
||||
|
||||
for _, v := range v.GetIndustryAttribute() {
|
||||
industrys = append(industrys, config.GetIndustryInfo(v, "-", ">").Value)
|
||||
}
|
||||
demand := struct {
|
||||
Total int `json:"total"`
|
||||
Complete int `json:"complete"`
|
||||
}{}
|
||||
// 筛选处理需求信息
|
||||
for _, val := range strings.Split(v.Demand, ";") {
|
||||
objs := strings.Split(val, ":")
|
||||
|
||||
count := utils.StringToInt(objs[1])
|
||||
|
||||
if model2.TechnologyDemandServiceStatus(utils.StringToInt(objs[0])) == model2.TechnologyDemandServiceStatusForComplete {
|
||||
demand.Complete = count
|
||||
}
|
||||
demand.Total += count
|
||||
}
|
||||
list = append(list, &AgentInfo{
|
||||
ID: v.GetEncodeID(), Name: v.Name, Mobile: v.Mobile, Industrys: industrys,
|
||||
Examine: v.Examine, CreatedAt: v.CreatedAt, Area: v.FormatBasic(),
|
||||
Demand: demand,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Agent) Detail(id uint64) (*AgentDetail, error) {
|
||||
mManageAgent := model.NewManageAgent()
|
||||
mManageAgent.ID = id
|
||||
|
||||
isExist, err := model2.First(mManageAgent)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,经纪人信息不存在或已被删除")
|
||||
}
|
||||
idImage := mManageAgent.GetIDImageAttribute()
|
||||
|
||||
idImage.Front = (&model2.Image{Image: idImage.Front}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
idImage.Behind = (&model2.Image{Image: idImage.Behind}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
idImage.Hold = (&model2.Image{Image: idImage.Hold}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
return &AgentDetail{
|
||||
ID: mManageAgent.GetEncodeID(),
|
||||
TenantID: mManageAgent.GetEncodeTenantID(),
|
||||
ManageAgent: mManageAgent.ManageAgent,
|
||||
IDImage: idImage,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewAgent() AgentHandle {
|
||||
return func(session *session.Admin) *Agent {
|
||||
return &Agent{session}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user