2022-01-14 17:09:06 +08:00
|
|
|
|
package technology
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"SciencesServer/app/api/admin/model"
|
|
|
|
|
"SciencesServer/app/basic/config"
|
|
|
|
|
"SciencesServer/app/basic/controller"
|
|
|
|
|
model2 "SciencesServer/app/common/model"
|
2022-02-08 18:26:40 +08:00
|
|
|
|
"SciencesServer/app/service"
|
2022-01-14 17:09:06 +08:00
|
|
|
|
"SciencesServer/app/session"
|
2022-02-09 11:06:59 +08:00
|
|
|
|
"SciencesServer/serve/orm"
|
2022-01-14 17:09:06 +08:00
|
|
|
|
"SciencesServer/utils"
|
|
|
|
|
"errors"
|
2022-02-09 11:06:59 +08:00
|
|
|
|
"gorm.io/gorm"
|
2022-02-08 18:26:40 +08:00
|
|
|
|
"strings"
|
2022-02-06 18:01:32 +08:00
|
|
|
|
"time"
|
2022-01-14 17:09:06 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Patent 专利信息
|
|
|
|
|
type Patent struct {
|
|
|
|
|
*session.Admin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PatentHandle func(session *session.Admin) *Patent
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
// PatentInfo 专利信息
|
|
|
|
|
PatentInfo struct {
|
2022-02-08 18:26:40 +08:00
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
*model.TechnologyPatentInfo
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
// PatentDetailInfo 专利详细信息
|
|
|
|
|
PatentDetailInfo struct {
|
|
|
|
|
ID string `json:"id"`
|
2022-02-06 18:01:32 +08:00
|
|
|
|
*model2.TechnologyPatent
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
2022-02-09 17:35:31 +08:00
|
|
|
|
// PatentFilterInfo 专利筛选信息
|
|
|
|
|
PatentFilterInfo struct {
|
|
|
|
|
Experts []*string
|
|
|
|
|
Patents []*PatentInfo `json:"patents"`
|
|
|
|
|
}
|
2022-01-14 17:09:06 +08:00
|
|
|
|
// PatentParams 专利参数信息
|
|
|
|
|
PatentParams struct {
|
|
|
|
|
ID, TenantID uint64
|
|
|
|
|
Kind int
|
|
|
|
|
Title, FileUrl string
|
|
|
|
|
ApplyCode, ApplyName, ApplyAddress, ApplyAt,
|
|
|
|
|
OpenCode, OpenAt string
|
|
|
|
|
Inventor, IPCCode, Description, PrincipalClaim string
|
|
|
|
|
ShelfStatus, Status int
|
|
|
|
|
}
|
|
|
|
|
// PatentIPCInfo 专利IPC信息
|
|
|
|
|
PatentIPCInfo struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
ParentID string `json:"parent_id"`
|
|
|
|
|
Industrys []string `json:"industrys"`
|
|
|
|
|
IndustrysTitle []string `json:"industrys_title"`
|
|
|
|
|
}
|
|
|
|
|
// PatentIPCParams 专利IPC参数信息
|
|
|
|
|
PatentIPCParams struct {
|
|
|
|
|
ID, ParentID uint64
|
|
|
|
|
IPC string
|
|
|
|
|
Industrys []string `json:"industrys"`
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
func (c *Patent) ipcTree(src []*model2.TechnologyPatentClassify, parentID uint64) []*PatentIPCInfo {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
out := make([]*PatentIPCInfo, 0)
|
|
|
|
|
|
|
|
|
|
for _, v := range src {
|
|
|
|
|
if v.ParentID == parentID {
|
|
|
|
|
industrys := v.GetIndustryAttribute()
|
|
|
|
|
industrysTitle := make([]string, 0)
|
|
|
|
|
|
|
|
|
|
for _, v := range industrys {
|
2022-01-20 09:43:26 +08:00
|
|
|
|
industrysTitle = append(industrysTitle, config.GetIndustryInfo(v, "-", "/").Value)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
out = append(out, &PatentIPCInfo{
|
|
|
|
|
ID: v.GetEncodeID(),
|
|
|
|
|
ParentID: (&model2.Model{ID: v.ParentID}).GetEncodeID(),
|
|
|
|
|
Industrys: industrys,
|
|
|
|
|
IndustrysTitle: industrysTitle,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
func (c *PatentParams) checkParams(iModel *model.TechnologyPatent, condition map[string]interface{}) error {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
isExist, err := iModel.IsExistParams(condition)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if isExist {
|
|
|
|
|
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Instance 首页信息
|
2022-02-09 17:35:31 +08:00
|
|
|
|
func (c *Patent) Instance(title, ipc string, page, pageSize int) (*controller.ReturnPages, error) {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mSysPatent := model.NewTechnologyPatent()
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
where := make([]*model2.ModelWhere, 0)
|
|
|
|
|
|
|
|
|
|
if title != "" {
|
|
|
|
|
where = append(where, model2.NewWhereLike("p.title", title))
|
|
|
|
|
}
|
|
|
|
|
if ipc != "" {
|
|
|
|
|
where = append(where, model2.NewWhereLike("p.ipc", ipc))
|
|
|
|
|
}
|
|
|
|
|
var count int64
|
|
|
|
|
|
|
|
|
|
out, err := mSysPatent.Patent(page, pageSize, &count, where...)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
2022-01-15 09:00:47 +08:00
|
|
|
|
list := make([]*PatentInfo, 0)
|
|
|
|
|
|
|
|
|
|
for _, v := range out {
|
|
|
|
|
list = append(list, &PatentInfo{
|
2022-02-08 18:26:40 +08:00
|
|
|
|
ID: v.GetEncodeID(),
|
|
|
|
|
TechnologyPatentInfo: v,
|
2022-01-15 09:00:47 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Detail 详细信息
|
|
|
|
|
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatent := model.NewTechnologyPatent()
|
|
|
|
|
mTechnologyPatent.ID = id
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
isExist, err := model2.First(mTechnologyPatent.TechnologyPatent)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return nil, errors.New("操作错误,专利信息不存在或已被删除")
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
return &PatentDetailInfo{ID: mTechnologyPatent.GetEncodeID(),
|
|
|
|
|
TechnologyPatent: mTechnologyPatent.TechnologyPatent}, nil
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Form 数据操作
|
|
|
|
|
func (c *Patent) Form(params *PatentParams) error {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatent := model.NewTechnologyPatent()
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
_condition := make(map[string]interface{}, 0)
|
|
|
|
|
|
|
|
|
|
if params.ID > 0 {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatent.ID = params.ID
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-03-07 13:46:46 +08:00
|
|
|
|
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "ipc_code", "created_at"})
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return errors.New("操作错误,专利信息不存在或已被删除")
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if mTechnologyPatent.ApplyCode != params.ApplyCode {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
_condition["apply_code"] = params.ApplyCode
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if mTechnologyPatent.IPCCode != params.IPCCode {
|
2022-02-09 17:35:31 +08:00
|
|
|
|
_condition["open_code"] = params.OpenCode
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
if len(_condition) > 0 {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if isExist, err = mTechnologyPatent.IsExistParams(_condition); err != nil {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
return err
|
|
|
|
|
} else if isExist {
|
|
|
|
|
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-08 08:56:28 +08:00
|
|
|
|
mTechnologyPatent.Kind = model2.TechnologyPatentKind(params.Kind)
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatent.Title = params.Title
|
|
|
|
|
mTechnologyPatent.FileUrl = params.FileUrl
|
|
|
|
|
mTechnologyPatent.ApplyCode = params.ApplyCode
|
|
|
|
|
mTechnologyPatent.ApplyAt = params.ApplyAt
|
|
|
|
|
mTechnologyPatent.OpenCode = params.OpenCode
|
|
|
|
|
mTechnologyPatent.OpenAt = params.OpenAt
|
|
|
|
|
mTechnologyPatent.ApplyName = params.ApplyName
|
|
|
|
|
mTechnologyPatent.ApplyAddress = params.ApplyAddress
|
|
|
|
|
mTechnologyPatent.Inventor = params.Inventor
|
|
|
|
|
mTechnologyPatent.Description = params.Description
|
|
|
|
|
mTechnologyPatent.PrincipalClaim = params.PrincipalClaim
|
|
|
|
|
mTechnologyPatent.IPCCode = params.IPCCode
|
2022-02-08 08:56:28 +08:00
|
|
|
|
mTechnologyPatent.Status = model2.TechnologyPatentStatus(params.Status)
|
2022-02-06 18:01:32 +08:00
|
|
|
|
|
2022-02-08 18:26:40 +08:00
|
|
|
|
// 查询IPCCode信息
|
|
|
|
|
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
|
|
|
|
|
|
|
|
|
isExist, err := model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "industry_detail"},
|
|
|
|
|
model2.NewWhere("ipc", params.IPCCode))
|
|
|
|
|
|
|
|
|
|
_industrys := make([]string, 0)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if isExist {
|
|
|
|
|
for _, v := range mTechnologyPatentClassify.GetIndustryDetailAttribute() {
|
|
|
|
|
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
manage := service.NewESPatent(
|
|
|
|
|
service.WithPatentTitle(mTechnologyPatent.Title),
|
|
|
|
|
service.WithPatentIndustry(strings.Join(_industrys, ";")),
|
|
|
|
|
)
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if mTechnologyPatent.ID > 0 {
|
2022-02-08 18:26:40 +08:00
|
|
|
|
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
_ = manage.Update()
|
|
|
|
|
return nil
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
_condition["apply_code"] = params.ApplyCode
|
2022-02-09 17:35:31 +08:00
|
|
|
|
_condition["open_code"] = params.OpenCode
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if isExist, err := mTechnologyPatent.IsExistParams(_condition); err != nil {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
return err
|
|
|
|
|
} else if isExist {
|
|
|
|
|
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
|
|
|
|
}
|
2022-02-08 18:26:40 +08:00
|
|
|
|
|
|
|
|
|
if err := model2.Create(mTechnologyPatent.TechnologyPatent); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
service.WithPatentID(mTechnologyPatent.ID)(manage)
|
|
|
|
|
|
|
|
|
|
return manage.Create()
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-09 17:35:31 +08:00
|
|
|
|
// 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)
|
|
|
|
|
|
2022-02-15 17:19:23 +08:00
|
|
|
|
if err = model2.ScanFields(mManageExpert.ManageExpert, &experts, []string{"id", "name", "mobile"},
|
2022-02-09 17:35:31 +08:00
|
|
|
|
&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
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 17:09:06 +08:00
|
|
|
|
// Bind 绑定信息
|
|
|
|
|
func (c *Patent) Bind(id, uid uint64) error {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatent := model.NewTechnologyPatent()
|
|
|
|
|
mTechnologyPatent.ID = id
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-03-07 13:46:46 +08:00
|
|
|
|
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return errors.New("操作错误,专利信息不存在或已被删除")
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
|
|
|
|
|
"uid": uid, "updated_at": time.Now(),
|
|
|
|
|
}); err != nil {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
return err
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
return nil
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete 删除操作
|
|
|
|
|
func (c *Patent) Delete(id uint64) error {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatent := model.NewTechnologyPatent()
|
|
|
|
|
mTechnologyPatent.ID = id
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-15 17:19:23 +08:00
|
|
|
|
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id"})
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return errors.New("操作错误,专利信息不存在或已被删除")
|
|
|
|
|
}
|
2022-02-09 11:06:59 +08:00
|
|
|
|
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
|
|
|
|
if err = model2.Delete(mTechnologyPatent.TechnologyPatent, tx); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2022-02-09 18:38:32 +08:00
|
|
|
|
mTechnologyPatentExpert := model.NewTechnologyPatentExpert()
|
2022-02-08 18:26:40 +08:00
|
|
|
|
|
2022-02-09 18:38:32 +08:00
|
|
|
|
if err = model2.DeleteWhere(mTechnologyPatentExpert.TechnologyPatentExpert, []*model2.ModelWhere{
|
2022-02-09 11:06:59 +08:00
|
|
|
|
model2.NewWhere("patent_id", id),
|
|
|
|
|
model2.NewWhere("is_deleted", model2.DeleteStatusForNot),
|
|
|
|
|
}, tx); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}); err != nil {
|
2022-02-08 18:26:40 +08:00
|
|
|
|
return err
|
|
|
|
|
}
|
2022-02-09 11:06:59 +08:00
|
|
|
|
|
2022-02-08 18:26:40 +08:00
|
|
|
|
_ = service.NewESPatent(service.WithPatentID(mTechnologyPatent.ID)).Delete()
|
|
|
|
|
|
|
|
|
|
return nil
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IPC IPC信息
|
|
|
|
|
func (c *Patent) IPC() ([]*PatentIPCInfo, error) {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
|
|
|
|
out := make([]*model2.TechnologyPatentClassify, 0)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if err := model2.Scan(mTechnologyPatentClassify.TechnologyPatentClassify, &out); err != nil {
|
2022-01-14 17:09:06 +08:00
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return c.ipcTree(out, 0), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IPCForm IPC数据操作
|
|
|
|
|
func (c *Patent) IPCForm(params *PatentIPCParams) error {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if params.ID > 0 {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify.ID = params.ID
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
isExist, err := model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "created_at"})
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return errors.New("操作错误,IPC信息不存在或已被删除")
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify.SetIndustryDetailAttribute(params.Industrys)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
// 查询上级元素
|
|
|
|
|
if params.ParentID > 0 {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mPTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
|
|
|
|
mPTechnologyPatentClassify.ID = params.ParentID
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
isExist, err := model2.FirstField(mPTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "industry"})
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return errors.New("操作错误,IPC父级信息不存在或已被删除")
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
_identitys := mPTechnologyPatentClassify.GetIndustryDetailAttribute()
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
for _, v := range params.Industrys {
|
|
|
|
|
if utils.InArray(v, _identitys) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
_identitys = append(_identitys, v)
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify.SetIndustryDetailAttribute(_identitys)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify.ParentID = params.ParentID
|
|
|
|
|
mTechnologyPatentClassify.IPC = params.IPC
|
|
|
|
|
mTechnologyPatentClassify.SetIndustryAttribute(params.Industrys)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
if mTechnologyPatentClassify.ID > 0 {
|
|
|
|
|
return model2.Updates(mTechnologyPatentClassify.TechnologyPatentClassify, mTechnologyPatentClassify.TechnologyPatentClassify)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
return model2.Create(mTechnologyPatentClassify.TechnologyPatentClassify)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IPCDelete IPC删除操作
|
|
|
|
|
func (c *Patent) IPCDelete(id uint64) error {
|
2022-02-06 18:01:32 +08:00
|
|
|
|
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
|
|
|
|
mTechnologyPatentClassify.ID = id
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
2022-02-06 18:01:32 +08:00
|
|
|
|
isExist, err := model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "created_at"})
|
2022-01-14 17:09:06 +08:00
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
} else if !isExist {
|
|
|
|
|
return errors.New("操作错误,IPC信息不存在或已被删除")
|
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
|
return model2.Delete(mTechnologyPatentClassify.TechnologyPatentClassify)
|
2022-01-14 17:09:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewPatent() PatentHandle {
|
|
|
|
|
return func(session *session.Admin) *Patent {
|
|
|
|
|
return &Patent{
|
|
|
|
|
Admin: session,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|