feat:优化项目信息
This commit is contained in:
@ -5,9 +5,11 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Company struct {
|
||||
@ -132,8 +134,23 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
if c.TenantID <= 0 {
|
||||
mManageCompany.TenantID = params.TenantID
|
||||
}
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range params.Industrys {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||
}
|
||||
manage := service.NewESManage(
|
||||
service.WithManageIdentity(config.TenantUserIdentityForCompany),
|
||||
service.WithManageIndustry(strings.Join(_industrys, ";")),
|
||||
service.WithManageKeyword(strings.Join(params.Keywords, ";")),
|
||||
)
|
||||
if mManageCompany.ID > 0 {
|
||||
return model2.Updates(mManageCompany.ManageCompany, mManageCompany.ManageCompany)
|
||||
if err := model2.Updates(mManageCompany.ManageCompany, mManageCompany.ManageCompany); err != nil {
|
||||
return nil
|
||||
}
|
||||
if mManageCompany.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
_ = manage.Update()
|
||||
}
|
||||
}
|
||||
// 查询手机号码是否在当前租户下是否已经注册了
|
||||
mManageCompany.Name = params.Name
|
||||
@ -148,7 +165,13 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在同一公司组织机构代码")
|
||||
}
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
if err := model2.Create(mManageCompany.ManageCompany); err != nil {
|
||||
return err
|
||||
}
|
||||
service.WithManageID(mManageCompany.ID)(manage)
|
||||
service.WithManageTitle(params.Name)(manage)
|
||||
|
||||
return manage.Create()
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
|
@ -7,8 +7,10 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -186,7 +188,6 @@ func (c *Patent) Form(params *PatentParams) error {
|
||||
mTechnologyPatent.Description = params.Description
|
||||
mTechnologyPatent.PrincipalClaim = params.PrincipalClaim
|
||||
mTechnologyPatent.IPCCode = params.IPCCode
|
||||
mTechnologyPatent.ShelfStatus = model2.ShelfStatusKind(params.ShelfStatus)
|
||||
mTechnologyPatent.Status = model2.TechnologyPatentStatus(params.Status)
|
||||
|
||||
// 查询IPCCode信息
|
||||
@ -207,7 +208,6 @@ func (c *Patent) Form(params *PatentParams) error {
|
||||
manage := service.NewESPatent(
|
||||
service.WithPatentTitle(mTechnologyPatent.Title),
|
||||
service.WithPatentIndustry(strings.Join(_industrys, ";")),
|
||||
service.WithPatentShow(params.Status),
|
||||
)
|
||||
if mTechnologyPatent.ID > 0 {
|
||||
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent); err != nil {
|
||||
@ -256,17 +256,6 @@ func (c *Patent) Bind(id, uid uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shelf 上下架操作
|
||||
func (c *Patent) Shelf(id uint64) error {
|
||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyPatent(), id, func(kind model2.ShelfStatusKind) error {
|
||||
manage := service.NewESPatent(
|
||||
service.WithPatentID(id),
|
||||
service.WithPatentShow(int(kind)),
|
||||
)
|
||||
return manage.Update()
|
||||
})
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Patent) Delete(id uint64) error {
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
@ -281,11 +270,23 @@ func (c *Patent) Delete(id uint64) error {
|
||||
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
err = model2.Delete(mTechnologyPatent.TechnologyPatent)
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Delete(mTechnologyPatent.TechnologyPatent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserPatent := model.NewUserPatent()
|
||||
|
||||
if err != nil {
|
||||
if err = model2.DeleteWhere(mUserPatent.UserPatent, []*model2.ModelWhere{
|
||||
model2.NewWhere("patent_id", id),
|
||||
model2.NewWhere("is_deleted", model2.DeleteStatusForNot),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = service.NewESPatent(service.WithPatentID(mTechnologyPatent.ID)).Delete()
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user