feat:完善项目
This commit is contained in:
@ -17,7 +17,7 @@ type SysAboutInfo struct {
|
||||
|
||||
func (m *SysAbout) About(where ...*model.ModelWhere) ([]*SysAboutInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.parent_id", "a.title", "t.province", "t.city").
|
||||
Select("a.id", "a.parent_id", "a.title", "t.province", "t.city", "a.updated_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON a.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
|
59
app/api/admin/model/sys_patent.go
Normal file
59
app/api/admin/model/sys_patent.go
Normal file
@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SysPatent 专利信息
|
||||
type SysPatent struct {
|
||||
*model.SysPatent
|
||||
}
|
||||
|
||||
// SysPatentInfo 专利信息
|
||||
type SysPatentInfo struct {
|
||||
*model.SysPatent
|
||||
UID string `json:"uid"`
|
||||
}
|
||||
|
||||
func (m *SysPatent) IsExistParams(params map[string]interface{}) (bool, error) {
|
||||
var count int64
|
||||
db := orm.GetDB().Table(m.TableName())
|
||||
|
||||
if len(params) > 0 {
|
||||
for k, v := range params {
|
||||
db = db.Or(fmt.Sprintf("%s = %v AND is_deleted = %d", k, v, model.DeleteStatusForNot))
|
||||
}
|
||||
}
|
||||
err := db.Count(&count).Error
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
// Patent 专利信息
|
||||
func (m *SysPatent) 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.tenant_id AND u.is_deleted = %d",
|
||||
model.NewUserPatent().TableName(), model.DeleteStatusForNot))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*SysPatentInfo, 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 NewSysPatent() *SysPatent {
|
||||
return &SysPatent{model.NewSysPatent()}
|
||||
}
|
11
app/api/admin/model/sys_patent_classify.go
Normal file
11
app/api/admin/model/sys_patent_classify.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysPatentClassify struct {
|
||||
*model.SysPatentClassify
|
||||
}
|
||||
|
||||
func NewSysPatentClassify() *SysPatentClassify {
|
||||
return &SysPatentClassify{model.NewSysPatentClassify()}
|
||||
}
|
11
app/api/admin/model/user_patent.go
Normal file
11
app/api/admin/model/user_patent.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserPatent struct {
|
||||
*model.UserPatent
|
||||
}
|
||||
|
||||
func NewUserPatent() *UserPatent {
|
||||
return &UserPatent{model.NewUserPatent()}
|
||||
}
|
Reference in New Issue
Block a user