feat:完善信息

This commit is contained in:
henry
2022-01-26 10:34:29 +08:00
parent 5c1278a500
commit 180f63de42
8 changed files with 83 additions and 63 deletions

View File

@ -4,6 +4,7 @@ import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"time"
)
type ManageResearch struct {
@ -16,12 +17,13 @@ type (
model.Model
Name string `json:"name"`
Code string `json:"code"`
Industry string `json:"industry"`
Research string `json:"research"`
Industry string `json:"-"`
Research string `json:"-"`
ExamineStatus string `json:"examine_status"`
model.Area
TenantProvince string `json:"-"`
TenantCity string `json:"-"`
TenantProvince string `json:"-"`
TenantCity string `json:"-"`
CreatedAt time.Time `json:"created_at"`
}
// ManageResearchDetail 详细信息
ManageResearchDetail struct {
@ -31,13 +33,13 @@ type (
)
// Research 科研机构信息
func (m *ManageResearch) Research(id uint64) (*ManageResearchDetail, error) {
func (m *ManageResearch) Research(id uint64) (*model.ManageResearch, error) {
db := orm.GetDB().Table(m.TableName()+" AS r").
Select("r.*").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("r.id = ?", id)
out := new(ManageResearchDetail)
out := new(model.ManageResearch)
err := db.Scan(out).Error
@ -48,7 +50,7 @@ func (m *ManageResearch) Research(id uint64) (*ManageResearchDetail, error) {
func (m *ManageResearch) Researchs(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageResearchInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS r").
Select("r.id", "r.name", "r.code", "r.industry", "r.research", "r.province", "r.city", "r.district",
"r.examine_status", "t.province AS tenant_province", "t.city AS tenant_city").
"r.examine_status", "t.province AS tenant_province", "t.city AS tenant_city", "r.created_at").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("r.is_deleted = ?", model.DeleteStatusForNot)