feat:优化项目信息

This commit is contained in:
henry
2022-02-09 17:35:31 +08:00
parent 2d8be509b7
commit 56e8243724
15 changed files with 357 additions and 54 deletions

View File

@ -33,6 +33,11 @@ type (
ID string `json:"id"`
*model2.TechnologyPatent
}
// PatentFilterInfo 专利筛选信息
PatentFilterInfo struct {
Experts []*string
Patents []*PatentInfo `json:"patents"`
}
// PatentParams 专利参数信息
PatentParams struct {
ID, TenantID uint64
@ -92,17 +97,11 @@ func (c *PatentParams) checkParams(iModel *model.TechnologyPatent, condition map
}
// Instance 首页信息
func (c *Patent) Instance(tenantID uint64, title, ipc string, page, pageSize int) (*controller.ReturnPages, error) {
func (c *Patent) Instance(title, ipc string, page, pageSize int) (*controller.ReturnPages, error) {
mSysPatent := model.NewTechnologyPatent()
where := make([]*model2.ModelWhere, 0)
if c.TenantID > 0 {
where = append(where, model2.NewWhere("p.tenant_id", c.TenantID))
}
if tenantID > 0 {
where = append(where, model2.NewWhere("p.tenant_id", tenantID))
}
if title != "" {
where = append(where, model2.NewWhereLike("p.title", title))
}
@ -158,14 +157,12 @@ func (c *Patent) Form(params *PatentParams) error {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
return errors.New("操作错误,无权限操作")
}
if mTechnologyPatent.ApplyCode != params.ApplyCode {
_condition["apply_code"] = params.ApplyCode
}
if mTechnologyPatent.IPCCode != params.IPCCode {
_condition["ipc_code"] = params.IPCCode
_condition["open_code"] = params.OpenCode
}
if len(_condition) > 0 {
if isExist, err = mTechnologyPatent.IsExistParams(_condition); err != nil {
@ -217,14 +214,13 @@ func (c *Patent) Form(params *PatentParams) error {
return nil
}
_condition["apply_code"] = params.ApplyCode
_condition["ipc_code"] = params.IPCCode
_condition["open_code"] = params.OpenCode
if isExist, err := mTechnologyPatent.IsExistParams(_condition); err != nil {
return err
} else if isExist {
return errors.New("操作错误,申请号或公开(公告)号已存在")
}
mTechnologyPatent.TenantID = c.TenantID
if err := model2.Create(mTechnologyPatent.TechnologyPatent); err != nil {
return err
@ -234,6 +230,39 @@ func (c *Patent) Form(params *PatentParams) error {
return manage.Create()
}
// Filter 筛选信息
func (c *Patent) Filter(applyName, inventor string) (*PatentFilterInfo, error) {
// 查询用户专家信息
mManageResearch := model.NewManageResearch()
researchIDs := make([]uint64, 0)
err := model2.Pluck(mManageResearch.ManageResearch, "id", &researchIDs, model2.NewWhere("name", applyName),
model2.NewWhere("examine_status", model2.ExamineStatusForAgree))
if err != nil {
return nil, err
}
if len(researchIDs) > 0 {
// 查询科研机构下专家信息
mManageExpert := model.NewManageExpert()
experts := make([]*model2.ManageExpert, 0)
if err = model2.ScanFields(mManageExpert.ManageExpert, &experts, []string{"id", "uid", "name", "mobile"},
&model2.ModelWhereOrder{
Where: model2.NewWhere("name", inventor),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
}, &model2.ModelWhereOrder{
Where: model2.NewWhereIn("research_id", researchIDs),
}); err != nil {
return nil, err
}
}
return &PatentFilterInfo{}, nil
}
// Bind 绑定信息
func (c *Patent) Bind(id, uid uint64) error {
mTechnologyPatent := model.NewTechnologyPatent()
@ -245,8 +274,6 @@ func (c *Patent) Bind(id, uid uint64) error {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
return errors.New("操作错误,无权限操作")
}
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
"uid": uid, "updated_at": time.Now(),
@ -267,8 +294,6 @@ func (c *Patent) Delete(id uint64) error {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
return errors.New("操作错误,无权限操作")
}
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
if err = model2.Delete(mTechnologyPatent.TechnologyPatent, tx); err != nil {