feat:完善项目信息

This commit is contained in:
henry
2021-12-27 11:12:37 +08:00
parent 41aa6f337c
commit 4926c5b765
9 changed files with 96 additions and 44 deletions

View File

@ -33,10 +33,10 @@ func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model
db := orm.GetDB().Table(m.TableName()+" e").
Select("e.id", "e.name", "e.mobile", "e.industry", "v.count AS visit_count", "c.count AS collect_count",
"e.examine_at AS settled_at").
Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS v ON e.id = v.expert_id",
model.NewManageExpertVisit().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT expert_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY expert_id) AS c ON e.id = c.expert_id",
model.NewManageExpertCollect().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON e.id = v.object_id",
model.NewUserVisit().TableName(), model.UserVisitKindForExpert, model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON e.id = c.object_id",
model.NewUserCollect().TableName(), model.UserCollectKindForExpert, model.DeleteStatusForNot)).
Where("e.examine_status = ? AND e.is_deleted = ?", model.ExamineStatusForAgree, model.DeleteStatusForNot)
if len(where) > 0 {

View File

@ -101,27 +101,27 @@ func (*Manage) ExpertPatent(c *gin.Context) {
func (*Manage) ExpertPaper(c *gin.Context) {
form := &struct {
PaperID string `json:"paper_id" form:"paper_id" binding:"required"`
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewExpert()(nil).Paper((&api.IDStringForm{ID: form.PaperID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewExpert()(nil).Paper((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Manage) ExpertCooperate(c *gin.Context) {
form := &struct {
CompanyID string `json:"company_id" form:"company_id" binding:"required"`
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewExpert()(nil).Cooperate((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewExpert()(nil).Cooperate((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
@ -138,78 +138,78 @@ func (*Manage) ExpertCooperateDetail(c *gin.Context) {
func (*Manage) Laboratory(c *gin.Context) {
form := &struct {
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Instance((&api.IDStringForm{ID: form.ExpertID}).Convert())
data, err := manage.NewLaboratory()(nil).Instance((&api.IDStringForm{ID: form.LaboratoryID}).Convert())
api.APIResponse(err, data)(c)
}
func (*Manage) LaboratoryAchievement(c *gin.Context) {
form := &struct {
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Achievement((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewLaboratory()(nil).Achievement((&api.IDStringForm{ID: form.LaboratoryID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Manage) LaboratoryProject(c *gin.Context) {
form := &struct {
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Project((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewLaboratory()(nil).Project((&api.IDStringForm{ID: form.LaboratoryID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Manage) LaboratoryPatent(c *gin.Context) {
form := &struct {
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Patent((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewLaboratory()(nil).Patent((&api.IDStringForm{ID: form.LaboratoryID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Manage) LaboratoryPaper(c *gin.Context) {
form := &struct {
PaperID string `json:"paper_id" form:"paper_id" binding:"required"`
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Paper((&api.IDStringForm{ID: form.PaperID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewLaboratory()(nil).Paper((&api.IDStringForm{ID: form.LaboratoryID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Manage) LaboratoryCooperate(c *gin.Context) {
form := &struct {
CompanyID string `json:"company_id" form:"company_id" binding:"required"`
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Cooperate((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
data, err := manage.NewLaboratory()(nil).Cooperate((&api.IDStringForm{ID: form.LaboratoryID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
@ -223,3 +223,16 @@ func (*Manage) LaboratoryCooperateDetail(c *gin.Context) {
data, err := manage.NewLaboratory()(nil).CooperateDetail(form.Convert())
api.APIResponse(err, data)(c)
}
func (*Manage) LaboratoryEquipment(c *gin.Context) {
form := &struct {
LaboratoryID string `json:"laboratory_id" form:"laboratory_id" binding:"required"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := manage.NewLaboratory()(nil).Equipment((&api.IDStringForm{ID: form.LaboratoryID}).Convert(), form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}

View File

@ -45,6 +45,10 @@ type (
Patent []*technology.PatentInfo `json:"patent"`
Paper []*technology.PaperInfo `json:"paper"`
}
EquipmentInfo struct {
ID string `json:"id"`
*model2.ManageEquipment
}
)
// achievement 技术成果信息
@ -222,3 +226,28 @@ func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
}
return out, nil
}
// equipment 设备信息
func equipment(kind model2.ManageEquipmentKind, uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
mManageEquipment := model.NewManageEquipment()
out := make([]*model2.ManageEquipment, 0)
var count int64
if err := model2.Pages(mManageEquipment.ManageEquipment, &out, page, pageSize, &count, &model2.ModelWhereOrder{
Where: model2.NewWhere("kind", kind),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{Where: model2.NewWhereIn("uid", uids)}); err != nil {
return nil, err
}
list := make([]*EquipmentInfo, 0)
for _, v := range out {
list = append(list, &EquipmentInfo{
ID: v.GetEncodeID(),
ManageEquipment: v,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -128,6 +128,17 @@ func (c *Laboratory) CooperateDetail(id uint64) (*CooperateDetailInfo, error) {
return cooperateDetail(id)
}
// Equipment 设备信息
func (c *Laboratory) Equipment(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
// 查询专家身份下用户信息
uids, err := c.expert(id)
if err != nil {
return nil, err
}
return equipment(model2.ManageEquipmentKindForExperiment, uids, page, pageSize)
}
func NewLaboratory() LaboratoryHandle {
return func(session *session.Enterprise) *Laboratory {
return &Laboratory{session}

View File

@ -0,0 +1,12 @@
package model
import "SciencesServer/app/common/model"
// ManageEquipment 设备信息
type ManageEquipment struct {
*model.ManageEquipment
}
func NewManageEquipment() *ManageEquipment {
return &ManageEquipment{model.NewManageEquipment()}
}

View File

@ -1,18 +0,0 @@
package model
// ManageExpertCollect 专家收藏数据模型
type ManageExpertCollect struct {
Model
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
ExpertID uint64 `gorm:"column:expert_id;type:int(11);default:0;comment:专家ID" json:"-"`
ModelDeleted
ModelAt
}
func (m *ManageExpertCollect) TableName() string {
return "manage_expert_collect"
}
func NewManageExpertCollect() *ManageExpertCollect {
return &ManageExpertCollect{}
}

View File

@ -15,6 +15,8 @@ type UserCollectKind int
const (
// UserCollectKindForLaboratory 实验室
UserCollectKindForLaboratory UserCollectKind = iota + 1
// UserCollectKindForExpert 专家
UserCollectKindForExpert
)
func (m *UserCollect) TableName() string {

View File

@ -19,6 +19,8 @@ type UserVisitKind int
const (
// UserVisitKindForLaboratory 实验室
UserVisitKindForLaboratory UserCollectKind = iota + 1
// UserVisitKindForExpert 专家
UserVisitKindForExpert
)
func (m *UserVisit) TableName() string {

View File

@ -81,12 +81,13 @@ func registerAPI(app *gin.Engine) {
manageV1.POST("/expert/cooperate", _api.ExpertCooperate)
manageV1.POST("/expert/cooperate/detail", _api.ExpertCooperateDetail)
manageV1.POST("/laboratory", _api.Laboratory)
manageV1.POST("/laboratory/achievement", _api.ExpertAchievement)
manageV1.POST("/laboratory/project", _api.ExpertProject)
manageV1.POST("/laboratory/patent", _api.ExpertPatent)
manageV1.POST("/laboratory/paper", _api.ExpertPaper)
manageV1.POST("/laboratory/cooperate", _api.ExpertCooperate)
manageV1.POST("/laboratory/cooperate/detail", _api.ExpertCooperateDetail)
manageV1.POST("/laboratory/achievement", _api.LaboratoryAchievement)
manageV1.POST("/laboratory/project", _api.LaboratoryProject)
manageV1.POST("/laboratory/patent", _api.LaboratoryPatent)
manageV1.POST("/laboratory/paper", _api.LaboratoryPaper)
manageV1.POST("/laboratory/cooperate", _api.LaboratoryCooperate)
manageV1.POST("/laboratory/cooperate/detail", _api.LaboratoryCooperateDetail)
manageV1.POST("/laboratory/equipment", _api.LaboratoryEquipment)
}
//Technology 技术信息管理
technologyV1 := v1.Group("/technology")