feat:优化项目信息

This commit is contained in:
henry
2022-02-09 11:06:59 +08:00
parent 1cec70ebee
commit 2d8be509b7
15 changed files with 217 additions and 285 deletions

View File

@ -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)

View File

@ -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 详细信息

View File

@ -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

View File

@ -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 {

View 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()}
}

View File

@ -1,27 +0,0 @@
package api
import (
"SciencesServer/app/api/enterprise/controller/sys"
"SciencesServer/app/basic/api"
"github.com/gin-gonic/gin"
)
type Sys struct{}
func (*Sys) Patent(c *gin.Context) {
form := &struct {
Kind int `json:"kind" form:"kind"`
Title string `json:"title" form:"title"`
ApplyCode string `json:"apply_code" form:"apply_code"`
OpenCode string `json:"open_code" form:"open_code"`
IPCCode string `json:"ipc_code" form:"ipc_code"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := sys.NewPatent()(nil).
List(form.Kind, form.Title, form.ApplyCode, form.OpenCode, form.IPCCode, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}

View File

@ -1,110 +0,0 @@
package sys
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"SciencesServer/utils"
"strings"
"time"
)
// Patent 专利信息
type Patent struct {
*session.Enterprise
}
type PatentHandle func(session *session.Enterprise) *Patent
type (
// PatentInfo 专利信息
PatentInfo struct {
ID string `json:"id"`
Kind model2.TechnologyPatentKind `json:"kind"`
Title string `json:"title"`
ApplyName string `json:"apply_name"`
ApplyCode string `json:"apply_code"`
ApplyAt string `json:"apply_at"`
Inventor string `json:"inventor"`
CreatedAt time.Time `json:"created_at"`
}
)
func (c *Patent) filter(src string) string {
src = utils.ReplaceAllCompile(src, "\t", "")
src = utils.ReplaceAllCompile(src, "\n", "")
src = strings.TrimLeft(src, " ")
src = strings.TrimRight(src, " ")
return src
}
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyPatent := model.NewTechnologyPatent()
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}}
if kind <= 0 {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhere("kind", kind),
})
}
if title != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("title", title),
})
}
if applyCode != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("apply_code", applyCode),
})
}
if openCode != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("open_code", openCode),
})
}
if ipcCode != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("ipc_code", ipcCode),
})
}
out := make([]*model2.TechnologyPatent, 0)
var count int64
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{"id", "title", "apply_code", "apply_name", "apply_at", "created_at"}, page, pageSize, &count); err != nil {
return nil, err
}
list := make([]*PatentInfo, 0)
for _, v := range out {
list = append(list, &PatentInfo{
ID: v.GetEncodeID(), Kind: v.Kind, Title: v.Title,
ApplyName: v.ApplyName, ApplyCode: v.ApplyCode, ApplyAt: v.ApplyAt,
CreatedAt: v.CreatedAt,
})
//v.ApplyName = c.filter(v.ApplyName)
//v.ApplyAddress = c.filter(v.ApplyAddress)
//v.Inventor = c.filter(v.Inventor)
//v.Description = c.filter(v.Description)
}
return &controller.ReturnPages{
Data: out,
Count: count,
}, nil
}
func (c *Patent) Select() {
}
func NewPatent() PatentHandle {
return func(session *session.Enterprise) *Patent {
return &Patent{Enterprise: session}
}
}

View File

@ -1,7 +1,6 @@
package technology
import (
"SciencesServer/app/api/enterprise/controller/sys"
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
@ -12,7 +11,6 @@ import (
"errors"
"gorm.io/gorm"
"strings"
"time"
)
// Patent 专利管理
@ -26,9 +24,8 @@ type PatentHandle func(session *session.Enterprise, tenantID uint64) *Patent
type (
// PatentInfo 专利信息
PatentInfo struct {
*sys.PatentInfo
ShelfStatus model2.ShelfStatusKind
Status model2.TechnologyPatentStatus
ID string `json:"id"`
*model.UserPatentInfo
}
// PatentMatchInfo 专利匹配信息
PatentMatchInfo struct {
@ -70,7 +67,6 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
mTechnologyPatent.Kind = model2.TechnologyPatentKind(c.Kind)
mTechnologyPatent.TenantID = tenantID
mTechnologyPatent.UID = uid
mTechnologyPatent.Title = c.Title
mTechnologyPatent.FileUrl = c.FileUrl
mTechnologyPatent.ApplyCode = c.ApplyCode
@ -88,6 +84,13 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
if err = model2.Create(mTechnologyPatent.TechnologyPatent, tx); err != nil {
return err
}
mUserPatent := model.NewUserPatent()
mUserPatent.UID = uid
mUserPatent.PatentID = mTechnologyPatent.ID
if err = model2.Create(mUserPatent.UserPatent, tx); err != nil {
return err
}
manage := service.NewESPatent(
service.WithPatentID(mTechnologyPatent.ID),
service.WithPatentTitle(mTechnologyPatent.Title),
@ -114,18 +117,26 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
// edit 删除专利信息
func (c *PatentParams) edit(uid uint64) error {
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = c.ID
mUserPatent := model.NewUserPatent()
mUserPatent.ID = c.ID
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "open_code", "created_at"})
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
} else if mTechnologyPatent.UID != uid {
return errors.New("操作错误,用户专利信息不存在或已被删除")
} else if mUserPatent.UID != uid {
return errors.New("操作错误,无权限操作")
}
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = mUserPatent.PatentID
if isExist, err = model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "apply_code", "open_code", "created_at"}); err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
}
_condition := make(map[string]interface{}, 0)
if mTechnologyPatent.ApplyCode != c.ApplyCode {
@ -133,7 +144,6 @@ func (c *PatentParams) edit(uid uint64) error {
}
if mTechnologyPatent.OpenCode != c.OpenCode {
_condition["open_code"] = c.OpenCode
}
if len(_condition) > 0 {
if isExist, err = mTechnologyPatent.IsExistParams(_condition); err != nil {
@ -171,44 +181,28 @@ func (c *PatentParams) edit(uid uint64) error {
// List 列表信息
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyPatent := model.NewTechnologyPatent()
mUserPatent := model.NewUserPatent()
where := []*model2.ModelWhere{model2.NewWhere("u.uid", c.UID)}
where := []*model2.ModelWhereOrder{
&model2.ModelWhereOrder{
Where: model2.NewWhere("uid", c.UID),
},
}
if kind <= 0 {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhere("kind", kind),
})
where = append(where, model2.NewWhere("p.kind", kind))
}
if title != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("title", title),
})
where = append(where, model2.NewWhereLike("p.title", title))
}
if applyCode != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("apply_code", applyCode),
})
where = append(where, model2.NewWhereLike("p.apply_code", applyCode))
}
if openCode != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("open_code", openCode),
})
where = append(where, model2.NewWhereLike("p.open_code", openCode))
}
if ipcCode != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("ipc_code", ipcCode),
})
where = append(where, model2.NewWhereLike("p.ipc_code", ipcCode))
}
var count int64
out := make([]*model2.TechnologyPatent, 0)
err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, out, []string{"id", "title", "apply_code",
"apply_name", "apply_at", "shelf", "status", "created_at"}, page, pageSize, &count, where...)
out, err := mUserPatent.Patent(page, pageSize, &count, where...)
if err != nil {
return nil, err
@ -217,11 +211,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
for _, v := range out {
list = append(list, &PatentInfo{
PatentInfo: &sys.PatentInfo{
ID: v.GetEncodeID(), Title: v.Title, ApplyCode: v.ApplyCode, ApplyName: v.ApplyName,
ApplyAt: v.ApplyAt, Inventor: v.Inventor,
},
ShelfStatus: v.ShelfStatus, Status: v.Status,
ID: v.GetEncodeID(), UserPatentInfo: v,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
@ -290,53 +280,40 @@ func (c *Patent) Form(params *PatentParams) error {
}
// Shelf 上下架操作
func (c *Patent) Shelf(id uint64, status int) error {
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = id
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
} else if mTechnologyPatent.UID != c.UID {
return errors.New("操作错误,无权限操作")
}
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
"shelf": status, "updated_at": time.Now(),
}); err != nil {
return err
}
manage := service.NewESPatent(
service.WithPatentID(mTechnologyPatent.ID),
service.WithPatentShow(status),
)
return manage.Update()
}
// Delete 删除操作
func (c *Patent) Delete(id uint64) error {
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = id
mUserPatent := model.NewUserPatent()
mUserPatent.ID = id
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专利信息不存在或已被删除")
} else if mTechnologyPatent.UID != c.UID {
return errors.New("操作错误,用户专利信息不存在或已被删除")
} else if mUserPatent.UID != c.UID {
return errors.New("操作错误,无权限操作")
}
if err = model2.Delete(mTechnologyPatent.TechnologyPatent); err != nil {
// 只删除关联关系
if err = model2.Delete(mUserPatent.UserPatent); err != nil {
return err
}
manage := service.NewESPatent(
service.WithPatentID(mTechnologyPatent.ID),
)
return manage.Delete()
//mTechnologyPatent := model.NewTechnologyPatent()
//mTechnologyPatent.ID = mUserPatent.PatentID
//
//if isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id"}); err != nil {
// return err
//} else if !isExist {
// return errors.New("操作错误,专利信息不存在或已被删除")
//}
//if err = model2.Delete(mTechnologyPatent.TechnologyPatent); err != nil {
// return err
//}
//manage := service.NewESPatent(
// service.WithPatentID(mTechnologyPatent.ID),
//)
//return manage.Delete()
return nil
}
func NewPatent() PatentHandle {

View File

@ -97,20 +97,20 @@ func (c *Project) Form(params *ProjectParams) error {
// Shelf 上下架操作
func (c *Project) Shelf(id uint64, status int) error {
mTechnologyPatent := model.NewTechnologyPatent()
mTechnologyPatent.ID = id
mTechnologyProject := model.NewTechnologyProject()
mTechnologyProject.ID = id
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
isExist, err := model2.FirstField(mTechnologyProject.TechnologyProject, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,项目信息不存在或已被删除")
} else if mTechnologyPatent.UID != c.UID {
} else if mTechnologyProject.UID != c.UID {
return errors.New("操作错误,无权限操作")
}
return model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
return model2.Updates(mTechnologyProject.TechnologyProject, map[string]interface{}{
"shelf_status": status, "updated_at": time.Now(),
})
}

View File

@ -0,0 +1,51 @@
package model
import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"time"
)
type UserPatent struct {
*model.UserPatent
}
// UserPatentInfo 用户专利信息
type UserPatentInfo struct {
model.Model
Title string `json:"title"`
ApplyCode string `json:"apply_code"`
ApplyName string `json:"apply_name"`
ApplyAt string `json:"apply_at"`
model.Shelf
Status model.TechnologyPatentStatus `json:"status"`
CreatedAt time.Time
}
// Patent 专利信息
func (m *UserPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*UserPatentInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS u").
Select("u.id", "p.title", "p.apply_code", "p.apply_name", "p.apply_at", "p.status", "p.created_at").
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u.patent_id = p.id", model.NewTechnologyPatent().TableName())).
Where("u.is_deleted = ?", model.DeleteStatusForNot)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*UserPatentInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("u.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func NewUserPatent() *UserPatent {
return &UserPatent{model.NewUserPatent()}
}

View File

@ -4,22 +4,20 @@ package model
type TechnologyPatent struct {
Model
ModelTenant
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Kind TechnologyPatentKind `gorm:"column:kind;index:idx_sys_patent_kind;type:tinyint(1);default:0;comment:专利类型" json:"kind"`
Title string `gorm:"column:title;type:varchar(100);default:'';comment:名称标题" json:"title"`
FileUrl string `gorm:"column:file_url;type:varchar(255);default:'';comment:文件地址" json:"file_url"`
ApplyCode string `gorm:"column:apply_code;type:varchar(30);default:'';comment:申请" json:"apply_code"`
ApplyAt string `gorm:"column:apply_at;type:varchar(10);default:'';comment:申请日" json:"apply_at"`
OpenCode string `gorm:"column:open_code;type:varchar(30);default:'';comment:公开(公告)" json:"open_code"`
OpenAt string `gorm:"column:open_at;type:varchar(10);default:'';comment:公开(公告)日" json:"open_at"`
ApplyName string `gorm:"column:apply_name;type:varchar(255);default:'';comment:申请(专利权)人" json:"apply_name"`
ApplyAddress string `gorm:"column:apply_address;type:varchar(255);default:'';comment:申请人地址" json:"apply_address"`
Inventor string `gorm:"column:inventor;type:varchar(255);default:'';comment:发明人" json:"inventor"`
Description string `gorm:"column:description;type:text;comment:摘要" json:"description"`
PrincipalClaim string `gorm:"column:principal_claim;type:text;comment:主权项" json:"principal_claim"`
IPCCode string `gorm:"column:ipc_code;index:idx_sys_patent_ipc_code;type:varchar(30);default:'';comment:IPC主分类号" json:"ipc_code"`
Shelf
Status TechnologyPatentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1授权2实审3公开)" json:"-"`
Kind TechnologyPatentKind `gorm:"column:kind;index:idx_sys_patent_kind;type:tinyint(1);default:0;comment:专利类型" json:"kind"`
Title string `gorm:"column:title;type:varchar(100);default:'';comment:名称标题" json:"title"`
FileUrl string `gorm:"column:file_url;type:varchar(255);default:'';comment:文件地址" json:"file_url"`
ApplyCode string `gorm:"column:apply_code;type:varchar(30);default:'';comment:申请号" json:"apply_code"`
ApplyAt string `gorm:"column:apply_at;type:varchar(10);default:'';comment:申请" json:"apply_at"`
OpenCode string `gorm:"column:open_code;type:varchar(30);default:'';comment:公开(公告)号" json:"open_code"`
OpenAt string `gorm:"column:open_at;type:varchar(10);default:'';comment:公开(公告)" json:"open_at"`
ApplyName string `gorm:"column:apply_name;type:varchar(255);default:'';comment:申请(专利权)人" json:"apply_name"`
ApplyAddress string `gorm:"column:apply_address;type:varchar(255);default:'';comment:申请人地址" json:"apply_address"`
Inventor string `gorm:"column:inventor;type:varchar(255);default:'';comment:发明人" json:"inventor"`
Description string `gorm:"column:description;type:text;comment:摘要" json:"description"`
PrincipalClaim string `gorm:"column:principal_claim;type:text;comment:主权项" json:"principal_claim"`
IPCCode string `gorm:"column:ipc_code;index:idx_sys_patent_ipc_code;type:varchar(30);default:'';comment:IPC主分类号" json:"ipc_code"`
Status TechnologyPatentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1授权2实审3公开)" json:"-"`
ModelDeleted
ModelAt
}

View File

@ -0,0 +1,18 @@
package model
// UserPatent 用户专利信息
type UserPatent struct {
Model
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
PatentID uint64 `gorm:"column:patent_id;type:int(11);default:0;comment:专利ID" json:"patent_id"`
ModelDeleted
ModelAt
}
func (m *UserPatent) TableName() string {
return "user_patent"
}
func NewUserPatent() *UserPatent {
return &UserPatent{}
}

View File

@ -29,6 +29,24 @@ func (this *ESManage) Create() error {
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
}
func (this *ESManage) Update() error {
_map := make(map[string]interface{}, 0)
if this.Title != "" {
_map["title"] = this.Title
}
if this.Industry != "" {
_map["industry"] = this.Industry
}
if this.Keyword != "" {
_map["keyword"] = this.Keyword
}
if this.Research != "" {
_map["research"] = this.Research
}
return es.Update(this.Index(), fmt.Sprintf("%d", this.ID), _map)
}
func (this *ESManage) Search(page, pageSize int, params map[string]interface{}) (interface{}, int64, error) {
termParams := make(map[string]interface{}, 0)
shouldParams := make(map[string]interface{}, 0)

View File

@ -10,7 +10,6 @@ type ESPatent struct {
ID uint64 `json:"id"`
Title string `json:"title"`
Industry string `json:"industry"` // 行业领域
IsShow int `json:"is_show"` // 展示
}
type ESPatentOption func(patent *ESPatent)
@ -33,9 +32,6 @@ func (this *ESPatent) Update() error {
if this.Industry != "" {
_map["industry"] = this.Industry
}
if this.IsShow != 0 {
_map["is_show"] = this.IsShow
}
return es.Update(this.Index(), fmt.Sprintf("%d", this.ID), _map)
}
@ -53,8 +49,6 @@ func (this *ESPatent) Search(page, pageSize int) (interface{}, int64, error) {
if this.Industry != "" {
termParams["industry"] = this.Industry
}
termParams["is_show"] = 1
return es.Search(this, this.Index(), &es.SearchParams{
TermParams: termParams,
MustParams: mustParams,
@ -79,12 +73,6 @@ func WithPatentIndustry(industry string) ESPatentOption {
}
}
func WithPatentShow(show int) ESPatentOption {
return func(patent *ESPatent) {
patent.IsShow = show
}
}
func NewESPatent(options ...ESPatentOption) *ESPatent {
out := new(ESPatent)

View File

@ -360,7 +360,6 @@ func registerAdminAPI(app *gin.Engine) {
technology.POST("/patent/add", _api.PatentForm)
technology.POST("/patent/edit", _api.PatentForm)
technology.POST("/patent/bind", _api.PatentBind)
technology.POST("/patent/shelf", _api.PatentShelf)
technology.POST("/patent/delete", _api.PatentDelete)
technology.GET("/patent/ipc", _api.PatentIPC)
technology.POST("/patent/ipc/add", _api.PatentIPCForm)
@ -469,12 +468,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
_api := new(api3.Home)
homeV1.GET("", _api.Instance)
}
// Sys 配置管理
sysV1 := v1.Group("/sys")
{
_api := new(api3.Sys)
sysV1.POST("/patent", _api.Patent)
}
// Settled 入驻管理
settledV1 := v1.Group("/settled")
{