feat:完善项目信息
This commit is contained in:
@ -166,7 +166,29 @@ func (*Manage) LaboratoryExamine(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (*Manage) Research(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.TenantIDStringForm
|
||||
Name string `json:"name" form:"name"`
|
||||
ExamineStatus int `json:"examine_status" form:"examine_status"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewResearch()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert(), form.Name, form.ExamineStatus, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) ResearchSelect(c *gin.Context) {
|
||||
form := new(api.TenantIDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewResearch()(api.GetSession()(c).(*session.Admin)).Select(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) ResearchExamine(c *gin.Context) {
|
||||
@ -181,6 +203,17 @@ func (*Manage) ResearchExamine(c *gin.Context) {
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Manage) ResearchDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewResearch()(api.GetSession()(c).(*session.Admin)).Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) Agent(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ type (
|
||||
ID string `json:"id"`
|
||||
*model.ManageCompanyInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
Address string `json:"address"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// CompanyDetail 公司企业详细信息
|
||||
@ -68,8 +69,17 @@ func (c *Company) Instance(tenantID uint64, name string, status int, page, pageS
|
||||
for _, v := range out {
|
||||
mManageCompany.Industry = v.Industry
|
||||
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range mManageCompany.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/"))
|
||||
}
|
||||
list = append(list, &CompanyInstance{
|
||||
ID: v.GetEncodeID(), ManageCompanyInfo: v, Industrys: mManageCompany.GetIndustryAttribute(), Area: v.FormatBasic(),
|
||||
ID: v.GetEncodeID(), ManageCompanyInfo: v, Industrys: _industrys,
|
||||
Address: v.FormatBasic(), Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -72,13 +71,16 @@ func (c *Expert) Instance(tenantID uint64, name string, examineStatus int, page,
|
||||
for _, v := range out {
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(v.Industry, ";") {
|
||||
for _, v := range mManageExpert.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/"))
|
||||
}
|
||||
// 研究机构,实验室
|
||||
list = append(list, &ExpertInstance{ID: v.GetEncodeID(), Name: v.Name, Industrys: _industrys,
|
||||
ResearchName: v.ResearchName, LaboratoryName: v.LaboratoryName, ExamineStatus: v.ExamineStatus,
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt, Area: v.FormatBasic(),
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt, Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
128
app/api/admin/controller/manage/research.go
Normal file
128
app/api/admin/controller/manage/research.go
Normal file
@ -0,0 +1,128 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Research struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type ResearchHandle func(session *session.Admin) *Research
|
||||
|
||||
type (
|
||||
// ResearchInstance 科研机构信息
|
||||
ResearchInstance struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageResearchInfo
|
||||
Address string `json:"address"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// ResearchSelect 科研机构筛选信息
|
||||
ResearchSelect struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
// ResearchDetail 科研机构详细信息
|
||||
ResearchDetail struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ManageResearch
|
||||
Area string `json:"area"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Research) Instance(tenantID uint64, name string, examineStatus, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("r.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("r.tenant_id", tenantID))
|
||||
}
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("r.name", name))
|
||||
}
|
||||
if examineStatus > 0 {
|
||||
where = append(where, model2.NewWhere("r.examine_status", examineStatus))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageResearch.Researchs(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchInstance, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ResearchInstance{
|
||||
ID: v.GetEncodeID(), ManageResearchInfo: v,
|
||||
Address: v.FormatBasic(), Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Research) Select(tenantID uint64) ([]*ResearchSelect, error) {
|
||||
if tenantID <= 0 {
|
||||
tenantID = c.TenantID
|
||||
}
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
out := make([]*model2.ManageResearch, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageResearch.ManageResearch, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", tenantID)}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree)}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchSelect, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ResearchSelect{
|
||||
ID: v.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (c *Research) Form() {
|
||||
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Research) Detail(id uint64) (*ResearchDetail, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
out, err := mManageResearch.Research(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.ManageResearch == nil {
|
||||
return nil, errors.New("操作错误,科研机构信息不存在或已被删除")
|
||||
}
|
||||
return &ResearchDetail{
|
||||
ID: out.GetEncodeID(), TenantID: out.GetEncodeTenantID(),
|
||||
ManageResearch: out.ManageResearch, Area: out.FormatBasic(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewResearch() ResearchHandle {
|
||||
return func(session *session.Admin) *Research {
|
||||
return &Research{session}
|
||||
}
|
||||
}
|
@ -12,33 +12,35 @@ type ManageCompany struct {
|
||||
}
|
||||
|
||||
type (
|
||||
// ManageCompanyBasic 公司企业基本信息
|
||||
ManageCompanyBasic struct {
|
||||
*model.ManageCompany
|
||||
model.Area
|
||||
}
|
||||
// ManageCompanyInfo 公司企业信息
|
||||
ManageCompanyInfo struct {
|
||||
model.Model
|
||||
Kind model.ManageCompanyKind `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Industry string `json:"industry"`
|
||||
Industry string `json:"-"`
|
||||
Address string `json:"address"`
|
||||
*model.Examine
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
model.Area
|
||||
TenantProvince string `json:"-"`
|
||||
TenantCity string `json:"-"`
|
||||
}
|
||||
// ManageCompanyDetail 公司企业信息
|
||||
ManageCompanyDetail struct {
|
||||
*model.ManageCompany
|
||||
model.Area
|
||||
}
|
||||
)
|
||||
|
||||
// Company 公司企业信息
|
||||
func (m *ManageCompany) Company(id uint64) (*ManageCompanyBasic, error) {
|
||||
func (m *ManageCompany) Company(id uint64) (*ManageCompanyDetail, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS c").
|
||||
Select("c.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON c.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("c.id = ?", id)
|
||||
|
||||
out := new(ManageCompanyBasic)
|
||||
out := new(ManageCompanyDetail)
|
||||
|
||||
err := db.Scan(out).Error
|
||||
|
||||
@ -47,8 +49,9 @@ func (m *ManageCompany) Company(id uint64) (*ManageCompanyBasic, error) {
|
||||
|
||||
func (m *ManageCompany) Companys(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageCompanyInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS c").
|
||||
Select("c.id", "c.kind", "c.name", "c.code", "c.industry", "c.address", "c.examine_status", "c.created_at",
|
||||
"t.province", "t.city").
|
||||
Select("c.id", "c.kind", "c.name", "c.code", "c.industry", "c.address", "c.examine_status",
|
||||
"c.created_at", "c.province", "c.city",
|
||||
"t.province AS tenant_province", "t.city AS tenant_city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON c.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("c.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
|
@ -11,11 +11,6 @@ type ManageExpert struct {
|
||||
}
|
||||
|
||||
type (
|
||||
// ManageExpertBasic 专家基本信息
|
||||
ManageExpertBasic struct {
|
||||
*model.ManageExpert
|
||||
model.Area
|
||||
}
|
||||
// ManageExpertInfo 专家信息
|
||||
ManageExpertInfo struct {
|
||||
*model.ManageExpert
|
||||
@ -23,17 +18,24 @@ type (
|
||||
ResearchName string `json:"research_name"`
|
||||
LaboratoryName string `json:"laboratory_name"`
|
||||
model.Area
|
||||
TenantProvince string `json:"-"`
|
||||
TenantCity string `json:"-"`
|
||||
}
|
||||
// ManageExpertDetail 专家信息
|
||||
ManageExpertDetail struct {
|
||||
*model.ManageExpert
|
||||
model.Area
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家信息
|
||||
func (m *ManageExpert) Expert(id uint64) (*ManageExpertBasic, error) {
|
||||
func (m *ManageExpert) Expert(id uint64) (*ManageExpertDetail, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||
Select("e.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON e.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("e.id = ?", id)
|
||||
|
||||
out := new(ManageExpertBasic)
|
||||
out := new(ManageExpertDetail)
|
||||
|
||||
err := db.Scan(out).Error
|
||||
|
||||
@ -44,7 +46,8 @@ func (m *ManageExpert) Expert(id uint64) (*ManageExpertBasic, error) {
|
||||
func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||
Select("e.id", "e.name", "e.industry", "r.name AS research_name", "l.name AS laboratory_name",
|
||||
"t.province", "t.city", "e.address", "e.created_at").
|
||||
"e.province", "e.city", "e.address", "e.created_at",
|
||||
"t.province AS tenant_province", "t.city AS tenant_city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS r ON e.research_id = r.id", model.NewManageResearch().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS l ON e.laboratory_id = l.id", model.NewManageLaboratory().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON e.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
|
@ -1,11 +1,73 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageResearch struct {
|
||||
*model.ManageResearch
|
||||
}
|
||||
|
||||
type (
|
||||
// ManageResearchInfo 基本信息
|
||||
ManageResearchInfo struct {
|
||||
model.Model
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Industry string `json:"industry"`
|
||||
Research string `json:"research"`
|
||||
ExamineStatus string `json:"examine_status"`
|
||||
model.Area
|
||||
TenantProvince string `json:"-"`
|
||||
TenantCity string `json:"-"`
|
||||
}
|
||||
// ManageResearchDetail 详细信息
|
||||
ManageResearchDetail struct {
|
||||
*model.ManageResearch
|
||||
model.Area
|
||||
}
|
||||
)
|
||||
|
||||
// Research 科研机构信息
|
||||
func (m *ManageResearch) Research(id uint64) (*ManageResearchDetail, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS r").
|
||||
Select("r.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("r.id = ?", id)
|
||||
|
||||
out := new(ManageResearchDetail)
|
||||
|
||||
err := db.Scan(out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
// Researchs 科研机构信息
|
||||
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").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("r.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
out := make([]*ManageResearchInfo, 0)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("r.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageResearch() *ManageResearch {
|
||||
return &ManageResearch{model.NewManageResearch()}
|
||||
}
|
||||
|
@ -13,11 +13,10 @@ type Area struct {
|
||||
type (
|
||||
// IdentityForCompany 公司附加信息
|
||||
IdentityForCompany struct {
|
||||
Kind int `json:"kind" form:"kind" binding:"required"` // 企业类型
|
||||
Product string `json:"product" form:"product" binding:"required"` // 企业产品
|
||||
Url string `json:"url" form:"url"` // 企业网站
|
||||
License string `json:"license" form:"license" binding:"required"` // 营业执照
|
||||
Directions []string `json:"direction" form:"direction"` // 产品方向
|
||||
Directions []string `json:"directions" form:"directions"` // 产品方向
|
||||
}
|
||||
// IdentityForExpert 专家附加信息
|
||||
IdentityForExpert struct {
|
||||
|
@ -295,6 +295,12 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
manage.POST("/expert/edit", _api.ExpertForm)
|
||||
manage.POST("/expert/detail", _api.ExpertDetail)
|
||||
manage.POST("/expert/examine", _api.ExpertExamine)
|
||||
manage.POST("/research", _api.Research)
|
||||
manage.POST("/research/select", _api.ResearchSelect)
|
||||
//manage.POST("/research/add", _api.ResearchForm)
|
||||
//manage.POST("/research/edit", _api.ResearchForm)
|
||||
manage.POST("/research/detail", _api.ResearchDetail)
|
||||
manage.POST("/research/examine", _api.ResearchExamine)
|
||||
}
|
||||
// Service 服务管理
|
||||
service := v1.Group("/service")
|
||||
|
Reference in New Issue
Block a user