feat:优化项目信息
This commit is contained in:
@ -8,11 +8,12 @@
|
|||||||
环境和依赖
|
环境和依赖
|
||||||
----
|
----
|
||||||
|
|
||||||
- Go>=1.15
|
- Go >= 1.15
|
||||||
- [Gin](https://github.com/gin-gonic/gin) - Web Router
|
- [Gin](https://github.com/gin-gonic/gin) - Web Router
|
||||||
- [Gorm.v2](https://github.com/go-gorm/gorm) - Data Engine
|
- [Gorm.v2](https://github.com/go-gorm/gorm) - Data Engine
|
||||||
- [Cacbin](https://github.com/casbin/casbin) - Auth(RBAC)
|
- [Cacbin](https://github.com/casbin/casbin) - Auth(RBAC)
|
||||||
- [Redis](https://github.com/redis/redis)
|
- [Redis](https://github.com/redis/redis)
|
||||||
|
- [Elasticsearch](https://github.com/olivere/elastic) - ESSearchV7
|
||||||
|
|
||||||
项目编译和运行
|
项目编译和运行
|
||||||
----
|
----
|
||||||
|
@ -41,7 +41,7 @@ func (*Technology) PatentForm(c *gin.Context) {
|
|||||||
form := &struct {
|
form := &struct {
|
||||||
api.IDStringForm
|
api.IDStringForm
|
||||||
api.TenantIDStringForm
|
api.TenantIDStringForm
|
||||||
Kind int `json:"kind" form:"kind" binding:"kind"`
|
Kind int `json:"kind" form:"kind" binding:"required"`
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
FileUrl string `json:"file_url" form:"file_url"`
|
FileUrl string `json:"file_url" form:"file_url"`
|
||||||
ApplyCode string `json:"apply_code" form:"apply_code" binding:"required"`
|
ApplyCode string `json:"apply_code" form:"apply_code" binding:"required"`
|
||||||
@ -55,7 +55,7 @@ func (*Technology) PatentForm(c *gin.Context) {
|
|||||||
PrincipalClaim string `json:"principal_claim" form:"principal_claim"`
|
PrincipalClaim string `json:"principal_claim" form:"principal_claim"`
|
||||||
Description string `json:"description" form:"description"`
|
Description string `json:"description" form:"description"`
|
||||||
ShelfStatus int `json:"shelf_status" form:"shelf_status" binding:"required"`
|
ShelfStatus int `json:"shelf_status" form:"shelf_status" binding:"required"`
|
||||||
Status int `json:"status" form:"status" binding:"required"`
|
Status int `json:"status" form:"status"`
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
|
@ -130,7 +130,13 @@ func (c *Achievement) Examine(id uint64, status int, remark string) error {
|
|||||||
|
|
||||||
// Shelf 上下架
|
// Shelf 上下架
|
||||||
func (c *Achievement) Shelf(id uint64) error {
|
func (c *Achievement) Shelf(id uint64) error {
|
||||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyAchievement(), id)
|
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyAchievement(), id, func(kind model2.ShelfStatusKind) error {
|
||||||
|
manage := service.NewESAchievement(
|
||||||
|
service.WithAchievementID(id),
|
||||||
|
service.WithAchievementShow(int(kind)),
|
||||||
|
)
|
||||||
|
return manage.Update()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Achievement) Delete(id uint64) error {
|
func (c *Achievement) Delete(id uint64) error {
|
||||||
|
@ -5,10 +5,11 @@ import (
|
|||||||
"SciencesServer/app/basic/config"
|
"SciencesServer/app/basic/config"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/utils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,9 +23,8 @@ type PatentHandle func(session *session.Admin) *Patent
|
|||||||
type (
|
type (
|
||||||
// PatentInfo 专利信息
|
// PatentInfo 专利信息
|
||||||
PatentInfo struct {
|
PatentInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
UID string `json:"uid"`
|
*model.TechnologyPatentInfo
|
||||||
*model.SysPatentInfo
|
|
||||||
}
|
}
|
||||||
// PatentDetailInfo 专利详细信息
|
// PatentDetailInfo 专利详细信息
|
||||||
PatentDetailInfo struct {
|
PatentDetailInfo struct {
|
||||||
@ -98,7 +98,6 @@ func (c *Patent) Instance(tenantID uint64, title, ipc string, page, pageSize int
|
|||||||
if c.TenantID > 0 {
|
if c.TenantID > 0 {
|
||||||
where = append(where, model2.NewWhere("p.tenant_id", c.TenantID))
|
where = append(where, model2.NewWhere("p.tenant_id", c.TenantID))
|
||||||
}
|
}
|
||||||
|
|
||||||
if tenantID > 0 {
|
if tenantID > 0 {
|
||||||
where = append(where, model2.NewWhere("p.tenant_id", tenantID))
|
where = append(where, model2.NewWhere("p.tenant_id", tenantID))
|
||||||
}
|
}
|
||||||
@ -119,9 +118,8 @@ func (c *Patent) Instance(tenantID uint64, title, ipc string, page, pageSize int
|
|||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &PatentInfo{
|
list = append(list, &PatentInfo{
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(),
|
||||||
UID: fmt.Sprintf("%d", v.UID),
|
TechnologyPatentInfo: v,
|
||||||
SysPatentInfo: v,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
@ -191,8 +189,32 @@ func (c *Patent) Form(params *PatentParams) error {
|
|||||||
mTechnologyPatent.ShelfStatus = model2.ShelfStatusKind(params.ShelfStatus)
|
mTechnologyPatent.ShelfStatus = model2.ShelfStatusKind(params.ShelfStatus)
|
||||||
mTechnologyPatent.Status = model2.TechnologyPatentStatus(params.Status)
|
mTechnologyPatent.Status = model2.TechnologyPatentStatus(params.Status)
|
||||||
|
|
||||||
|
// 查询IPCCode信息
|
||||||
|
mTechnologyPatentClassify := model.NewTechnologyPatentClassify()
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mTechnologyPatentClassify.TechnologyPatentClassify, []string{"id", "industry_detail"},
|
||||||
|
model2.NewWhere("ipc", params.IPCCode))
|
||||||
|
|
||||||
|
_industrys := make([]string, 0)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if isExist {
|
||||||
|
for _, v := range mTechnologyPatentClassify.GetIndustryDetailAttribute() {
|
||||||
|
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
manage := service.NewESPatent(
|
||||||
|
service.WithPatentTitle(mTechnologyPatent.Title),
|
||||||
|
service.WithPatentIndustry(strings.Join(_industrys, ";")),
|
||||||
|
service.WithPatentShow(params.Status),
|
||||||
|
)
|
||||||
if mTechnologyPatent.ID > 0 {
|
if mTechnologyPatent.ID > 0 {
|
||||||
return model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent)
|
if err = model2.Updates(mTechnologyPatent.TechnologyPatent, mTechnologyPatent.TechnologyPatent); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_ = manage.Update()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
_condition["apply_code"] = params.ApplyCode
|
_condition["apply_code"] = params.ApplyCode
|
||||||
_condition["ipc_code"] = params.IPCCode
|
_condition["ipc_code"] = params.IPCCode
|
||||||
@ -203,7 +225,13 @@ func (c *Patent) Form(params *PatentParams) error {
|
|||||||
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
return errors.New("操作错误,申请号或公开(公告)号已存在")
|
||||||
}
|
}
|
||||||
mTechnologyPatent.TenantID = c.TenantID
|
mTechnologyPatent.TenantID = c.TenantID
|
||||||
return model2.Create(mTechnologyPatent.TechnologyPatent)
|
|
||||||
|
if err := model2.Create(mTechnologyPatent.TechnologyPatent); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
service.WithPatentID(mTechnologyPatent.ID)(manage)
|
||||||
|
|
||||||
|
return manage.Create()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind 绑定信息
|
// Bind 绑定信息
|
||||||
@ -226,30 +254,17 @@ func (c *Patent) Bind(id, uid uint64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
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)
|
|
||||||
//})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shelf 上下架操作
|
||||||
func (c *Patent) Shelf(id uint64) error {
|
func (c *Patent) Shelf(id uint64) error {
|
||||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyPatent(), id)
|
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyPatent(), id, func(kind model2.ShelfStatusKind) error {
|
||||||
|
manage := service.NewESPatent(
|
||||||
|
service.WithPatentID(id),
|
||||||
|
service.WithPatentShow(int(kind)),
|
||||||
|
)
|
||||||
|
return manage.Update()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
@ -266,7 +281,14 @@ func (c *Patent) Delete(id uint64) error {
|
|||||||
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
|
} else if c.TenantID > 0 && mTechnologyPatent.TenantID > 0 && c.TenantID != mTechnologyPatent.TenantID {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
return model2.Delete(mTechnologyPatent.TechnologyPatent)
|
err = model2.Delete(mTechnologyPatent.TechnologyPatent)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_ = service.NewESPatent(service.WithPatentID(mTechnologyPatent.ID)).Delete()
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPC IPC信息
|
// IPC IPC信息
|
||||||
|
@ -105,7 +105,7 @@ func (c *Product) Examine(id uint64, status int, remark string) error {
|
|||||||
|
|
||||||
// Shelf 上下架操作
|
// Shelf 上下架操作
|
||||||
func (c *Product) Shelf(id uint64) error {
|
func (c *Product) Shelf(id uint64) error {
|
||||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyProduct(), id)
|
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyProduct(), id, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
|
@ -59,8 +59,7 @@ func (c *Project) Instance(tenantID uint64, title string, page, pageSize int) (*
|
|||||||
|
|
||||||
// Shelf 上下架操作
|
// Shelf 上下架操作
|
||||||
func (c *Project) Shelf(id uint64) error {
|
func (c *Project) Shelf(id uint64) error {
|
||||||
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).
|
return controller.NewShelf(controller.WithShelfSessionAdmin(c.Admin)).Handle(model2.NewTechnologyProject(), id, nil)
|
||||||
Handle(model2.NewTechnologyProject(), id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
|
@ -12,15 +12,16 @@ type TechnologyPatent struct {
|
|||||||
*model.TechnologyPatent
|
*model.TechnologyPatent
|
||||||
}
|
}
|
||||||
|
|
||||||
// SysPatentInfo 专利信息
|
// TechnologyPatentInfo 专利信息
|
||||||
type SysPatentInfo struct {
|
type TechnologyPatentInfo struct {
|
||||||
model.Model
|
model.Model
|
||||||
model.ModelTenant
|
model.ModelTenant
|
||||||
Title string `json:"title"`
|
Kind model.TechnologyPatentKind `json:"kind"`
|
||||||
ApplyCode string `json:"apply_code"`
|
Title string `json:"title"`
|
||||||
ApplyAt string `json:"apply_at"`
|
ApplyCode string `json:"apply_code"`
|
||||||
ApplyName string `json:"apply_name"`
|
ApplyAt string `json:"apply_at"`
|
||||||
Inventor string `json:"inventor"`
|
ApplyName string `json:"apply_name"`
|
||||||
|
Inventor string `json:"inventor"`
|
||||||
model.Shelf
|
model.Shelf
|
||||||
UID uint64 `json:"-"`
|
UID uint64 `json:"-"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
@ -32,7 +33,7 @@ func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, e
|
|||||||
|
|
||||||
if len(params) > 0 {
|
if len(params) > 0 {
|
||||||
for k, v := range params {
|
for k, v := range params {
|
||||||
db = db.Or(fmt.Sprintf("%s = %v AND is_deleted = %d", k, v, model.DeleteStatusForNot))
|
db = db.Or(fmt.Sprintf("%s = '%v' AND is_deleted = %d", k, v, model.DeleteStatusForNot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err := db.Count(&count).Error
|
err := db.Count(&count).Error
|
||||||
@ -40,17 +41,18 @@ func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
func (m *TechnologyPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
func (m *TechnologyPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyPatentInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
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",
|
Select("p.id", "p.kind", "p.title", "p.apply_code", "p.inventor", "p.apply_name", "p.apply_at",
|
||||||
"p.shelf_status", "p.created_at")
|
"p.shelf_status", "p.created_at").
|
||||||
|
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
for _, wo := range where {
|
for _, wo := range where {
|
||||||
db = db.Where(wo.Condition, wo.Value)
|
db = db.Where(wo.Condition, wo.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out := make([]*SysPatentInfo, 0)
|
out := make([]*TechnologyPatentInfo, 0)
|
||||||
|
|
||||||
if err := db.Count(count).Error; err != nil {
|
if err := db.Count(count).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -208,9 +208,17 @@ func (c *Achievement) Shelf(id uint64, status int) error {
|
|||||||
} else if mTechnologyAchievement.ShelfStatus == model2.ShelfStatusKind(status) {
|
} else if mTechnologyAchievement.ShelfStatus == model2.ShelfStatusKind(status) {
|
||||||
return errors.New("操作错误,无需变更上下架状态")
|
return errors.New("操作错误,无需变更上下架状态")
|
||||||
}
|
}
|
||||||
return model2.Updates(mTechnologyAchievement.TechnologyAchievement, map[string]interface{}{
|
|
||||||
|
if err = model2.Updates(mTechnologyAchievement.TechnologyAchievement, map[string]interface{}{
|
||||||
"shelf_status": status, "updated_at": time.Now(),
|
"shelf_status": status, "updated_at": time.Now(),
|
||||||
})
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
manage := service.NewESAchievement(
|
||||||
|
service.WithAchievementID(mTechnologyAchievement.ID),
|
||||||
|
service.WithAchievementShow(status),
|
||||||
|
)
|
||||||
|
return manage.Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
@ -227,7 +235,14 @@ func (c *Achievement) Delete(id uint64) error {
|
|||||||
} else if mTechnologyAchievement.UID != c.UID {
|
} else if mTechnologyAchievement.UID != c.UID {
|
||||||
return errors.New("无权限操作")
|
return errors.New("无权限操作")
|
||||||
}
|
}
|
||||||
return model2.Delete(mTechnologyAchievement.TechnologyAchievement)
|
|
||||||
|
if err = model2.Delete(mTechnologyAchievement.TechnologyAchievement); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
manage := service.NewESAchievement(
|
||||||
|
service.WithAchievementID(mTechnologyAchievement.ID),
|
||||||
|
)
|
||||||
|
return manage.Delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAchievement() AchievementHandle {
|
func NewAchievement() AchievementHandle {
|
||||||
|
@ -33,10 +33,11 @@ func WithShelfSessionEnterprise(session *session.Enterprise) ShelfOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Shelf) Handle(iModel model.IModel, id uint64) error {
|
func (c *Shelf) Handle(iModel model.IModel, id uint64, callback func(kind model.ShelfStatusKind) error) error {
|
||||||
if c.Admin == nil && c.Enterprise == nil {
|
if c.Admin == nil && c.Enterprise == nil {
|
||||||
return errors.New("操作错误,未知的人员操作")
|
return errors.New("操作错误,未知的人员操作")
|
||||||
}
|
}
|
||||||
|
iModel.SetID(id)
|
||||||
out := new(IModelInfo)
|
out := new(IModelInfo)
|
||||||
|
|
||||||
err := model.ScanFields(iModel, out, []string{"id", "tenant_id", "uid", "shelf_status"},
|
err := model.ScanFields(iModel, out, []string{"id", "tenant_id", "uid", "shelf_status"},
|
||||||
@ -57,14 +58,22 @@ func (c *Shelf) Handle(iModel model.IModel, id uint64) error {
|
|||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
shelfStatus := model.ShelfStatusForUp
|
||||||
|
|
||||||
|
if out.ShelfStatus == model.ShelfStatusForUp {
|
||||||
|
shelfStatus = model.ShelfStatusForDown
|
||||||
|
}
|
||||||
values := map[string]interface{}{
|
values := map[string]interface{}{
|
||||||
"shelf_status": model.ShelfStatusForUp,
|
"shelf_status": shelfStatus,
|
||||||
"updated_at": time.Now(),
|
"updated_at": time.Now(),
|
||||||
}
|
}
|
||||||
if out.ShelfStatus == model.ShelfStatusForUp {
|
if err := model.Updates(iModel, values); err != nil {
|
||||||
values["shelf_status"] = model.ShelfStatusForDown
|
return err
|
||||||
}
|
}
|
||||||
return model.Updates(iModel, values)
|
if callback != nil {
|
||||||
|
return callback(shelfStatus)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewShelf(options ...ShelfOption) *Shelf {
|
func NewShelf(options ...ShelfOption) *Shelf {
|
||||||
|
@ -29,7 +29,7 @@ type PPatent struct {
|
|||||||
PrincipalClaim string `gorm:"column:principal_claim;type:text;comment:主权项" json:"principal_claim"`
|
PrincipalClaim string `gorm:"column:principal_claim;type:text;comment:主权项" json:"principal_claim"`
|
||||||
IPCCode string `gorm:"column:ipc_code;type:varchar(50);default:'';comment:IPC主分类号" json:"ipc_code"`
|
IPCCode string `gorm:"column:ipc_code;type:varchar(50);default:'';comment:IPC主分类号" json:"ipc_code"`
|
||||||
Shelf
|
Shelf
|
||||||
Status SysParentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1:授权,2:实审,3:公开)" json:"-"`
|
Status TechnologyPatentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1:授权,2:实审,3:公开)" json:"-"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func TestRecoveryPatent(t *testing.T) {
|
|||||||
|
|
||||||
mysql := mysql()
|
mysql := mysql()
|
||||||
|
|
||||||
mSysPatent := new(SysPatent)
|
mSysPatent := new(PPatent)
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
@ -105,17 +105,17 @@ func TestRecoveryPatent(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Log(len(src))
|
t.Log(len(src))
|
||||||
out := make([]*SysPatent, 0)
|
out := make([]*TechnologyPatent, 0)
|
||||||
|
|
||||||
for _, v := range src {
|
for _, v := range src {
|
||||||
kind := SysParentKindForInvent
|
kind := TechnologyPatentKindForInvent
|
||||||
|
|
||||||
if v.Kind == "实用新型" {
|
if v.Kind == "实用新型" {
|
||||||
kind = SysParentKindForNewPractical
|
kind = TechnologyPatentKindForNewPractical
|
||||||
} else if v.Kind == "外观设计" {
|
} else if v.Kind == "外观设计" {
|
||||||
kind = SysParentKindForDesign
|
kind = TechnologyPatentKindForDesign
|
||||||
}
|
}
|
||||||
data := &SysPatent{
|
data := &TechnologyPatent{
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
Title: v.Title,
|
Title: v.Title,
|
||||||
FileUrl: v.FileUrl,
|
FileUrl: v.FileUrl,
|
||||||
|
@ -11,6 +11,7 @@ type ESAchievement struct {
|
|||||||
Title string `json:"title"` // 成果名称
|
Title string `json:"title"` // 成果名称
|
||||||
Industry string `json:"industry"` // 行业领域
|
Industry string `json:"industry"` // 行业领域
|
||||||
Keyword string `json:"keyword"` // 关键词
|
Keyword string `json:"keyword"` // 关键词
|
||||||
|
IsShow int `json:"is_show"` // 展示
|
||||||
}
|
}
|
||||||
|
|
||||||
type ESAchievementOption func(achievement *ESAchievement)
|
type ESAchievementOption func(achievement *ESAchievement)
|
||||||
@ -24,6 +25,24 @@ func (this *ESAchievement) Create() error {
|
|||||||
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ESAchievement) Update() error {
|
||||||
|
_map := make(map[string]interface{}, 0)
|
||||||
|
|
||||||
|
if this.Title != "" {
|
||||||
|
_map["title"] = this.Title
|
||||||
|
}
|
||||||
|
if this.Industry != "" {
|
||||||
|
_map["industry"] = this.Industry
|
||||||
|
}
|
||||||
|
if this.Keyword != "" {
|
||||||
|
_map["keyword"] = this.Keyword
|
||||||
|
}
|
||||||
|
if this.IsShow != 0 {
|
||||||
|
_map["is_show"] = this.IsShow
|
||||||
|
}
|
||||||
|
return es.Update(this.Index(), fmt.Sprintf("%d", this.ID), _map)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *ESAchievement) Search(page, pageSize int) (interface{}, int64, error) {
|
func (this *ESAchievement) Search(page, pageSize int) (interface{}, int64, error) {
|
||||||
termParams := make(map[string]interface{}, 0)
|
termParams := make(map[string]interface{}, 0)
|
||||||
mustParams := make(map[string]interface{}, 0)
|
mustParams := make(map[string]interface{}, 0)
|
||||||
@ -37,12 +56,18 @@ func (this *ESAchievement) Search(page, pageSize int) (interface{}, int64, error
|
|||||||
if this.Keyword != "" {
|
if this.Keyword != "" {
|
||||||
mustParams["keyword"] = this.Keyword
|
mustParams["keyword"] = this.Keyword
|
||||||
}
|
}
|
||||||
|
termParams["is_show"] = 1
|
||||||
|
|
||||||
return es.Search(this, this.Index(), &es.SearchParams{
|
return es.Search(this, this.Index(), &es.SearchParams{
|
||||||
TermParams: termParams,
|
TermParams: termParams,
|
||||||
MustParams: mustParams,
|
MustParams: mustParams,
|
||||||
}, page, pageSize)
|
}, page, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ESAchievement) Delete() error {
|
||||||
|
return es.Delete(this.Index(), fmt.Sprintf("%d", this.ID))
|
||||||
|
}
|
||||||
|
|
||||||
func WithAchievementID(id uint64) ESAchievementOption {
|
func WithAchievementID(id uint64) ESAchievementOption {
|
||||||
return func(achievement *ESAchievement) {
|
return func(achievement *ESAchievement) {
|
||||||
achievement.ID = id
|
achievement.ID = id
|
||||||
@ -67,6 +92,12 @@ func WithAchievementKeyword(keyword string) ESAchievementOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithAchievementShow(show int) ESAchievementOption {
|
||||||
|
return func(achievement *ESAchievement) {
|
||||||
|
achievement.IsShow = show
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NewESAchievement(options ...ESAchievementOption) *ESAchievement {
|
func NewESAchievement(options ...ESAchievementOption) *ESAchievement {
|
||||||
out := new(ESAchievement)
|
out := new(ESAchievement)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user