feat:优化项目信息
This commit is contained in:
@ -54,7 +54,7 @@ func (*Technology) PatentForm(c *gin.Context) {
|
||||
Inventor string `json:"inventor" form:"inventor"`
|
||||
PrincipalClaim string `json:"principal_claim" form:"principal_claim"`
|
||||
Description string `json:"description" form:"description"`
|
||||
ShelfStatus int `json:"shelf_status" form:"shelf_status" binding:"required"`
|
||||
ShelfStatus int `json:"shelf_status" form:"shelf_status"` // TODO:已删除,不需要
|
||||
Status int `json:"status" form:"status"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
@ -89,17 +89,6 @@ func (*Technology) PatentExamine(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (*Technology) PatentShelf(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPatent()(api.GetSession()(c).(*session.Admin)).Shelf(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Technology) PatentDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
|
@ -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
|
||||
|
@ -44,7 +44,7 @@ func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, e
|
||||
func (m *TechnologyPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "p.kind", "p.title", "p.apply_code", "p.inventor", "p.apply_name", "p.apply_at",
|
||||
"p.shelf_status", "p.created_at").
|
||||
"p.created_at").
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
|
12
app/api/admin/model/user_patent.go
Normal file
12
app/api/admin/model/user_patent.go
Normal file
@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
// UserPatent 用户专利信息
|
||||
type UserPatent struct {
|
||||
*model.UserPatent
|
||||
}
|
||||
|
||||
func NewUserPatent() *UserPatent {
|
||||
return &UserPatent{model.NewUserPatent()}
|
||||
}
|
Reference in New Issue
Block a user