feat:完善项目信息
This commit is contained in:
@ -98,3 +98,40 @@ func (*Manage) ExpertPatent(c *gin.Context) {
|
|||||||
data, err := manage.NewExpert()(nil).Patent((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
|
data, err := manage.NewExpert()(nil).Patent((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Manage) ExpertPaper(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
PaperID string `json:"paper_id" form:"paper_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)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Manage) ExpertCompany(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
CompanyID string `json:"company_id" form:"company_id" binding:"required"`
|
||||||
|
api.PageForm
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := manage.NewExpert()(nil).Company((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Manage) ExpertCompanyDetail(c *gin.Context) {
|
||||||
|
form := new(api.IDStringForm)
|
||||||
|
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := manage.NewExpert()(nil).CompanyDetail(form.Convert())
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package manage
|
package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"SciencesServer/app/api/website/controller/technology"
|
||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,13 +48,25 @@ type (
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.PatentInfo
|
*model.PatentInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpertPaperInfo 论文信息
|
// ExpertPaperInfo 论文信息
|
||||||
ExpertPaperInfo struct {
|
ExpertPaperInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model2.TechnologyPaper
|
*model2.TechnologyPaper
|
||||||
Keywords []string `json:"keywords"`
|
Keywords []string `json:"keywords"`
|
||||||
}
|
}
|
||||||
|
// ExpertCompanyInfo 合作企业信息
|
||||||
|
ExpertCompanyInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
PatentCount int `json:"patent_count"`
|
||||||
|
PaperCount int `json:"paper_count"`
|
||||||
|
}
|
||||||
|
// ExpertCompanyDetailInfo 合作企业详细信息
|
||||||
|
ExpertCompanyDetailInfo struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Patent []*technology.PatentInfo `json:"patent"`
|
||||||
|
Paper []*technology.PaperInfo `json:"paper"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Expert) user(id uint64) ([]uint64, error) {
|
func (c *Expert) user(id uint64) ([]uint64, error) {
|
||||||
@ -208,6 +222,92 @@ func (c *Expert) Paper(id uint64, page, pageSize int) (*controller.ReturnPages,
|
|||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Company 企业信息
|
||||||
|
func (c *Expert) Company(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
// 查询专家身份下用户信息
|
||||||
|
uids, err := c.user(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mUserCooperateEnterprise := model.NewUserCooperateEnterprise()
|
||||||
|
|
||||||
|
out := make([]*model2.UserCooperateEnterprise, 0)
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if err = model2.PagesFields(mUserCooperateEnterprise.UserCooperateEnterprise, &out, []string{"id", "title", "paper", "patent"},
|
||||||
|
page, pageSize, &count, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhereIn("uid", uids),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("kind", model2.UserCooperateEnterpriseModeForCooperateAlready)}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*ExpertCompanyInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &ExpertCompanyInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
Title: v.Title,
|
||||||
|
PatentCount: len(v.GetPatentAttribute()),
|
||||||
|
PaperCount: len(v.GetPaperAttribute()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompanyDetail 公司企业详细信息
|
||||||
|
func (c *Expert) CompanyDetail(id uint64) (*ExpertCompanyDetailInfo, error) {
|
||||||
|
mUserCooperateEnterprise := model.NewUserCooperateEnterprise()
|
||||||
|
mUserCooperateEnterprise.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserCooperateEnterprise.UserCooperateEnterprise, []string{"id", "title", "paper", "patent"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,企业信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
out := &ExpertCompanyDetailInfo{
|
||||||
|
Title: mUserCooperateEnterprise.Title,
|
||||||
|
Patent: make([]*technology.PatentInfo, 0),
|
||||||
|
Paper: make([]*technology.PaperInfo, 0),
|
||||||
|
}
|
||||||
|
// 专利信息
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
|
||||||
|
patents := make([]*model.SysPatentInfo, 0)
|
||||||
|
|
||||||
|
if patents, err = mSysPatent.Instance(model2.NewWhereIn("p.id", mUserCooperateEnterprise.GetPatentAttribute())); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range patents {
|
||||||
|
out.Patent = append(out.Patent, &technology.PatentInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
SysPatentInfo: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 论文信息
|
||||||
|
mTechnologyPaper := model.NewTechnologyPaper()
|
||||||
|
|
||||||
|
papers := make([]*model2.TechnologyPaper, 0)
|
||||||
|
|
||||||
|
if err = model2.ScanFields(mTechnologyPaper.TechnologyPaper, &papers, []string{"id", "title", "ext", "keyword"},
|
||||||
|
&model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhereIn("id", mUserCooperateEnterprise.GetPaperAttribute()),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range papers {
|
||||||
|
out.Paper = append(out.Paper, &technology.PaperInfo{
|
||||||
|
ID: v.GetEncodeID(), Title: v.Title, Ext: v.Ext, Keywords: v.GetKeywordAttribute(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func NewExpert() ExpertHandle {
|
func NewExpert() ExpertHandle {
|
||||||
return func(session *session.Enterprise) *Expert {
|
return func(session *session.Enterprise) *Expert {
|
||||||
return &Expert{session}
|
return &Expert{session}
|
||||||
|
12
app/api/website/controller/technology/paper.go
Normal file
12
app/api/website/controller/technology/paper.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package technology
|
||||||
|
|
||||||
|
type Paper struct{}
|
||||||
|
|
||||||
|
type (
|
||||||
|
PaperInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Ext string `json:"ext"`
|
||||||
|
Keywords []string `json:"keywords"`
|
||||||
|
}
|
||||||
|
)
|
@ -18,6 +18,28 @@ type SysPatentInfo struct {
|
|||||||
ApplyAt string `json:"apply_at"`
|
ApplyAt string `json:"apply_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Instance 专利信息
|
||||||
|
func (m *SysPatent) Instance(where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||||
|
Select("p.id", "p.title", "LEFT(p.description, 80) AS description", "p.apply_at").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON p.ipc_code = c.ipc AND c.is_deleted = %d",
|
||||||
|
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||||
|
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||||
|
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*SysPatentInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Patent 专利信息
|
// Patent 专利信息
|
||||||
func (m *SysPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
func (m *SysPatent) Patent(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysPatentInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||||
|
@ -1,11 +1,38 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
)
|
||||||
|
|
||||||
type TechnologyPaper struct {
|
type TechnologyPaper struct {
|
||||||
*model.TechnologyPaper
|
*model.TechnologyPaper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
TechnologyPaperInfo struct {
|
||||||
|
model.Model
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (m *TechnologyPaper) Instance(where ...*model.ModelWhere) ([]*TechnologyPaperInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()).
|
||||||
|
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||||
|
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*TechnologyPaperInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func NewTechnologyPaper() *TechnologyPaper {
|
func NewTechnologyPaper() *TechnologyPaper {
|
||||||
return &TechnologyPaper{model.NewTechnologyPaper()}
|
return &TechnologyPaper{model.NewTechnologyPaper()}
|
||||||
}
|
}
|
||||||
|
11
app/api/website/model/user_cooperate_enterprise.go
Normal file
11
app/api/website/model/user_cooperate_enterprise.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type UserCooperateEnterprise struct {
|
||||||
|
*model.UserCooperateEnterprise
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserCooperateEnterprise() *UserCooperateEnterprise {
|
||||||
|
return &UserCooperateEnterprise{model.NewUserCooperateEnterprise()}
|
||||||
|
}
|
@ -75,6 +75,11 @@ func registerAPI(app *gin.Engine) {
|
|||||||
manageV1.POST("/company/product", _api.CompanyProduct)
|
manageV1.POST("/company/product", _api.CompanyProduct)
|
||||||
manageV1.POST("/expert", _api.Expert)
|
manageV1.POST("/expert", _api.Expert)
|
||||||
manageV1.POST("/expert/achievement", _api.ExpertAchievement)
|
manageV1.POST("/expert/achievement", _api.ExpertAchievement)
|
||||||
|
manageV1.POST("/expert/project", _api.ExpertProject)
|
||||||
|
manageV1.POST("/expert/patent", _api.ExpertPatent)
|
||||||
|
manageV1.POST("/expert/paper", _api.ExpertPaper)
|
||||||
|
manageV1.POST("/expert/company", _api.ExpertCompany)
|
||||||
|
manageV1.POST("/expert/company/detail", _api.ExpertCompanyDetail)
|
||||||
}
|
}
|
||||||
//Technology 技术信息管理
|
//Technology 技术信息管理
|
||||||
technologyV1 := v1.Group("/technology")
|
technologyV1 := v1.Group("/technology")
|
||||||
|
Reference in New Issue
Block a user