feat:完善项目

This commit is contained in:
henry
2022-01-14 17:09:06 +08:00
parent cf68cfbd96
commit 9a41d7ff12
16 changed files with 646 additions and 38 deletions

View File

@ -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)

View 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()}
}

View File

@ -0,0 +1,11 @@
package model
import "SciencesServer/app/common/model"
type SysPatentClassify struct {
*model.SysPatentClassify
}
func NewSysPatentClassify() *SysPatentClassify {
return &SysPatentClassify{model.NewSysPatentClassify()}
}

View File

@ -0,0 +1,11 @@
package model
import "SciencesServer/app/common/model"
type UserPatent struct {
*model.UserPatent
}
func NewUserPatent() *UserPatent {
return &UserPatent{model.NewUserPatent()}
}