feat:完善项目信息
This commit is contained in:
@ -10,6 +10,40 @@ 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").
|
||||
|
Reference in New Issue
Block a user