Files
2021-12-14 09:05:47 +08:00

46 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"time"
)
type ManageCompany struct {
*model.ManageCompany
}
// ManageCompanyInfo 公司信息,包含公司下需求信息
type ManageCompanyInfo struct {
model.Model
Name string `json:"name"`
SettledAt time.Time `json:"settled_at"`
}
func (m *ManageCompany) Company(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageCompanyInfo, error) {
// TODO未完成功能
db := orm.GetDB().Table(m.TableName()+" AS c").
Select("c.id", "c.name", "c.industry", "c.examine_at AS settled_at").
Joins(fmt.Sprintf("LEFT JOIN (SELECT * FROM %s AS u_c)"))
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*ManageCompanyInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("c.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func NewManageCompany() *ManageCompany {
return &ManageCompany{model.NewManageCompany()}
}