feat:完善信息,增加需求指派功能
This commit is contained in:
@ -123,6 +123,36 @@ func (c *Demand) Delete(id uint64) error {
|
||||
return model2.Delete(mTechnologyDemand.TechnologyDemand)
|
||||
}
|
||||
|
||||
// Assign 指派经纪人
|
||||
func (c *Demand) Assign(id, agentID uint64) error {
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
mTechnologyDemand.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyDemand.TechnologyDemand, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,需求信息不存在或已被删除")
|
||||
} else if c.TenantID > 0 && mTechnologyDemand.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
// 查询该需求是否已经指派
|
||||
mTechnologyDemandService := model.NewTechnologyDemandService()
|
||||
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mTechnologyDemandService.TechnologyDemandService, &count, model2.NewWhere("demand_id", id)); err != nil {
|
||||
return err
|
||||
} else if count > 0 {
|
||||
return errors.New("操作错误,该需求信息已指派,请勿重复指派")
|
||||
}
|
||||
mTechnologyDemandService.DemandID = id
|
||||
mTechnologyDemandService.AgentID = agentID
|
||||
|
||||
return model2.Create(mTechnologyDemandService.TechnologyDemandService)
|
||||
}
|
||||
|
||||
func NewDemand() DemandHandle {
|
||||
return func(session *session.Admin) *Demand {
|
||||
return &Demand{session}
|
||||
|
Reference in New Issue
Block a user