feat:完善后台经纪人审核信息
This commit is contained in:
@ -277,7 +277,29 @@ func (*Manage) LaboratoryExamine(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (*Manage) Agent(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Name string `json:"name" form:"name"`
|
||||
ExamineStatus int `json:"examine_status" form:"examine_status"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewAgent()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Name, form.ExamineStatus, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) AgentDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewAgent()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) AgentExamine(c *gin.Context) {
|
||||
|
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}
|
||||
}
|
||||
}
|
@ -1,11 +1,52 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageAgent struct {
|
||||
*model.ManageAgent
|
||||
}
|
||||
|
||||
type ManageAgentInfo struct {
|
||||
*model.ManageAgent
|
||||
Demand string `json:"-"`
|
||||
model.Area
|
||||
}
|
||||
|
||||
// Agents 经纪人信息
|
||||
func (m *ManageAgent) Agents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageAgentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.tenant_id", "a.name", "a.mobile", "a.industry", "a.credential_image",
|
||||
"a.examine_status", "a.examine_remark", "a.examine_at", "a.created_at", "t.province", "t.city", "d.demand").
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT a.agent_id, GROUP_CONCAT(a.`status`, ':', a.count SEPARATOR ';') AS demand FROM ("+
|
||||
"SELECT u_a.agent_id, d.status, COUNT(d.id) AS count FROM %s AS u_a "+
|
||||
"LEFT JOIN %s AS d ON u_a.uid = d.uid AND d.is_deleted = %d "+
|
||||
"WHERE u_a.is_deleted = %d AND u_a.invalid_status = %d GROUP BY u_a.agent_id, d.status) AS a GROUP BY a.agent_id) AS d ON a.id = d.agent_id",
|
||||
model.NewUserAgent().TableName(), model.NewTechnologyDemandService().TableName(), model.DeleteStatusForNot,
|
||||
model.DeleteStatusForNot, model.InvalidStatusForNot,
|
||||
)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON a.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageAgentInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageAgent() *ManageAgent {
|
||||
return &ManageAgent{model.NewManageAgent()}
|
||||
}
|
||||
|
@ -431,5 +431,12 @@ func (*Manage) AgentCompanyEdit(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (*Manage) AgentCompanyDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := manage.NewAgent()(api.GetSession()(c).(*session.Enterprise)).Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
"errors"
|
||||
)
|
||||
@ -16,12 +17,14 @@ var instanceHandle = map[int]func(int, int, string, string, map[string]interface
|
||||
|
||||
// Launch 发起搜索
|
||||
func (c *Instance) Launch(mode int, keyword, industry string, params map[string]interface{}, page, pageSize int) (interface{}, error) {
|
||||
_industry := config.GetIndustryInfo(industry, "-", "-").Value
|
||||
|
||||
handle, has := instanceHandle[mode]
|
||||
|
||||
if !has {
|
||||
return nil, errors.New("操作错误,未知的搜索模式")
|
||||
}
|
||||
return handle(page, pageSize, keyword, industry, params)
|
||||
return handle(page, pageSize, keyword, _industry, params)
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
|
@ -21,7 +21,7 @@ type synchronized struct {
|
||||
}
|
||||
|
||||
func (this *Instance) Handle() {
|
||||
fmt.Println("========================\n=== 数据开始迁移 ===\n========================")
|
||||
fmt.Println("========================\n=== 数据开始迁移 ===\n========================")
|
||||
|
||||
db := this.gormDB
|
||||
|
||||
@ -141,6 +141,7 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewTechnologyAchievement()}, &synchronized{iModel: model.NewTechnologyDemand()},
|
||||
&synchronized{iModel: model.NewTechnologyPaper()}, &synchronized{iModel: model.NewTechnologyProduct()},
|
||||
&synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()},
|
||||
&synchronized{iModel: model.NewTechnologyDemandService()}, &synchronized{iModel: model.NewTechnologyDemandServiceProgress()},
|
||||
&synchronized{iModel: model.NewServiceDocking()},
|
||||
&synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceMessageLog()},
|
||||
&synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()},
|
||||
|
32
app/common/model/technology_demand_service.go
Normal file
32
app/common/model/technology_demand_service.go
Normal file
@ -0,0 +1,32 @@
|
||||
package model
|
||||
|
||||
// TechnologyDemandService 技术需求服务信息
|
||||
type TechnologyDemandService struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
DemandID uint64 `gorm:"column:demand_id;type:int(11);default:0;comment:需求ID" json:"-"`
|
||||
Progress TechnologyDemandServiceProgressKind `gorm:"column:progress;type:tinyint(1);default:0;comment:进度类型" json:"progress"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:0;comment:进度状态(0:进行中,1:已完成)" json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// TechnologyDemandServiceProgressKind 技术需求服务进度类型
|
||||
type TechnologyDemandServiceProgressKind int
|
||||
|
||||
type TechnologyDemandServiceStatus int
|
||||
|
||||
const (
|
||||
// TechnologyDemandServiceStatusForOngoing 进行中
|
||||
TechnologyDemandServiceStatusForOngoing TechnologyDemandServiceStatus = iota
|
||||
// TechnologyDemandServiceStatusForComplete 已完成
|
||||
TechnologyDemandServiceStatusForComplete
|
||||
)
|
||||
|
||||
func (m *TechnologyDemandService) TableName() string {
|
||||
return "technology_demand_service"
|
||||
}
|
||||
|
||||
func NewTechnologyDemandService() *TechnologyDemandService {
|
||||
return &TechnologyDemandService{}
|
||||
}
|
19
app/common/model/technology_demand_service_progress.go
Normal file
19
app/common/model/technology_demand_service_progress.go
Normal file
@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
// TechnologyDemandServiceProgress 技术需求服务进度信息
|
||||
type TechnologyDemandServiceProgress struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Progress TechnologyDemandServiceProgressKind `gorm:"column:progress;type:tinyint(1);default:0;comment:进度类型" json:"progress"`
|
||||
Config string `gorm:"column:config;type:text;comment:详细信息" json:"config"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *TechnologyDemandServiceProgress) TableName() string {
|
||||
return "technology_demand_service_progress"
|
||||
}
|
||||
|
||||
func NewTechnologyDemandServiceProgress() *TechnologyDemandServiceProgress {
|
||||
return &TechnologyDemandServiceProgress{}
|
||||
}
|
@ -24,7 +24,8 @@ func (this *ESPatent) Create() error {
|
||||
}
|
||||
|
||||
func (this *ESPatent) Update() error {
|
||||
return nil
|
||||
_bytes, _ := json.Marshal(this)
|
||||
return es.Update(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
||||
}
|
||||
|
||||
func (this *ESPatent) Search(page, pageSize int) (interface{}, int64, error) {
|
||||
|
Reference in New Issue
Block a user