feat:优化项目信息,待测试修改
This commit is contained in:
65
app/api/enterprise/model/technology_patent.go
Normal file
65
app/api/enterprise/model/technology_patent.go
Normal file
@ -0,0 +1,65 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// TechnologyPatent 专利信息
|
||||
type TechnologyPatent struct {
|
||||
*model.TechnologyPatent
|
||||
}
|
||||
|
||||
type TechnologyPatentInfo struct {
|
||||
model.Model
|
||||
Kind model.SysParentKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
|
||||
type TechnologyPatentBasicInfo struct {
|
||||
model.Model
|
||||
Title string `json:"title"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
|
||||
// Instance 专利信息
|
||||
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.NewTechnologyPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*TechnologyPatentInfo, 0)
|
||||
|
||||
if err := db.Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (m *TechnologyPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
var count int64
|
||||
db := orm.GetDB().Table(m.TableName())
|
||||
|
||||
if len(params) > 0 {
|
||||
for k, v := range params {
|
||||
db = db.Or(fmt.Sprintf("%s = %v AND is_deleted = %d", k, v, model.DeleteStatusForNot))
|
||||
}
|
||||
}
|
||||
err := db.Count(&count).Error
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
func NewTechnologyPatent() *TechnologyPatent {
|
||||
return &TechnologyPatent{model.NewTechnologyPatent()}
|
||||
}
|
Reference in New Issue
Block a user