feat:优化项目信息,待测试修改
This commit is contained in:
@ -6,11 +6,10 @@ import (
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Patent 专利信息
|
||||
@ -30,7 +29,7 @@ type (
|
||||
// PatentDetailInfo 专利详细信息
|
||||
PatentDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.SysPatent
|
||||
*model2.TechnologyPatent
|
||||
}
|
||||
// PatentParams 专利参数信息
|
||||
PatentParams struct {
|
||||
@ -57,7 +56,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Patent) ipcTree(src []*model2.SysPatentClassify, parentID uint64) []*PatentIPCInfo {
|
||||
func (c *Patent) ipcTree(src []*model2.TechnologyPatentClassify, parentID uint64) []*PatentIPCInfo {
|
||||
out := make([]*PatentIPCInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
@ -79,7 +78,7 @@ func (c *Patent) ipcTree(src []*model2.SysPatentClassify, parentID uint64) []*Pa
|
||||
return out
|
||||
}
|
||||
|
||||
func (c *PatentParams) checkParams(iModel *model.SysPatent, condition map[string]interface{}) error {
|
||||
func (c *PatentParams) checkParams(iModel *model.TechnologyPatent, condition map[string]interface{}) error {
|
||||
isExist, err := iModel.IsExistParams(condition)
|
||||
|
||||
if err != nil {
|
||||
@ -92,10 +91,17 @@ func (c *PatentParams) checkParams(iModel *model.SysPatent, condition map[string
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Patent) Instance(tenantID uint64, title, ipc string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent := model.NewTechnologyPatent()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("p.tenant_id", c.TenantID))
|
||||
}
|
||||
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("p.tenant_id", tenantID))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("p.title", title))
|
||||
}
|
||||
@ -123,140 +129,152 @@ func (c *Patent) Instance(tenantID uint64, title, ipc string, page, pageSize int
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.First(mSysPatent.SysPatent)
|
||||
isExist, err := model2.First(mTechnologyPatent.TechnologyPatent)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,专利信息不存在或已被删除")
|
||||
}
|
||||
return &PatentDetailInfo{ID: mSysPatent.GetEncodeID(), SysPatent: mSysPatent.SysPatent}, nil
|
||||
return &PatentDetailInfo{ID: mTechnologyPatent.GetEncodeID(),
|
||||
TechnologyPatent: mTechnologyPatent.TechnologyPatent}, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Patent) Form(params *PatentParams) error {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
_condition := make(map[string]interface{}, 0)
|
||||
|
||||
if params.ID > 0 {
|
||||
mSysPatent.ID = params.ID
|
||||
mTechnologyPatent.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mSysPatent.SysPatent, []string{"id", "tenant_id", "apply_code", "ipc_code", "created_at"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "tenant_id", "uid", "apply_code", "ipc_code", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,专利信息不存在或已被删除")
|
||||
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if mSysPatent.ApplyCode != params.ApplyCode {
|
||||
if mTechnologyPatent.ApplyCode != params.ApplyCode {
|
||||
_condition["apply_code"] = params.ApplyCode
|
||||
}
|
||||
if mSysPatent.IPCCode != params.IPCCode {
|
||||
if mTechnologyPatent.IPCCode != params.IPCCode {
|
||||
_condition["ipc_code"] = params.IPCCode
|
||||
}
|
||||
if len(_condition) > 0 {
|
||||
if isExist, err = mSysPatent.IsExistParams(_condition); err != nil {
|
||||
if isExist, err = mTechnologyPatent.IsExistParams(_condition); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
||||
}
|
||||
}
|
||||
}
|
||||
mSysPatent.Kind = model2.SysParentKind(params.Kind)
|
||||
mSysPatent.Title = params.Title
|
||||
mSysPatent.FileUrl = params.FileUrl
|
||||
mSysPatent.ApplyCode = params.ApplyCode
|
||||
mSysPatent.ApplyAt = params.ApplyAt
|
||||
mSysPatent.OpenCode = params.OpenCode
|
||||
mSysPatent.OpenAt = params.OpenAt
|
||||
mSysPatent.ApplyName = params.ApplyName
|
||||
mSysPatent.ApplyAddress = params.ApplyAddress
|
||||
mSysPatent.Inventor = params.Inventor
|
||||
mSysPatent.Description = params.Description
|
||||
mSysPatent.PrincipalClaim = params.PrincipalClaim
|
||||
mSysPatent.IPCCode = params.IPCCode
|
||||
mSysPatent.ShelfStatus = model2.ShelfStatusKind(params.ShelfStatus)
|
||||
mSysPatent.Status = model2.SysParentStatus(params.Status)
|
||||
mTechnologyPatent.Kind = model2.SysParentKind(params.Kind)
|
||||
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
|
||||
mTechnologyPatent.ShelfStatus = model2.ShelfStatusKind(params.ShelfStatus)
|
||||
mTechnologyPatent.Status = model2.SysParentStatus(params.Status)
|
||||
|
||||
if mSysPatent.ID > 0 {
|
||||
return model2.Updates(mSysPatent.SysPatent, mSysPatent.SysPatent)
|
||||
if mTechnologyPatent.ID > 0 {
|
||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent)
|
||||
}
|
||||
_condition["apply_code"] = params.ApplyCode
|
||||
_condition["ipc_code"] = params.IPCCode
|
||||
|
||||
if isExist, err := mSysPatent.IsExistParams(_condition); err != nil {
|
||||
if isExist, err := mTechnologyPatent.IsExistParams(_condition); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
||||
}
|
||||
return model2.Create(mSysPatent.SysPatent)
|
||||
mTechnologyPatent.TenantID = c.TenantID
|
||||
return model2.Create(mTechnologyPatent.TechnologyPatent)
|
||||
}
|
||||
|
||||
// Bind 绑定信息
|
||||
func (c *Patent) Bind(id, uid uint64) error {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mSysPatent.SysPatent, []string{"id", "tenant_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,专利信息不存在或已被删除")
|
||||
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mUserPatent := model.NewUserPatent()
|
||||
|
||||
if isExist, err = model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid"}, model2.NewWhere("patent_id", id)); err != nil {
|
||||
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
|
||||
"uid": uid, "updated_at": time.Now(),
|
||||
}); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
mUserPatent.UID = uid
|
||||
mUserPatent.PatentID = id
|
||||
return model2.Create(mUserPatent.UserPatent)
|
||||
}
|
||||
if mUserPatent.UID == uid {
|
||||
return nil
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.DeleteWhere(mUserPatent.UserPatent, []*model2.ModelWhere{model2.NewWhere("patent_id", id)}); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserPatent.UID = uid
|
||||
mUserPatent.PatentID = id
|
||||
return model2.Create(mUserPatent.UserPatent, tx)
|
||||
})
|
||||
return nil
|
||||
//mUserPatent := model.NewUserPatent()
|
||||
|
||||
//if isExist, err = model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid"}, model2.NewWhere("patent_id", id)); err != nil {
|
||||
// return err
|
||||
//} else if !isExist {
|
||||
// mUserPatent.UID = uid
|
||||
// mUserPatent.PatentID = id
|
||||
// return model2.Create(mUserPatent.UserPatent)
|
||||
//}
|
||||
//if mUserPatent.UID == uid {
|
||||
// return nil
|
||||
//}
|
||||
//return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// if err = model2.DeleteWhere(mUserPatent.UserPatent, []*model2.ModelWhere{model2.NewWhere("patent_id", id)}); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// mUserPatent.UID = uid
|
||||
// mUserPatent.PatentID = id
|
||||
// return model2.Create(mUserPatent.UserPatent, tx)
|
||||
//})
|
||||
}
|
||||
|
||||
func (c *Patent) Shelf(id uint64) error {
|
||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewSysPatent(), id)
|
||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyPatent(), id)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Patent) Delete(id uint64) error {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mSysPatent.SysPatent, []string{"id", "tenant_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,专利信息不存在或已被删除")
|
||||
} else if c.TenantID > 0 && mSysPatent.TenantID != c.TenantID {
|
||||
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mSysPatent.SysPatent)
|
||||
return model2.Delete(mTechnologyPatent.TechnologyPatent)
|
||||
}
|
||||
|
||||
// IPC IPC信息
|
||||
func (c *Patent) IPC() ([]*PatentIPCInfo, error) {
|
||||
mSysPatentClassify := model.NewSysPatentClassify()
|
||||
out := make([]*model2.SysPatentClassify, 0)
|
||||
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
||||
out := make([]*model2.TechnologyPatentClassify, 0)
|
||||
|
||||
if err := model2.Scan(mSysPatentClassify.SysPatentClassify, &out); err != nil {
|
||||
if err := model2.Scan(mTechnologyPatentClassify.TechnologyPatentClassify, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.ipcTree(out, 0), nil
|
||||
@ -264,12 +282,12 @@ func (c *Patent) IPC() ([]*PatentIPCInfo, error) {
|
||||
|
||||
// IPCForm IPC数据操作
|
||||
func (c *Patent) IPCForm(params *PatentIPCParams) error {
|
||||
mSysPatentClassify := model.NewSysPatentClassify()
|
||||
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
||||
|
||||
if params.ID > 0 {
|
||||
mSysPatentClassify.ID = params.ID
|
||||
mTechnologyPatentClassify.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mSysPatentClassify.SysPatentClassify, []string{"id", "created_at"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -277,20 +295,20 @@ func (c *Patent) IPCForm(params *PatentIPCParams) error {
|
||||
return errors.New("操作错误,IPC信息不存在或已被删除")
|
||||
}
|
||||
}
|
||||
mSysPatentClassify.SetIndustryDetailAttribute(params.Industrys)
|
||||
mTechnologyPatentClassify.SetIndustryDetailAttribute(params.Industrys)
|
||||
// 查询上级元素
|
||||
if params.ParentID > 0 {
|
||||
mPSysPatentClassify := model.NewSysPatentClassify()
|
||||
mPSysPatentClassify.ID = params.ParentID
|
||||
mPTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
||||
mPTechnologyPatentClassify.ID = params.ParentID
|
||||
|
||||
isExist, err := model2.FirstField(mPSysPatentClassify.SysPatentClassify, []string{"id", "industry"})
|
||||
isExist, err := model2.FirstField(mPTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "industry"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,IPC父级信息不存在或已被删除")
|
||||
}
|
||||
_identitys := mPSysPatentClassify.GetIndustryDetailAttribute()
|
||||
_identitys := mPTechnologyPatentClassify.GetIndustryDetailAttribute()
|
||||
|
||||
for _, v := range params.Industrys {
|
||||
if utils.InArray(v, _identitys) {
|
||||
@ -298,32 +316,31 @@ func (c *Patent) IPCForm(params *PatentIPCParams) error {
|
||||
}
|
||||
_identitys = append(_identitys, v)
|
||||
}
|
||||
mSysPatentClassify.SetIndustryDetailAttribute(_identitys)
|
||||
mTechnologyPatentClassify.SetIndustryDetailAttribute(_identitys)
|
||||
}
|
||||
mSysPatentClassify.ParentID = params.ParentID
|
||||
mSysPatentClassify.IPC = params.IPC
|
||||
mSysPatentClassify.SetIndustryAttribute(params.Industrys)
|
||||
mTechnologyPatentClassify.ParentID = params.ParentID
|
||||
mTechnologyPatentClassify.IPC = params.IPC
|
||||
mTechnologyPatentClassify.SetIndustryAttribute(params.Industrys)
|
||||
|
||||
if mSysPatentClassify.ID > 0 {
|
||||
return model2.Updates(mSysPatentClassify.SysPatentClassify, mSysPatentClassify.SysPatentClassify)
|
||||
if mTechnologyPatentClassify.ID > 0 {
|
||||
return model2.Updates(mTechnologyPatentClassify.TechnologyPatentClassify, mTechnologyPatentClassify.TechnologyPatentClassify)
|
||||
}
|
||||
|
||||
return model2.Create(mSysPatentClassify.SysPatentClassify)
|
||||
return model2.Create(mTechnologyPatentClassify.TechnologyPatentClassify)
|
||||
}
|
||||
|
||||
// IPCDelete IPC删除操作
|
||||
func (c *Patent) IPCDelete(id uint64) error {
|
||||
mSysPatentClassify := model.NewSysPatentClassify()
|
||||
mSysPatentClassify.ID = id
|
||||
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
||||
mTechnologyPatentClassify.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mSysPatentClassify.SysPatentClassify, []string{"id", "created_at"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,IPC信息不存在或已被删除")
|
||||
}
|
||||
return model2.Delete(mSysPatentClassify.SysPatentClassify)
|
||||
return model2.Delete(mTechnologyPatentClassify.TechnologyPatentClassify)
|
||||
}
|
||||
|
||||
func NewPatent() PatentHandle {
|
||||
|
@ -53,13 +53,13 @@ func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS r ON e.research_id = r.id", model.NewManageResearch().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS l ON e.laboratory_id = l.id", model.NewManageLaboratory().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON e.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT u.expert_id, SUM(t_a.count) AS achievement_count, SUM(u_p.count) AS patent_count FROM %s AS u "+
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT u.expert_id, SUM(t_a.count) AS achievement_count, SUM(p.count) AS patent_count FROM %s AS u "+
|
||||
"LEFT JOIN (SELECT uid, COUNT(id) AS count FROM %s WHERE is_deleted = %d AND status = %d GROUP BY uid) AS t_a ON u.uid = t_a.uid "+
|
||||
"LEFT JOIN (SELECT uid, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY uid) AS u_p ON u.uid = u_p.uid "+
|
||||
" WHERE u.is_deleted = %d AND u.invalid_status = %d GROUP BY u.expert_id) AS u ON e.id = u.expert_id",
|
||||
"LEFT JOIN (SELECT uid, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY uid) AS p ON u.uid = p.uid "+
|
||||
"WHERE u.is_deleted = %d AND u.invalid_status = %d GROUP BY u.expert_id) AS u ON e.id = u.expert_id",
|
||||
model.NewUserExpert().TableName(),
|
||||
model.NewTechnologyAchievement().TableName(), model.DeleteStatusForNot, model.TechnologyStatusKindForAgree,
|
||||
model.NewUserPatent().TableName(), model.DeleteStatusForNot,
|
||||
model.NewTechnologyPatent().TableName(), model.DeleteStatusForNot,
|
||||
model.DeleteStatusForNot, model.InvalidStatusForNot)).
|
||||
Where("e.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SysPatent 专利信息
|
||||
type SysPatent struct {
|
||||
*model.SysPatent
|
||||
// TechnologyPatent 专利信息
|
||||
type TechnologyPatent struct {
|
||||
*model.TechnologyPatent
|
||||
}
|
||||
|
||||
// SysPatentInfo 专利信息
|
||||
@ -26,7 +26,7 @@ type SysPatentInfo struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
var count int64
|
||||
db := orm.GetDB().Table(m.TableName())
|
||||
|
||||
@ -40,12 +40,10 @@ func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
}
|
||||
|
||||
// Patent 专利信息
|
||||
func (m *SysPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||
func (m *TechnologyPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "p.title", "p.apply_code", "p.inventor", "p.apply_name", "p.apply_at", "u.uid",
|
||||
"p.shelf_status", "p.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON p.id = u.patent_id AND u.is_deleted = %d",
|
||||
model.NewUserPatent().TableName(), model.DeleteStatusForNot))
|
||||
"p.shelf_status", "p.created_at")
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
@ -63,6 +61,6 @@ func (m *SysPatent) Patent(page, pageSize int, count *int64, where ...*model.Mod
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewSysPatent() *SysPatent {
|
||||
return &SysPatent{model.NewSysPatent()}
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{model.NewTechnologyPatent()}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserPatent struct {
|
||||
*model.UserPatent
|
||||
}
|
||||
|
||||
func NewUserPatent() *UserPatent {
|
||||
return &UserPatent{model.NewUserPatent()}
|
||||
}
|
@ -23,12 +23,12 @@ type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.PatentInstance
|
||||
*model.TechnologyPatentBasicInfo
|
||||
}
|
||||
// PatentInstance 专利信息
|
||||
PatentInstance struct {
|
||||
ID string `json:"id"`
|
||||
*model.SysPatentInfo
|
||||
*model.TechnologyPatentInfo
|
||||
}
|
||||
// PaperInstance 论文信息
|
||||
PaperInstance struct {
|
||||
@ -113,23 +113,30 @@ func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
|
||||
|
||||
// patent 专利信息
|
||||
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
var count int64
|
||||
out := make([]*model.TechnologyPatentBasicInfo, 0)
|
||||
|
||||
out, err := mUserPatent.Instance(page, pageSize, &count, model2.NewWhereIn("u_p.uid", uids))
|
||||
|
||||
if err != nil {
|
||||
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{
|
||||
"id", "title", "apply_at", "description",
|
||||
}, page, pageSize, &count, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", uids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*PatentInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &PatentInfo{
|
||||
ID: v.GetEncodeID(), PatentInstance: v,
|
||||
ID: v.GetEncodeID(), TechnologyPatentBasicInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func paper(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyPaper := model.NewTechnologyPaper()
|
||||
|
||||
@ -204,17 +211,17 @@ func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
|
||||
Paper: make([]*PaperInstance, 0),
|
||||
}
|
||||
// 专利信息
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
patents := make([]*model.SysPatentInfo, 0)
|
||||
patents := make([]*model.TechnologyPatentInfo, 0)
|
||||
|
||||
if patents, err = mSysPatent.Instance(model2.NewWhereIn("p.id", mManageCooperateEnterprise.GetPatentAttribute())); err != nil {
|
||||
if patents, err = mTechnologyPatent.Instance(model2.NewWhereIn("p.id", mManageCooperateEnterprise.GetPatentAttribute())); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range patents {
|
||||
out.Patent = append(out.Patent, &PatentInstance{
|
||||
ID: v.GetEncodeID(),
|
||||
SysPatentInfo: v,
|
||||
ID: v.GetEncodeID(),
|
||||
TechnologyPatentInfo: v,
|
||||
})
|
||||
}
|
||||
// 论文信息
|
||||
|
@ -40,7 +40,7 @@ func (c *Patent) filter(src string) string {
|
||||
}
|
||||
|
||||
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
@ -76,7 +76,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
||||
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mSysPatent.SysPatent, &out, []string{"id", "title", "apply_code", "apply_name", "apply_at", "created_at"}, page, pageSize, &count); err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ type (
|
||||
// PatentDetailInfo 专利详细信息
|
||||
PatentDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.SysPatent
|
||||
*model2.TechnologyPatent
|
||||
}
|
||||
// PatentParams 专利参数信息
|
||||
PatentParams struct {
|
||||
@ -56,8 +56,9 @@ type (
|
||||
|
||||
// add 新增专利信息
|
||||
func (c *PatentParams) add(tenantID, uid uint64) error {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
isExist, err := mSysPatent.IsExistParams(map[string]interface{}{
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
isExist, err := mTechnologyPatent.IsExistParams(map[string]interface{}{
|
||||
"apply_code": c.ApplyCode, "open_code": c.OpenCode,
|
||||
})
|
||||
if err != nil {
|
||||
@ -66,114 +67,117 @@ func (c *PatentParams) add(tenantID, uid uint64) error {
|
||||
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mSysPatent.Kind = model2.SysParentKind(c.Kind)
|
||||
mSysPatent.TenantID = tenantID
|
||||
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)
|
||||
mTechnologyPatent.Kind = model2.SysParentKind(c.Kind)
|
||||
mTechnologyPatent.TenantID = tenantID
|
||||
mTechnologyPatent.UID = uid
|
||||
mTechnologyPatent.Title = c.Title
|
||||
mTechnologyPatent.FileUrl = c.FileUrl
|
||||
mTechnologyPatent.ApplyCode = c.ApplyCode
|
||||
mTechnologyPatent.ApplyAt = c.ApplyAt
|
||||
mTechnologyPatent.OpenCode = c.OpenCode
|
||||
mTechnologyPatent.OpenAt = c.OpenAt
|
||||
mTechnologyPatent.ApplyName = c.ApplyName
|
||||
mTechnologyPatent.ApplyAddress = c.ApplyAddress
|
||||
mTechnologyPatent.Inventor = c.Inventor
|
||||
mTechnologyPatent.Description = c.Description
|
||||
mTechnologyPatent.PrincipalClaim = c.PrincipalClaim
|
||||
mTechnologyPatent.IPCCode = c.IPCCode
|
||||
mTechnologyPatent.Status = model2.SysParentStatus(c.Status)
|
||||
|
||||
if err = model2.Create(mSysPatent.SysPatent, tx); err != nil {
|
||||
if err = model2.Create(mTechnologyPatent.TechnologyPatent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mUserPatent.UID = uid
|
||||
mUserPatent.PatentID = mSysPatent.ID
|
||||
|
||||
return model2.Create(mUserPatent.UserPatent, tx)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// edit 删除专利信息
|
||||
func (c *PatentParams) edit(uid uint64) error {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mUserPatent.ID = c.ID
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = c.ID
|
||||
|
||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid", "apply_code", "open_code"})
|
||||
|
||||
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("操作错误,专利信息不存在或已被删除")
|
||||
} else if mTechnologyPatent.UID != uid {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
_condition := make(map[string]interface{}, 0)
|
||||
|
||||
if mSysPatent.ApplyCode != c.ApplyCode {
|
||||
if mTechnologyPatent.ApplyCode != c.ApplyCode {
|
||||
_condition["apply_code"] = c.ApplyCode
|
||||
}
|
||||
if mSysPatent.OpenCode != c.OpenCode {
|
||||
if mTechnologyPatent.OpenCode != c.OpenCode {
|
||||
_condition["open_code"] = c.OpenCode
|
||||
|
||||
}
|
||||
if len(_condition) > 0 {
|
||||
if isExist, err = mSysPatent.IsExistParams(_condition); err != nil {
|
||||
if isExist, err = mTechnologyPatent.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)
|
||||
mTechnologyPatent.Kind = model2.SysParentKind(c.Kind)
|
||||
mTechnologyPatent.Title = c.Title
|
||||
mTechnologyPatent.FileUrl = c.FileUrl
|
||||
mTechnologyPatent.ApplyCode = c.ApplyCode
|
||||
mTechnologyPatent.ApplyAt = c.ApplyAt
|
||||
mTechnologyPatent.OpenCode = c.OpenCode
|
||||
mTechnologyPatent.OpenAt = c.OpenAt
|
||||
mTechnologyPatent.ApplyName = c.ApplyName
|
||||
mTechnologyPatent.ApplyAddress = c.ApplyAddress
|
||||
mTechnologyPatent.Inventor = c.Inventor
|
||||
mTechnologyPatent.Description = c.Description
|
||||
mTechnologyPatent.PrincipalClaim = c.PrincipalClaim
|
||||
mTechnologyPatent.IPCCode = c.IPCCode
|
||||
mTechnologyPatent.Status = model2.SysParentStatus(c.Status)
|
||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent)
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
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.NewWhere("p.kind", kind))
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("kind", kind),
|
||||
})
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("p.title", title))
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
})
|
||||
}
|
||||
if applyCode != "" {
|
||||
where = append(where, model2.NewWhereLike("p.apply_code", applyCode))
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("apply_code", applyCode),
|
||||
})
|
||||
}
|
||||
if openCode != "" {
|
||||
where = append(where, model2.NewWhereLike("p.open_code", openCode))
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("open_code", openCode),
|
||||
})
|
||||
}
|
||||
if ipcCode != "" {
|
||||
where = append(where, model2.NewWhereLike("p.ipc_code", ipcCode))
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("ipc_code", ipcCode),
|
||||
})
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mUserPatent.Patents(page, pageSize, &count, where...)
|
||||
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...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -212,11 +216,11 @@ func (c *Patent) Match(title string, industrys, keywords []string) (*controller.
|
||||
val := v.(*service.ESAchievement)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
patents := make([]*model2.SysPatent, 0)
|
||||
|
||||
if err = model2.ScanFields(mSysPatent.SysPatent, &patents, []string{"id", "kind", "title", "description", "apply_at"}, &model2.ModelWhereOrder{
|
||||
if err = model2.ScanFields(mTechnologyPatent.TechnologyPatent, &patents, []string{"id", "kind", "title", "description", "apply_at"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}); err != nil {
|
||||
@ -234,25 +238,17 @@ func (c *Patent) Match(title string, industrys, keywords []string) (*controller.
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mUserPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||
isExist, err := model2.First(mTechnologyPatent.TechnologyPatent)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||
return nil, errors.New("操作错误,专利信息不存在或已被删除")
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = mUserPatent.PatentID
|
||||
|
||||
_, err = model2.First(mSysPatent.SysPatent)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PatentDetailInfo{ID: mUserPatent.GetEncodeID(), SysPatent: mSysPatent.SysPatent}, nil
|
||||
return &PatentDetailInfo{ID: mTechnologyPatent.GetEncodeID(), TechnologyPatent: mTechnologyPatent.TechnologyPatent}, nil
|
||||
}
|
||||
|
||||
func (c *Patent) Form(params *PatentParams) error {
|
||||
@ -265,49 +261,38 @@ func (c *Patent) Form(params *PatentParams) error {
|
||||
|
||||
// Shelf 上下架操作
|
||||
func (c *Patent) Shelf(id uint64, status int) error {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mUserPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||
} else if mUserPatent.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
return errors.New("操作错误,专利信息不存在或已被删除")
|
||||
} else if mTechnologyPatent.UID != c.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = mUserPatent.PatentID
|
||||
|
||||
return model2.Updates(mSysPatent.SysPatent, map[string]interface{}{
|
||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
|
||||
"shelf": status, "updated_at": time.Now(),
|
||||
})
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Patent) Delete(id uint64) error {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mUserPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,用户专利信息不存在或已被删除")
|
||||
} else if mUserPatent.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
return errors.New("操作错误,专利信息不存在或已被删除")
|
||||
} else if mTechnologyPatent.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)
|
||||
})
|
||||
return model2.Delete(mTechnologyPatent.TechnologyPatent)
|
||||
}
|
||||
|
||||
func NewPatent() PatentHandle {
|
||||
|
@ -97,22 +97,20 @@ func (c *Project) Form(params *ProjectParams) error {
|
||||
|
||||
// Shelf 上下架操作
|
||||
func (c *Project) Shelf(id uint64, status int) error {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mUserPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mUserPatent.UserPatent, []string{"id", "uid", "patent_id"})
|
||||
isExist, err := model2.FirstField(mTechnologyPatent.TechnologyPatent, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,项目信息不存在或已被删除")
|
||||
} else if mUserPatent.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
} else if mTechnologyPatent.UID != c.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = mUserPatent.PatentID
|
||||
|
||||
return model2.Updates(mSysPatent.SysPatent, map[string]interface{}{
|
||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, map[string]interface{}{
|
||||
"shelf_status": status, "updated_at": time.Now(),
|
||||
})
|
||||
}
|
||||
|
@ -35,21 +35,19 @@ type ManageExpertInstanceInfo struct {
|
||||
Introduce string `json:"introduce"`
|
||||
}
|
||||
|
||||
// Expert 专家信息
|
||||
// Instance 专家信息
|
||||
func (m *ManageExpert) Instance(limit int, where ...*model.ModelWhere) ([]*ManageExpertInstanceInfo, error) {
|
||||
// 专利信息
|
||||
mSysPatent := model.NewSysPatent()
|
||||
// 用户专利信息
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword",
|
||||
"p.title AS patent_title").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = p.patent_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
|
||||
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||
FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND p.shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||
limit, mUserPatent.TableName(), mSysPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||
Joins(fmt.Sprintf(`LEFT JOIN (SELECT uid, SUBSTRING_INDEX(GROUP_CONCAT(title ORDER BY id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||
FROM %s WHERE is_deleted = %d AND shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||
limit, mTechnologyPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||
Where("e.examine_status = ?", model.ExamineStatusForAgree).
|
||||
Where("e.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
@ -69,18 +67,16 @@ FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND
|
||||
// Detail 专家信息
|
||||
func (m *ManageExpert) Detail(limit int, id uint64) (*ManageExpertInstanceInfo, error) {
|
||||
// 专利信息
|
||||
mSysPatent := model.NewSysPatent()
|
||||
// 用户专利信息
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword", "e.research", "e.introduce",
|
||||
"p.title AS patent_title").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = p.patent_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
|
||||
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||
FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND p.shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||
limit, mUserPatent.TableName(), mSysPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||
Joins(fmt.Sprintf(`LEFT JOIN (SELECT uid, SUBSTRING_INDEX(GROUP_CONCAT(title ORDER BY id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||
FROM %s WHERE is_deleted = %d AND shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||
limit, mTechnologyPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||
Where("e.id = ?", id)
|
||||
|
||||
out := new(ManageExpertInstanceInfo)
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SysPatent 专利信息
|
||||
type SysPatent struct {
|
||||
*model.SysPatent
|
||||
// TechnologyPatent 专利信息
|
||||
type TechnologyPatent struct {
|
||||
*model.TechnologyPatent
|
||||
}
|
||||
|
||||
type SysPatentInfo struct {
|
||||
type TechnologyPatentInfo struct {
|
||||
model.Model
|
||||
Kind model.SysParentKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
@ -19,12 +19,18 @@ type SysPatentInfo struct {
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
|
||||
type TechnologyPatentBasicInfo struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
|
||||
// Instance 专利信息
|
||||
func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||
func (m *TechnologyPatent) Instance(where ...*model.ModelWhere) ([]*TechnologyPatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
@ -33,7 +39,7 @@ func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, erro
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*SysPatentInfo, 0)
|
||||
out := make([]*TechnologyPatentInfo, 0)
|
||||
|
||||
if err := db.Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
@ -41,7 +47,7 @@ func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, erro
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
var count int64
|
||||
db := orm.GetDB().Table(m.TableName())
|
||||
|
||||
@ -54,6 +60,6 @@ func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
func NewSysPatent() *SysPatent {
|
||||
return &SysPatent{model.NewSysPatent()}
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{model.NewTechnologyPatent()}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type UserPatent struct {
|
||||
*model.UserPatent
|
||||
}
|
||||
|
||||
type (
|
||||
// PatentInstance 专利信息
|
||||
PatentInstance struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
)
|
||||
|
||||
// Patent 专利信息
|
||||
func (m *UserPatent) Instance(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*PatentInstance, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS u_p").
|
||||
Select("p.id", "p.title", "p.apply_at", "p.description").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_p.patent_id = p.id",
|
||||
model.NewSysPatent().TableName())).
|
||||
Where("u_p.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*PatentInstance, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return &UserPatent{model.NewUserPatent()}
|
||||
}
|
@ -174,9 +174,9 @@ func (c *Index) static() (*InstanceStaticInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
// 专利信息
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
if err = model2.Count(mSysPatent.SysPatent, &out.PatentCount, model2.NewWhere("shelf_status", model2.ShelfStatusForUp)); err != nil {
|
||||
if err = model2.Count(mTechnologyPatent.TechnologyPatent, &out.PatentCount, model2.NewWhere("shelf_status", model2.ShelfStatusForUp)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//成果信息
|
||||
@ -250,8 +250,8 @@ func (c *Index) DistributionDemand(province, city string) (map[string]*InstanceD
|
||||
|
||||
// DistributionPatent 专利信息
|
||||
func (c *Index) DistributionPatent(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
out, err := mSysPatent.Distribution()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
out, err := mTechnologyPatent.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -281,9 +281,9 @@ func (c *Index) DistributionAchievementAndPatent(province, city string) (map[str
|
||||
|
||||
var err error
|
||||
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
// 专利信息
|
||||
if patent, err = mSysPatent.Distribution(); err != nil {
|
||||
if patent, err = mTechnologyPatent.Distribution(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
@ -329,8 +329,6 @@ func (c *Index) Instance() (*InstanceInfo, error) {
|
||||
|
||||
func NewIndex() IndexHandle {
|
||||
return func(session *session.Enterprise) *Index {
|
||||
return &Index{
|
||||
session,
|
||||
}
|
||||
return &Index{session}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.PatentInfo
|
||||
*model.TechnologyPatentBasicInfo
|
||||
}
|
||||
// PaperInfo 论文信息
|
||||
PaperInfo struct {
|
||||
@ -122,20 +122,25 @@ func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error)
|
||||
|
||||
// patent 专利信息
|
||||
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
var count int64
|
||||
out := make([]*model.TechnologyPatentBasicInfo, 0)
|
||||
|
||||
out, err := mUserPatent.Patent(page, pageSize, &count, model2.NewWhereIn("u_p.uid", uids))
|
||||
|
||||
if err != nil {
|
||||
if err := model2.PagesFields(mTechnologyPatent.TechnologyPatent, &out, []string{
|
||||
"id", "title", "apply_at", "description",
|
||||
}, page, pageSize, &count, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", uids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*PatentInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &PatentInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
PatentInfo: v,
|
||||
ID: v.GetEncodeID(), TechnologyPatentBasicInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
@ -216,17 +221,17 @@ func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
|
||||
Paper: make([]*technology.PaperInfo, 0),
|
||||
}
|
||||
// 专利信息
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
patents := make([]*model.SysPatentInfo, 0)
|
||||
patents := make([]*model.TechnologyPatentInfo, 0)
|
||||
|
||||
if patents, err = mSysPatent.Instance(model2.NewWhereIn("p.id", strings.Split(mManageCooperateEnterprise.Patent, ","))); err != nil {
|
||||
if patents, err = mTechnologyPatent.Instance(model2.NewWhereIn("p.id", strings.Split(mManageCooperateEnterprise.Patent, ","))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range patents {
|
||||
out.Patent = append(out.Patent, &technology.PatentInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
SysPatentInfo: v,
|
||||
ID: v.GetEncodeID(),
|
||||
TechnologyPatentInfo: v,
|
||||
})
|
||||
}
|
||||
// 论文信息
|
||||
|
@ -58,15 +58,15 @@ func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
patentTitles := make([]string, 0)
|
||||
|
||||
if out.PatentTitle != "" {
|
||||
for _, val := range strings.Split(out.PatentTitle, "&&") {
|
||||
objs := strings.Split(val, "$$")
|
||||
mSysPatent.Kind = model2.SysParentKind(utils.StringToInt(objs[0]))
|
||||
patentTitles = append(patentTitles, fmt.Sprintf("【%s】%s", mSysPatent.KindTitle(), objs[1]))
|
||||
mTechnologyPatent.Kind = model2.SysParentKind(utils.StringToInt(objs[0]))
|
||||
patentTitles = append(patentTitles, fmt.Sprintf("【%s】%s", mTechnologyPatent.KindTitle(), objs[1]))
|
||||
}
|
||||
}
|
||||
_industrys := make([]string, 0)
|
||||
|
@ -61,7 +61,7 @@ func searchExpert(page, pageSize int, keyword, industry string, params map[strin
|
||||
}
|
||||
list := make([]*ExpertInfo, 0)
|
||||
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
for _, v := range experts {
|
||||
_industrys := make([]string, 0)
|
||||
@ -74,8 +74,8 @@ func searchExpert(page, pageSize int, keyword, industry string, params map[strin
|
||||
if v.PatentTitle != "" {
|
||||
for _, val := range strings.Split(v.PatentTitle, "&&") {
|
||||
objs := strings.Split(val, "$$")
|
||||
mSysPatent.Kind = model2.SysParentKind(utils.StringToInt(objs[0]))
|
||||
patentTitles = append(patentTitles, fmt.Sprintf("【%s】%s", mSysPatent.KindTitle(), objs[1]))
|
||||
mTechnologyPatent.Kind = model2.SysParentKind(utils.StringToInt(objs[0]))
|
||||
patentTitles = append(patentTitles, fmt.Sprintf("【%s】%s", mTechnologyPatent.KindTitle(), objs[1]))
|
||||
}
|
||||
}
|
||||
list = append(list, &ExpertInfo{
|
||||
|
@ -40,11 +40,11 @@ func searchPatent(page, pageSize int, keyword, industry string, params map[strin
|
||||
if len(ids) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
patents := make([]*model2.SysPatent, 0)
|
||||
|
||||
if err = model2.ScanFields(mSysPatent.SysPatent, &patents, []string{"id", "kind", "title", "apply_at", "description"},
|
||||
if err = model2.ScanFields(mTechnologyPatent.TechnologyPatent, &patents, []string{"id", "kind", "title", "apply_at", "description"},
|
||||
&model2.ModelWhereOrder{Where: model2.NewWhereIn("id", ids)}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Patent struct{}
|
||||
@ -17,12 +16,12 @@ type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.SysPatentInfo
|
||||
*model.TechnologyPatentInfo
|
||||
}
|
||||
// PatentDetailInfo 专利详细信息
|
||||
PatentDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.SysPatent
|
||||
*model2.TechnologyPatent
|
||||
}
|
||||
)
|
||||
|
||||
@ -44,14 +43,12 @@ func (c *Patent) Instance(title, industry string, page, pageSize int) (*controll
|
||||
|
||||
var count int64
|
||||
|
||||
fmt.Println(out)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out == nil {
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
@ -59,15 +56,15 @@ func (c *Patent) Instance(title, industry string, page, pageSize int) (*controll
|
||||
val := v.(*service.ESPatent)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
ret := make([]*model.SysPatentInfo, 0)
|
||||
ret := make([]*model.TechnologyPatentInfo, 0)
|
||||
|
||||
if ret, err = mSysPatent.Patents(page, pageSize, &count, model2.NewWhereIn("p.id", ids)); err != nil {
|
||||
if ret, err = mTechnologyPatent.Patents(page, pageSize, &count, model2.NewWhereIn("p.id", ids)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range ret {
|
||||
list = append(list, &PatentInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
SysPatentInfo: v,
|
||||
ID: v.GetEncodeID(),
|
||||
TechnologyPatentInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count1}, nil
|
||||
@ -75,17 +72,17 @@ func (c *Patent) Instance(title, industry string, page, pageSize int) (*controll
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
mSysPatent.ID = id
|
||||
mTechnologyPatent := model.NewTechnologyPatent()
|
||||
mTechnologyPatent.ID = id
|
||||
|
||||
isExist, err := model2.First(mSysPatent.SysPatent)
|
||||
isExist, err := model2.First(mTechnologyPatent.TechnologyPatent)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,专利信息不存在或已被删除")
|
||||
}
|
||||
return &PatentDetailInfo{ID: mSysPatent.GetEncodeID(), SysPatent: mSysPatent.SysPatent}, nil
|
||||
return &PatentDetailInfo{ID: mTechnologyPatent.GetEncodeID(), TechnologyPatent: mTechnologyPatent.TechnologyPatent}, nil
|
||||
}
|
||||
|
||||
func NewPatent() PatentHandle {
|
||||
|
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysPatentClassify struct {
|
||||
*model.SysPatentClassify
|
||||
}
|
||||
|
||||
func NewSysPatentClassify() *SysPatentClassify {
|
||||
return &SysPatentClassify{model.NewSysPatentClassify()}
|
||||
}
|
@ -6,11 +6,11 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type SysPatent struct {
|
||||
*model.SysPatent
|
||||
type TechnologyPatent struct {
|
||||
*model.TechnologyPatent
|
||||
}
|
||||
|
||||
type SysPatentInfo struct {
|
||||
type TechnologyPatentInfo struct {
|
||||
model.Model
|
||||
Kind model.SysParentKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
@ -18,12 +18,22 @@ type SysPatentInfo struct {
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
|
||||
type (
|
||||
// TechnologyPatentBasicInfo 专利信息
|
||||
TechnologyPatentBasicInfo struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 专利信息
|
||||
func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||
func (m *TechnologyPatent) Instance(where ...*model.ModelWhere) ([]*TechnologyPatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
@ -32,7 +42,7 @@ func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, erro
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*SysPatentInfo, 0)
|
||||
out := make([]*TechnologyPatentInfo, 0)
|
||||
|
||||
if err := db.Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
@ -41,11 +51,11 @@ func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, erro
|
||||
}
|
||||
|
||||
// Patents 专利信息
|
||||
func (m *SysPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||
func (m *TechnologyPatent) Patents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
@ -54,7 +64,7 @@ func (m *SysPatent) Patents(page, pageSize int, count *int64, where ...*model.Mo
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*SysPatentInfo, 0)
|
||||
out := make([]*TechnologyPatentInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
@ -67,16 +77,14 @@ func (m *SysPatent) Patents(page, pageSize int, count *int64, where ...*model.Mo
|
||||
}
|
||||
|
||||
// Distribution 分布信息
|
||||
func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
func (m *TechnologyPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("e.province", "e.city", "e.district", "GROUP_CONCAT(p_c.industry_detail SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("RIGHT JOIN %s AS p_c ON p.ipc_code = p_c.ipc AND p_c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("RIGHT JOIN %s AS u_p ON p.id = u_p.patent_id AND u_p.is_deleted = %d",
|
||||
model.NewUserPatent().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON u_p.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
model.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON p.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
@ -86,6 +94,6 @@ func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewSysPatent() *SysPatent {
|
||||
return &SysPatent{model.NewSysPatent()}
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{model.NewTechnologyPatent()}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type UserPatent struct {
|
||||
*model.UserPatent
|
||||
}
|
||||
|
||||
type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
)
|
||||
|
||||
// Patent 专利信息
|
||||
func (m *UserPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*PatentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS u_p").
|
||||
Select("p.id", "p.title", "p.apply_at", "p.description").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_p.patent_id = p.id",
|
||||
model.NewSysPatent().TableName())).
|
||||
Where("u_p.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*PatentInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("p.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()}
|
||||
}
|
@ -64,7 +64,6 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewSysPatent(), iValues: func() interface{} {
|
||||
return nil
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysPatentClassify()},
|
||||
&synchronized{iModel: model.NewSysIdentity(), iValues: func() interface{} {
|
||||
out := make([]*model.SysIdentity, 0)
|
||||
|
||||
@ -127,8 +126,7 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewSysUserExamineLog()},
|
||||
// 用户管理
|
||||
&synchronized{iModel: model.NewUserInstance()}, &synchronized{iModel: model.NewUserIdentity()},
|
||||
&synchronized{iModel: model.NewUserAssets()},
|
||||
&synchronized{iModel: model.NewUserPatent()}, &synchronized{iModel: model.NewUserBank()},
|
||||
&synchronized{iModel: model.NewUserAssets()}, &synchronized{iModel: model.NewUserBank()},
|
||||
&synchronized{iModel: model.NewUserCompany()}, &synchronized{iModel: model.NewUserExpert()},
|
||||
&synchronized{iModel: model.NewUserLaboratory()}, &synchronized{iModel: model.NewUserResearch()},
|
||||
&synchronized{iModel: model.NewUserAgent()},
|
||||
@ -142,6 +140,7 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewTechnologyPaper()}, &synchronized{iModel: model.NewTechnologyProduct()},
|
||||
&synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()},
|
||||
&synchronized{iModel: model.NewTechnologyDemandService()}, &synchronized{iModel: model.NewTechnologyDemandServiceProgress()},
|
||||
&synchronized{iModel: model.NewTechnologyPatent()}, &synchronized{iModel: model.NewTechnologyPatentClassify()},
|
||||
&synchronized{iModel: model.NewServiceDocking()},
|
||||
&synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceMessageLog()},
|
||||
&synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseKind()},
|
||||
|
@ -4,6 +4,7 @@ package model
|
||||
type SysPatent struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Kind SysParentKind `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"`
|
||||
|
68
app/common/model/technology_patent.go
Normal file
68
app/common/model/technology_patent.go
Normal file
@ -0,0 +1,68 @@
|
||||
package model
|
||||
|
||||
// TechnologyPatent 专利信息数据模型
|
||||
type TechnologyPatent struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Kind SysParentKind `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 SysParentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1:授权,2:实审,3:公开)" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// TechnologyPatentKind 专利类型
|
||||
type TechnologyPatentKind int
|
||||
|
||||
const (
|
||||
// TechnologyPatentKindForInvent 发明专利
|
||||
TechnologyPatentKindForInvent TechnologyPatentKind = iota + 1
|
||||
// TechnologyPatentKindForDesign 外观设计
|
||||
TechnologyPatentKindForDesign
|
||||
// TechnologyPatentKindForNewPractical 实用新型
|
||||
TechnologyPatentKindForNewPractical
|
||||
)
|
||||
|
||||
// TechnologyPatentStatus 专利状态
|
||||
type TechnologyPatentStatus int
|
||||
|
||||
const (
|
||||
// TechnologyPatentStatusForAuthorize 授权
|
||||
TechnologyPatentStatusForAuthorize TechnologyPatentStatus = iota + 1
|
||||
// TechnologyPatentStatusForActualTrial 实审
|
||||
TechnologyPatentStatusForActualTrial
|
||||
// TechnologyPatentStatusForPublic 公开
|
||||
TechnologyPatentStatusForPublic
|
||||
)
|
||||
|
||||
func (m *TechnologyPatent) TableName() string {
|
||||
return "technology_patent"
|
||||
}
|
||||
|
||||
func (m *TechnologyPatent) KindTitle() string {
|
||||
if m.Kind == SysParentKindForInvent {
|
||||
return "发明专利"
|
||||
} else if m.Kind == SysParentKindForDesign {
|
||||
return "外观设计"
|
||||
} else if m.Kind == SysParentKindForNewPractical {
|
||||
return "实用新型"
|
||||
}
|
||||
return "未知"
|
||||
}
|
||||
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{}
|
||||
}
|
@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// SysPatentClassify 专利分类信息数据模型
|
||||
type SysPatentClassify struct {
|
||||
// TechnologyPatentClassify 专利分类信息数据模型
|
||||
type TechnologyPatentClassify struct {
|
||||
Model
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"parent_id"`
|
||||
IPC string `gorm:"column:ipc;type:varchar(18);default:'';comment:IPC主分类号" json:"ipc"`
|
||||
@ -15,32 +15,32 @@ type SysPatentClassify struct {
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *SysPatentClassify) TableName() string {
|
||||
return "sys_patent_classify"
|
||||
func (m *TechnologyPatentClassify) TableName() string {
|
||||
return "technology_patent_classify"
|
||||
}
|
||||
|
||||
func (m *SysPatentClassify) GetIndustryAttribute() []string {
|
||||
func (m *TechnologyPatentClassify) GetIndustryAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = json.Unmarshal([]byte(m.Industry), &out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *SysPatentClassify) SetIndustryAttribute(value []string) {
|
||||
func (m *TechnologyPatentClassify) SetIndustryAttribute(value []string) {
|
||||
_bytes, _ := json.Marshal(value)
|
||||
m.Industry = string(_bytes)
|
||||
}
|
||||
|
||||
func (m *SysPatentClassify) GetIndustryDetailAttribute() []string {
|
||||
func (m *TechnologyPatentClassify) GetIndustryDetailAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = json.Unmarshal([]byte(m.IndustryDetail), &out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *SysPatentClassify) SetIndustryDetailAttribute(value []string) {
|
||||
func (m *TechnologyPatentClassify) SetIndustryDetailAttribute(value []string) {
|
||||
_bytes, _ := json.Marshal(value)
|
||||
m.IndustryDetail = string(_bytes)
|
||||
}
|
||||
|
||||
func NewSysPatentClassify() *SysPatentClassify {
|
||||
return &SysPatentClassify{}
|
||||
func NewTechnologyPatentClassify() *TechnologyPatentClassify {
|
||||
return &TechnologyPatentClassify{}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
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:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserPatent) TableName() string {
|
||||
return "user_patent"
|
||||
}
|
||||
|
||||
func NewUserPatent() *UserPatent {
|
||||
return &UserPatent{}
|
||||
}
|
Reference in New Issue
Block a user