feat:优化项目信息
This commit is contained in:
@ -237,53 +237,48 @@ func (c *Expert) Patent(id uint64, title, applyName string) ([]*ExpertPatent, er
|
||||
}
|
||||
|
||||
// PatentBind 专利认领绑定
|
||||
func (c *Expert) PatentBind(id uint64, patentID []uint64) error {
|
||||
mUserExpert := model.NewUserExpert()
|
||||
func (c *Expert) PatentBind(id uint64, patentIDs []uint64) error {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
mManageExpert.ID = id
|
||||
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
err := model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,专家信息不存在或已被删除")
|
||||
} else if c.TenantID > 0 && c.TenantID != mManageExpert.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if len(uids) <= 0 {
|
||||
return nil
|
||||
}
|
||||
data := make([]*model2.UserPatent, 0)
|
||||
data := make([]*model2.TechnologyPatentExpert, 0)
|
||||
|
||||
for _, uid := range uids {
|
||||
for _, v := range patentID {
|
||||
data = append(data, &model2.UserPatent{
|
||||
UID: uid,
|
||||
PatentID: v,
|
||||
})
|
||||
}
|
||||
for _, v := range patentIDs {
|
||||
data = append(data, &model2.TechnologyPatentExpert{
|
||||
ExpertID: mManageExpert.ID, PatentID: v,
|
||||
})
|
||||
}
|
||||
if len(data) > 0 {
|
||||
return model2.Creates(model.NewUserPatent().UserPatent, data)
|
||||
return model2.Creates(model.NewTechnologyPatentExpert().TechnologyPatentExpert, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PatentUnbind 专利认领解绑
|
||||
func (c *Expert) PatentUnbind(id uint64, patentID []uint64) error {
|
||||
mUserExpert := model.NewUserExpert()
|
||||
mManageExpert := model.NewManageExpert()
|
||||
mManageExpert.ID = id
|
||||
|
||||
uids := make([]uint64, 0)
|
||||
|
||||
err := model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id),
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,专家信息不存在或已被删除")
|
||||
} else if c.TenantID > 0 && c.TenantID != mManageExpert.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if len(uids) <= 0 {
|
||||
return nil
|
||||
}
|
||||
return model2.DeleteWhere(model.NewUserPatent().UserPatent, []*model2.ModelWhere{
|
||||
model2.NewWhereIn("uid", uids),
|
||||
return model2.DeleteWhere(model.NewTechnologyPatentExpert().TechnologyPatentExpert, []*model2.ModelWhere{
|
||||
model2.NewWhere("expert_id", mManageExpert.ID),
|
||||
model2.NewWhereIn("patent_id", patentID),
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user