feat:完善用户专利数据模型
This commit is contained in:
@ -44,19 +44,20 @@ type (
|
|||||||
}
|
}
|
||||||
// patentForm 专利参数
|
// patentForm 专利参数
|
||||||
patentForm struct {
|
patentForm struct {
|
||||||
|
Kind int `json:"kind" form:"kind" binding:"kind"`
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
IPCCode string `json:"ipc_code" form:"ipc_code" binding:"required"`
|
FileUrl string `json:"file_url" form:"file_url"`
|
||||||
CPCCode string `json:"cpc_code" form:"cpc_code" binding:"required"`
|
|
||||||
ApplyCode string `json:"apply_code" form:"apply_code" binding:"required"`
|
ApplyCode string `json:"apply_code" form:"apply_code" binding:"required"`
|
||||||
ApplyName string `json:"apply_name" form:"apply_name" binding:"required"`
|
ApplyName string `json:"apply_name" form:"apply_name" binding:"required"`
|
||||||
ApplyAddress string `json:"apply_address" form:"apply_address" binding:"required"`
|
ApplyAddress string `json:"apply_address" form:"apply_address" binding:"required"`
|
||||||
ApplyZipCode string `json:"apply_zip_code" form:"apply_zip_code" binding:"required"`
|
|
||||||
Inventor string `json:"inventor" form:"inventor" binding:"required"`
|
|
||||||
PriorityCode string `json:"priority_code" form:"priority_code" binding:"required"`
|
|
||||||
OpenCode string `json:"open_code" form:"open_code" binding:"required"`
|
|
||||||
ApplyAt string `json:"apply_at" form:"apply_at" binding:"required"`
|
ApplyAt string `json:"apply_at" form:"apply_at" binding:"required"`
|
||||||
PriorityAt string `json:"priority_at" form:"priority_at" binding:"required"`
|
OpenCode string `json:"open_code" form:"open_code" binding:"required"`
|
||||||
OpenAt string `json:"open_at" form:"open_at" binding:"required"`
|
OpenAt string `json:"open_at" form:"open_at" binding:"required"`
|
||||||
|
IPCCode string `json:"ipc_code" form:"ipc_code"`
|
||||||
|
Inventor string `json:"inventor" form:"inventor"`
|
||||||
|
PrincipalClaim string `json:"principal_claim" form:"principal_claim"`
|
||||||
|
Description string `json:"description" form:"description"`
|
||||||
|
Status int `json:"status" form:"status" binding:"status"`
|
||||||
}
|
}
|
||||||
// demandForm 需求参数
|
// demandForm 需求参数
|
||||||
demandForm struct {
|
demandForm struct {
|
||||||
@ -261,7 +262,11 @@ func (a *Technology) PaperDelete(c *gin.Context) {
|
|||||||
|
|
||||||
func (a *Technology) Patent(c *gin.Context) {
|
func (a *Technology) Patent(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
|
Kind int `json:"kind" form:"kind"`
|
||||||
Title string `json:"title" form:"title"`
|
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
|
api.PageForm
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
@ -269,7 +274,7 @@ func (a *Technology) Patent(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
data, err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
List(form.Title, form.Page, form.PageSize)
|
List(form.Kind, form.Title, form.ApplyCode, form.OpenCode, form.IPCCode, form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,11 +298,10 @@ func (a *Technology) PatentAdd(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
Form(&technology2.PatentParams{
|
Form(&technology2.PatentParams{Kind: form.Kind, Title: form.Title, FileUrl: (&api.FileForm{File: form.FileUrl}).FilterURL(),
|
||||||
Title: form.Title, IPCCode: form.IPCCode, CPCCode: form.CPCCode, ApplyCode: form.ApplyCode,
|
ApplyCode: form.ApplyCode, ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyAt: form.ApplyAt,
|
||||||
ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyZipCode: form.ApplyZipCode,
|
OpenCode: form.OpenCode, OpenAt: form.OpenAt, Inventor: form.Inventor, IPCCode: form.IPCCode,
|
||||||
Inventor: form.Inventor, PriorityCode: form.PriorityCode, OpenCode: form.OpenCode, ApplyAt: form.ApplyAt,
|
Description: form.Description, PrincipalClaim: form.PrincipalClaim,
|
||||||
PriorityAt: form.PriorityAt, OpenAt: form.OpenAt,
|
|
||||||
})
|
})
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
@ -312,11 +316,11 @@ func (a *Technology) PatentEdit(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
err := technology2.NewPatent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
Form(&technology2.PatentParams{
|
Form(&technology2.PatentParams{ID: form.Convert(), Kind: form.Kind, Title: form.Title,
|
||||||
ID: form.Convert(), Title: form.Title, IPCCode: form.IPCCode, CPCCode: form.CPCCode,
|
FileUrl: (&api.FileForm{File: form.FileUrl}).FilterURL(), ApplyCode: form.ApplyCode,
|
||||||
ApplyCode: form.ApplyCode, ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress,
|
ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyAt: form.ApplyAt, OpenCode: form.OpenCode,
|
||||||
ApplyZipCode: form.ApplyZipCode, Inventor: form.Inventor, PriorityCode: form.PriorityCode, OpenCode: form.OpenCode,
|
OpenAt: form.OpenAt, Inventor: form.Inventor, IPCCode: form.IPCCode, Description: form.Description,
|
||||||
ApplyAt: form.ApplyAt, PriorityAt: form.PriorityAt, OpenAt: form.OpenAt,
|
PrincipalClaim: form.PrincipalClaim, Status: form.Status,
|
||||||
})
|
})
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/utils"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
@ -22,6 +23,11 @@ type (
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Kind model2.SysParentKind `json:"kind"`
|
Kind model2.SysParentKind `json:"kind"`
|
||||||
Title string `json:"title"`
|
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"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,7 +42,10 @@ func (c *Patent) filter(src string) string {
|
|||||||
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
|
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
mSysPatent := model.NewSysPatent()
|
mSysPatent := model.NewSysPatent()
|
||||||
|
|
||||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{Order: model2.NewOrder("id", model2.OrderModeToDesc)}}
|
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("shelf", model2.ShelfStatusForUp),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}}
|
||||||
|
|
||||||
if kind <= 0 {
|
if kind <= 0 {
|
||||||
where = append(where, &model2.ModelWhereOrder{
|
where = append(where, &model2.ModelWhereOrder{
|
||||||
@ -67,7 +76,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
|||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
if err := model2.Pages(mSysPatent.SysPatent, &out, page, pageSize, &count); err != nil {
|
if err := model2.PagesFields(mSysPatent.SysPatent, &out, []string{"id", "title", "apply_code", "apply_name", "apply_at", "created_at"}, page, pageSize, &count); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,14 +84,14 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
|||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &PatentInfo{
|
list = append(list, &PatentInfo{
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(), Kind: v.Kind, Title: v.Title,
|
||||||
Kind: v.Kind,
|
ApplyName: v.ApplyName, ApplyCode: v.ApplyCode, ApplyAt: v.ApplyAt,
|
||||||
Title: v.Title,
|
CreatedAt: v.CreatedAt,
|
||||||
})
|
})
|
||||||
v.ApplyName = c.filter(v.ApplyName)
|
//v.ApplyName = c.filter(v.ApplyName)
|
||||||
v.ApplyAddress = c.filter(v.ApplyAddress)
|
//v.ApplyAddress = c.filter(v.ApplyAddress)
|
||||||
v.Inventor = c.filter(v.Inventor)
|
//v.Inventor = c.filter(v.Inventor)
|
||||||
v.Description = c.filter(v.Description)
|
//v.Description = c.filter(v.Description)
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{
|
return &controller.ReturnPages{
|
||||||
Data: out,
|
Data: out,
|
||||||
@ -90,6 +99,10 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Patent) Select() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func NewPatent() PatentHandle {
|
func NewPatent() PatentHandle {
|
||||||
return func(session *session.Enterprise) *Patent {
|
return func(session *session.Enterprise) *Patent {
|
||||||
return &Patent{Enterprise: session}
|
return &Patent{Enterprise: session}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package technology
|
package technology
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"SciencesServer/app/api/enterprise/controller/sys"
|
||||||
"SciencesServer/app/api/enterprise/model"
|
"SciencesServer/app/api/enterprise/model"
|
||||||
"SciencesServer/app/api/manage/controller"
|
"SciencesServer/app/api/manage/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/serve/orm"
|
||||||
"errors"
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,54 +23,160 @@ type PatentHandle func(session *session.Enterprise, local string) *Patent
|
|||||||
type (
|
type (
|
||||||
// PatentInfo 专利信息
|
// PatentInfo 专利信息
|
||||||
PatentInfo struct {
|
PatentInfo struct {
|
||||||
ID string `json:"id"`
|
*sys.PatentInfo
|
||||||
Title string `json:"title"`
|
Shelf model2.ShelfStatusKind
|
||||||
ApplyCode string `json:"apply_code"` // 申请号
|
Status model2.SysParentStatus
|
||||||
ApplyName string `json:"apply_name"` // 申请人
|
|
||||||
ApplyAt time.Time `json:"apply_at"` // 申请时间
|
|
||||||
Inventor string `json:"inventor"` // 发明人
|
|
||||||
}
|
}
|
||||||
// PatentDetailInfo 专利详细信息
|
// PatentDetailInfo 专利详细信息
|
||||||
PatentDetailInfo struct {
|
PatentDetailInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model2.TechnologyPatent
|
*model2.SysPatent
|
||||||
}
|
}
|
||||||
// PatentParams 专利参数信息
|
// PatentParams 专利参数信息
|
||||||
PatentParams struct {
|
PatentParams struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
Title, IPCCode, CPCCode, ApplyCode, ApplyName, ApplyAddress, ApplyZipCode,
|
Kind int
|
||||||
Inventor, PriorityCode, OpenCode, ApplyAt, PriorityAt, OpenAt string
|
Title, FileUrl string
|
||||||
|
ApplyCode, ApplyName, ApplyAddress, ApplyAt,
|
||||||
|
OpenCode, OpenAt string
|
||||||
|
Inventor, IPCCode, Description, PrincipalClaim string
|
||||||
|
Status int
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// List 列表信息
|
// add 新增专利信息
|
||||||
func (c *Patent) List(title string, page, pageSize int) (*controller.ReturnPages, error) {
|
func (c *PatentParams) add(uid uint64, local string) error {
|
||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
mSysPatent := model.NewSysPatent()
|
||||||
|
isExist, err := mSysPatent.IsExistParams(map[string]interface{}{
|
||||||
|
"apply_code": c.ApplyCode, "open_code": c.OpenCode,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if isExist {
|
||||||
|
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
||||||
|
}
|
||||||
|
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
|
mSysPatent.Kind = model2.SysParentKind(c.Kind)
|
||||||
|
mSysPatent.Title = c.Title
|
||||||
|
mSysPatent.FileUrl = c.FileUrl
|
||||||
|
mSysPatent.ApplyCode = c.ApplyCode
|
||||||
|
mSysPatent.ApplyAt = c.ApplyAt
|
||||||
|
mSysPatent.OpenCode = c.OpenCode
|
||||||
|
mSysPatent.OpenAt = c.OpenAt
|
||||||
|
mSysPatent.ApplyName = c.ApplyName
|
||||||
|
mSysPatent.ApplyAddress = c.ApplyAddress
|
||||||
|
mSysPatent.Inventor = c.Inventor
|
||||||
|
mSysPatent.Description = c.Description
|
||||||
|
mSysPatent.PrincipalClaim = c.PrincipalClaim
|
||||||
|
mSysPatent.IPCCode = c.IPCCode
|
||||||
|
mSysPatent.Status = model2.SysParentStatus(c.Status)
|
||||||
|
|
||||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
if err = model2.Create(mSysPatent.SysPatent, tx); err != nil {
|
||||||
Where: model2.NewWhere("uid", c.ManageUID),
|
return err
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
}
|
||||||
}}
|
|
||||||
|
|
||||||
if title != "" {
|
mUserPatent := model.NewUserPatent()
|
||||||
where = append(where, &model2.ModelWhereOrder{
|
mUserPatent.Local.Local = local
|
||||||
Where: model2.NewWhereLike("title", title),
|
mUserPatent.UID = uid
|
||||||
|
mUserPatent.PatentID = mSysPatent.ID
|
||||||
|
|
||||||
|
return model2.Create(mUserPatent.UserPatent, tx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
out := make([]*model2.TechnologyPatent, 0)
|
|
||||||
|
|
||||||
|
// edit 删除专利信息
|
||||||
|
func (c *PatentParams) edit(uid uint64) error {
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
mUserPatent.ID = c.ID
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||||
|
} else if mUserPatent.UID != uid {
|
||||||
|
return errors.New("无权限操作")
|
||||||
|
}
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
mSysPatent.ID = mUserPatent.PatentID
|
||||||
|
|
||||||
|
if isExist, err = model2.FirstField(mSysPatent.SysPatent, []string{"id", "apply_code", "open_code"}); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,专利信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
_condition := make(map[string]interface{}, 0)
|
||||||
|
|
||||||
|
if mSysPatent.ApplyCode != c.ApplyCode {
|
||||||
|
_condition["apply_code"] = c.ApplyCode
|
||||||
|
}
|
||||||
|
if mSysPatent.OpenCode != c.OpenCode {
|
||||||
|
_condition["open_code"] = c.OpenCode
|
||||||
|
|
||||||
|
}
|
||||||
|
if len(_condition) > 0 {
|
||||||
|
if isExist, err = mSysPatent.IsExistParams(_condition); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mSysPatent.Kind = model2.SysParentKind(c.Kind)
|
||||||
|
mSysPatent.Title = c.Title
|
||||||
|
mSysPatent.FileUrl = c.FileUrl
|
||||||
|
mSysPatent.ApplyCode = c.ApplyCode
|
||||||
|
mSysPatent.ApplyAt = c.ApplyAt
|
||||||
|
mSysPatent.OpenCode = c.OpenCode
|
||||||
|
mSysPatent.OpenAt = c.OpenAt
|
||||||
|
mSysPatent.ApplyName = c.ApplyName
|
||||||
|
mSysPatent.ApplyAddress = c.ApplyAddress
|
||||||
|
mSysPatent.Inventor = c.Inventor
|
||||||
|
mSysPatent.Description = c.Description
|
||||||
|
mSysPatent.PrincipalClaim = c.PrincipalClaim
|
||||||
|
mSysPatent.IPCCode = c.IPCCode
|
||||||
|
mSysPatent.Status = model2.SysParentStatus(c.Status)
|
||||||
|
return model2.Updates(mSysPatent.SysPatent, mSysPatent.SysPatent)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List 列表信息
|
||||||
|
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
|
||||||
|
where := []*model2.ModelWhere{
|
||||||
|
model2.NewWhere("u.uid", c.UID),
|
||||||
|
}
|
||||||
|
if kind <= 0 {
|
||||||
|
where = append(where, model2.NewWhere("p.kind", kind))
|
||||||
|
}
|
||||||
|
if title != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("p.title", title))
|
||||||
|
}
|
||||||
|
if applyCode != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("p.apply_code", applyCode))
|
||||||
|
}
|
||||||
|
if openCode != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("p.open_code", openCode))
|
||||||
|
}
|
||||||
|
if ipcCode != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("p.ipc_code", ipcCode))
|
||||||
|
}
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{"id", "title", "apply_code", "inventor",
|
out, err := mUserPatent.Patents(page, pageSize, &count, where...)
|
||||||
"apply_name", "apply_at"}, page, pageSize, &count, where...); err != nil {
|
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list := make([]*PatentInfo, 0)
|
list := make([]*PatentInfo, 0)
|
||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &PatentInfo{
|
list = append(list, &PatentInfo{
|
||||||
|
PatentInfo: &sys.PatentInfo{
|
||||||
ID: v.GetEncodeID(), Title: v.Title, ApplyCode: v.ApplyCode, ApplyName: v.ApplyName,
|
ID: v.GetEncodeID(), Title: v.Title, ApplyCode: v.ApplyCode, ApplyName: v.ApplyName,
|
||||||
ApplyAt: v.ApplyAt, Inventor: v.Inventor,
|
ApplyAt: v.ApplyAt, Inventor: v.Inventor,
|
||||||
|
},
|
||||||
|
Shelf: v.Shelf, Status: v.Status,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
@ -76,75 +184,80 @@ func (c *Patent) List(title string, page, pageSize int) (*controller.ReturnPages
|
|||||||
|
|
||||||
// Detail 详细信息
|
// Detail 详细信息
|
||||||
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
mUserPatent := model.NewUserPatent()
|
||||||
mTechnologyPatent.ID = id
|
mUserPatent.ID = id
|
||||||
|
|
||||||
isExist, err := model2.First(mTechnologyPatent.TechnologyPatent)
|
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return nil, errors.New("操作错误,专利信息不存在")
|
return nil, errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||||
}
|
}
|
||||||
return &PatentDetailInfo{
|
mSysPatent := model.NewSysPatent()
|
||||||
ID: mTechnologyPatent.GetEncodeID(), TechnologyPatent: mTechnologyPatent.TechnologyPatent,
|
mSysPatent.ID = mUserPatent.PatentID
|
||||||
}, nil
|
|
||||||
|
_, err = model2.First(mSysPatent.SysPatent)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &PatentDetailInfo{ID: mUserPatent.GetEncodeID(), SysPatent: mSysPatent.SysPatent}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Patent) Form(params *PatentParams) error {
|
func (c *Patent) Form(params *PatentParams) error {
|
||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
|
||||||
|
|
||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mTechnologyPatent.ID = params.ID
|
return params.edit(c.UID)
|
||||||
|
}
|
||||||
|
return params.add(c.UID, c.local)
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "m_uid"})
|
}
|
||||||
|
|
||||||
|
// Shelf 上下架操作
|
||||||
|
func (c *Patent) Shelf(id uint64, status int) error {
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
mUserPatent.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("操作错误,专利信息不存在")
|
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||||
} else if mTechnologyPatent.MUid != c.ManageUID {
|
} else if mUserPatent.UID != c.UID {
|
||||||
return errors.New("无权限操作")
|
return errors.New("无权限操作")
|
||||||
}
|
}
|
||||||
}
|
mSysPatent := model.NewSysPatent()
|
||||||
mTechnologyPatent.Title = params.Title
|
mSysPatent.ID = mUserPatent.PatentID
|
||||||
mTechnologyPatent.IPCCode = params.IPCCode
|
|
||||||
mTechnologyPatent.CPCCode = params.CPCCode
|
|
||||||
mTechnologyPatent.ApplyCode = params.ApplyCode
|
|
||||||
mTechnologyPatent.ApplyName = params.ApplyName
|
|
||||||
mTechnologyPatent.ApplyZipCode = params.ApplyZipCode
|
|
||||||
mTechnologyPatent.ApplyAt = utils.DataTimeToDate(params.ApplyAt)
|
|
||||||
mTechnologyPatent.Inventor = params.Inventor
|
|
||||||
mTechnologyPatent.PriorityCode = params.PriorityCode
|
|
||||||
mTechnologyPatent.PriorityAt = utils.DataTimeToDate(params.PriorityAt)
|
|
||||||
mTechnologyPatent.OpenCode = params.OpenCode
|
|
||||||
mTechnologyPatent.OpenAt = utils.DataTimeToDate(params.OpenAt)
|
|
||||||
|
|
||||||
if mTechnologyPatent.ID > 0 {
|
return model2.Updates(mSysPatent.SysPatent, map[string]interface{}{
|
||||||
mTechnologyPatent.UpdatedAt = time.Now()
|
"shelf": status, "updated_at": time.Now(),
|
||||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent)
|
})
|
||||||
}
|
|
||||||
mTechnologyPatent.TenantID = c.TenantID
|
|
||||||
mTechnologyPatent.Local.Local = c.local
|
|
||||||
mTechnologyPatent.MUid = c.ManageUID
|
|
||||||
return model2.Create(mTechnologyPatent.TechnologyPatent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
func (c *Patent) Delete(id uint64) error {
|
func (c *Patent) Delete(id uint64) error {
|
||||||
mTechnologyPatent := model.NewTechnologyPatent()
|
mUserPatent := model.NewUserPatent()
|
||||||
mTechnologyPatent.ID = id
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("操作错误,专利信息不存在")
|
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||||
} else if mTechnologyPatent.MUid != c.ManageUID {
|
} else if mUserPatent.UID != c.UID {
|
||||||
return errors.New("无权限操作")
|
return errors.New("无权限操作")
|
||||||
}
|
}
|
||||||
return model2.Delete(mTechnologyPatent.TechnologyPatent)
|
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err = model2.Delete(mUserPatent.UserPatent); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
mSysPatent.ID = mUserPatent.PatentID
|
||||||
|
|
||||||
|
return model2.Delete(mSysPatent.SysPatent)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPatent() PatentHandle {
|
func NewPatent() PatentHandle {
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"SciencesServer/app/api/enterprise/model"
|
|
||||||
"SciencesServer/app/basic/controller"
|
|
||||||
model2 "SciencesServer/app/common/model"
|
|
||||||
"SciencesServer/app/session"
|
|
||||||
"SciencesServer/serve/orm"
|
|
||||||
"errors"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Patent struct {
|
|
||||||
*session.Enterprise
|
|
||||||
local string
|
|
||||||
}
|
|
||||||
|
|
||||||
type PatentHandle func(session *session.Enterprise, local string) *Patent
|
|
||||||
|
|
||||||
type (
|
|
||||||
// PatentParams 专利参数信息
|
|
||||||
PatentParams struct {
|
|
||||||
ID uint64
|
|
||||||
Title string
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *PatentParams) add() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *PatentParams) edit() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
|
|
||||||
return &controller.ReturnPages{
|
|
||||||
Data: nil,
|
|
||||||
Count: 0,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Patent) Form(params *PatentParams) error {
|
|
||||||
if params.ID <= 0 {
|
|
||||||
return params.add()
|
|
||||||
}
|
|
||||||
return params.edit()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shelf 上下架操作
|
|
||||||
func (c *Patent) Shelf(id uint64, status int) error {
|
|
||||||
mUserPatent := model.NewUserPatent()
|
|
||||||
mUserPatent.ID = id
|
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
} else if !isExist {
|
|
||||||
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
|
||||||
} else if mUserPatent.UID != c.UID {
|
|
||||||
return errors.New("无权限操作")
|
|
||||||
}
|
|
||||||
mSysPatent := model.NewSysPatent()
|
|
||||||
mSysPatent.ID = mUserPatent.PatentID
|
|
||||||
|
|
||||||
return model2.Updates(mSysPatent.SysPatent, map[string]interface{}{
|
|
||||||
"shelf": status, "updated_at": time.Now(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete 删除操作
|
|
||||||
func (c *Patent) Delete(id uint64) error {
|
|
||||||
mUserPatent := model.NewUserPatent()
|
|
||||||
mUserPatent.ID = id
|
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
} else if !isExist {
|
|
||||||
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
|
||||||
} else if mUserPatent.UID != c.UID {
|
|
||||||
return errors.New("无权限操作")
|
|
||||||
}
|
|
||||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
|
||||||
if err = model2.Delete(mUserPatent.UserPatent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
mSysPatent := model.NewSysPatent()
|
|
||||||
mSysPatent.ID = mUserPatent.PatentID
|
|
||||||
|
|
||||||
return model2.Delete(mSysPatent.SysPatent)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPatent() PatentHandle {
|
|
||||||
return func(session *session.Enterprise, local string) *Patent {
|
|
||||||
return &Patent{
|
|
||||||
Enterprise: session,
|
|
||||||
local: local,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,29 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
// SysPatent 专利信息
|
// SysPatent 专利信息
|
||||||
type SysPatent struct {
|
type SysPatent struct {
|
||||||
*model.SysPatent
|
*model.SysPatent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||||
|
var count int64
|
||||||
|
db := orm.GetDB().Table(m.TableName())
|
||||||
|
|
||||||
|
if len(params) > 0 {
|
||||||
|
for k, v := range params {
|
||||||
|
db = db.Or(fmt.Sprintf("%s = %v AND is_deleted = %d", k, v, model.DeleteStatusForNot))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err := db.Count(&count).Error
|
||||||
|
return count > 0, err
|
||||||
|
}
|
||||||
|
|
||||||
func NewSysPatent() *SysPatent {
|
func NewSysPatent() *SysPatent {
|
||||||
return &SysPatent{model.NewSysPatent()}
|
return &SysPatent{model.NewSysPatent()}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
|
||||||
|
|
||||||
type TechnologyPatent struct {
|
|
||||||
*model.TechnologyPatent
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyPatent() *TechnologyPatent {
|
|
||||||
return &TechnologyPatent{TechnologyPatent: model.NewTechnologyPatent()}
|
|
||||||
}
|
|
@ -1,11 +1,38 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
type UserPatent struct {
|
type UserPatent struct {
|
||||||
*model.UserPatent
|
*model.UserPatent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Patents 专利信息
|
||||||
|
func (m *UserPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*model.SysPatent, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS u").
|
||||||
|
Select("u.id", "p.title", "p.apply_code", "p.apply_name", "p.apply_at", "shelf", "status", "u.created_at").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u.patent_id = p.id", model.NewSysPatent().TableName())).
|
||||||
|
Where("u.is_deleted = ? AND p.is_deleted = ?", model.DeleteStatusForNot, model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, wo := range where {
|
||||||
|
db = db.Where(wo.Condition, wo.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*model.SysPatent, 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 {
|
func NewUserPatent() *UserPatent {
|
||||||
return &UserPatent{model.NewUserPatent()}
|
return &UserPatent{model.NewUserPatent()}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,14 @@ func (this *ImageForm) FilterImageURL() string {
|
|||||||
return strings.Replace(this.Image, config.SettingInfo.Domain, "", -1)
|
return strings.Replace(this.Image, config.SettingInfo.Domain, "", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FileForm struct {
|
||||||
|
File string `json:"file" form:"file"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *FileForm) FilterURL() string {
|
||||||
|
return strings.Replace(this.File, config.SettingInfo.Domain, "", -1)
|
||||||
|
}
|
||||||
|
|
||||||
type PositionForm struct {
|
type PositionForm struct {
|
||||||
Longitude float64 `json:"longitude" form:"longitude" binding:"required"`
|
Longitude float64 `json:"longitude" form:"longitude" binding:"required"`
|
||||||
Latitude float64 `json:"latitude" form:"latitude" binding:"required"`
|
Latitude float64 `json:"latitude" form:"latitude" binding:"required"`
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// TechnologyPatent 技术专利
|
|
||||||
type TechnologyPatent struct {
|
|
||||||
Model
|
|
||||||
ModelTenant
|
|
||||||
Local
|
|
||||||
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
|
|
||||||
Title string `gorm:"column:title;type:varchar(50);default:null;comment:专利名称" json:"title"`
|
|
||||||
IPCCode string `gorm:"column:ipc_code;type:varchar(30);default:null;comment:IPC分类号" json:"ipc_code"`
|
|
||||||
CPCCode string `gorm:"column:cpc_code;type:varchar(30);default:null;comment:CPC分类号" json:"cpc_code"`
|
|
||||||
ApplyCode string `gorm:"column:apply_code;type:varchar(30);default:null;comment:专利申请号" json:"apply_code"`
|
|
||||||
ApplyName string `gorm:"column:apply_name;type:varchar(15);default:null;comment:专利申请人" json:"apply_name"`
|
|
||||||
ApplyAddress string `gorm:"column:apply_address;type:varchar(100);default:null;comment:专利申请人地址" json:"apply_address"`
|
|
||||||
ApplyZipCode string `gorm:"column:apply_zip_code;type:varchar(10);default:null;comment:专利申请人邮编" json:"apply_zip_code"`
|
|
||||||
ApplyAt time.Time `gorm:"column:apply_at;type:date;not null;comment:专利申请人时间" json:"apply_at"`
|
|
||||||
Inventor string `gorm:"column:inventor;type:varchar(15);default:null;comment:发明人" json:"inventor"`
|
|
||||||
PriorityCode string `gorm:"column:priority_code;type:varchar(30);default:null;comment:优先权号" json:"priority_code"`
|
|
||||||
PriorityAt time.Time `gorm:"column:priority_at;type:date;not null;comment:优先权日" json:"priority_at"`
|
|
||||||
OpenCode string `gorm:"column:open_code;type:varchar(100);default:null;comment:公开(公告)号" json:"open_code"`
|
|
||||||
OpenAt time.Time `gorm:"column:open_at;type:date;not null;comment:公开(公告)日" json:"open_at"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *TechnologyPatent) TableName() string {
|
|
||||||
return m.NewTableName("technology_patent")
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyPatent() *TechnologyPatent {
|
|
||||||
return &TechnologyPatent{}
|
|
||||||
}
|
|
Reference in New Issue
Block a user