feat:完善项目信息
This commit is contained in:
@ -47,3 +47,28 @@ func (*Manage) CompanyProduct(c *gin.Context) {
|
|||||||
data, err := manage.NewCompany()(nil).Product((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
|
data, err := manage.NewCompany()(nil).Product((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Manage) Expert(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
ExpertID string `json:"expert_id" form:"expert_id" binding:"required"`
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := manage.NewExpert()(nil).Instance((&api.IDStringForm{ID: form.ExpertID}).Convert())
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Manage) ExpertAchievement(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
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).Achievement((&api.IDStringForm{ID: form.ExpertID}).Convert(), form.Page, form.PageSize)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
98
app/api/website/controller/manage/expert.go
Normal file
98
app/api/website/controller/manage/expert.go
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
package manage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Expert struct {
|
||||||
|
*session.Enterprise
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExpertHandle func(session *session.Enterprise) *Expert
|
||||||
|
|
||||||
|
type (
|
||||||
|
// ExpertBasicInfo 基本信息
|
||||||
|
ExpertBasicInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
School string `json:"school"`
|
||||||
|
Major string `json:"major"`
|
||||||
|
Industrys []string `json:"industrys"`
|
||||||
|
Keywords []string `json:"keywords"`
|
||||||
|
PatentTitles []string `json:"patent_titles"`
|
||||||
|
}
|
||||||
|
// ExpertInstanceInfo 专家信息
|
||||||
|
ExpertInstanceInfo struct {
|
||||||
|
ExpertBasicInfo
|
||||||
|
Researchs []string `json:"researchs"`
|
||||||
|
Introduce string `json:"introduce"`
|
||||||
|
}
|
||||||
|
// ExpertAchievementInfo 专家成果信息
|
||||||
|
ExpertAchievementInfo struct {
|
||||||
|
*model.TechnologyAchievementInfo
|
||||||
|
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Instance 专家信息
|
||||||
|
func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
|
||||||
|
mManageExpert := model.NewManageExpert()
|
||||||
|
out, err := mManageExpert.Detail(3, id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ExpertInstanceInfo{
|
||||||
|
ExpertBasicInfo: ExpertBasicInfo{
|
||||||
|
ID: out.GetEncodeID(),
|
||||||
|
Name: out.Name,
|
||||||
|
School: out.School,
|
||||||
|
Major: out.Major,
|
||||||
|
Industrys: out.GetIndustryAttribute(),
|
||||||
|
Keywords: out.GetKeywordAttribute(),
|
||||||
|
PatentTitles: strings.Split(out.PatentTitle, "&&"),
|
||||||
|
},
|
||||||
|
Researchs: out.GetResearchAttribute(),
|
||||||
|
Introduce: out.Introduce,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Expert) Achievement(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
// 查询专家身份下用户信息
|
||||||
|
mUserExpert := model.NewUserExpert()
|
||||||
|
|
||||||
|
uids := make([]*uint64, 0)
|
||||||
|
|
||||||
|
err := model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out := make([]*model.TechnologyAchievementInfo, 0)
|
||||||
|
|
||||||
|
if out, err = mTechnologyAchievement.Achievement(page, pageSize, &count, model2.NewWhereIn("uid", uids)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*ExpertAchievementInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &ExpertAchievementInfo{
|
||||||
|
TechnologyAchievementInfo: v,
|
||||||
|
ChargeInfo: v.GetChargeInfoAttribute(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewExpert() ExpertHandle {
|
||||||
|
return func(session *session.Enterprise) *Expert {
|
||||||
|
return &Expert{session}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import (
|
|||||||
"SciencesServer/app/service"
|
"SciencesServer/app/service"
|
||||||
config2 "SciencesServer/config"
|
config2 "SciencesServer/config"
|
||||||
"errors"
|
"errors"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Search struct{}
|
type Search struct{}
|
||||||
@ -33,12 +34,13 @@ func company(ids []uint64) (interface{}, error) {
|
|||||||
mManageCompany := model.NewManageCompany()
|
mManageCompany := model.NewManageCompany()
|
||||||
out := make([]*model2.ManageCompany, 0)
|
out := make([]*model2.ManageCompany, 0)
|
||||||
|
|
||||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
|
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{"id", "kind", "name", "image", "url", "keyword"},
|
||||||
Where: model2.NewWhereIn("id", ids),
|
&model2.ModelWhereOrder{
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
Where: model2.NewWhereIn("id", ids),
|
||||||
}, &model2.ModelWhereOrder{
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
}, &model2.ModelWhereOrder{
|
||||||
}); err != nil {
|
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
||||||
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list := make([]*CompanyBasicInfo, 0)
|
list := make([]*CompanyBasicInfo, 0)
|
||||||
@ -54,19 +56,28 @@ func company(ids []uint64) (interface{}, error) {
|
|||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// expert 专家信息
|
||||||
func expert(ids []uint64) (interface{}, error) {
|
func expert(ids []uint64) (interface{}, error) {
|
||||||
mManageCompany := model.NewManageCompany()
|
mManageExpert := model.NewManageExpert()
|
||||||
out := make([]*model2.ManageCompany, 0)
|
out, err := mManageExpert.Expert(3, model2.NewWhereIn("e.id", ids))
|
||||||
|
|
||||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &out, []string{}, &model2.ModelWhereOrder{
|
if err != nil {
|
||||||
Where: model2.NewWhereIn("id", ids),
|
|
||||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
|
||||||
}, &model2.ModelWhereOrder{
|
|
||||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
|
||||||
}); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return out, nil
|
list := make([]*ExpertBasicInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &ExpertBasicInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
Name: v.Name,
|
||||||
|
School: v.School,
|
||||||
|
Major: v.Major,
|
||||||
|
Industrys: v.GetIndustryAttribute(),
|
||||||
|
Keywords: v.GetKeywordAttribute(),
|
||||||
|
PatentTitles: strings.Split(v.PatentTitle, "&&"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func research(ids []uint64) (interface{}, error) {
|
func research(ids []uint64) (interface{}, error) {
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SolutionCase 解决方案案例
|
||||||
type SolutionCase struct {
|
type SolutionCase struct {
|
||||||
*session.Enterprise
|
*session.Enterprise
|
||||||
local string
|
local string
|
||||||
|
@ -3,12 +3,76 @@ package model
|
|||||||
import (
|
import (
|
||||||
"SciencesServer/app/common/model"
|
"SciencesServer/app/common/model"
|
||||||
"SciencesServer/serve/orm"
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ManageExpert struct {
|
type ManageExpert struct {
|
||||||
*model.ManageExpert
|
*model.ManageExpert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ManageExpertInfo struct {
|
||||||
|
*model.ManageExpert
|
||||||
|
PatentTitle string `json:"-"`
|
||||||
|
Research string `json:"-"`
|
||||||
|
Introduce string `json:"introduce"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expert 专家信息
|
||||||
|
func (m *ManageExpert) Expert(limit int, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
|
||||||
|
// 专利信息
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
// 用户专利信息
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||||
|
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword",
|
||||||
|
"p.title AS patent_title").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = p.patent_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
|
||||||
|
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||||
|
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||||
|
FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND p.shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||||
|
limit, mUserPatent.TableName(), mSysPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||||
|
Where("e.examine_status = ?", model.ExamineStatusForAgree).
|
||||||
|
Where("e.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*ManageExpertInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Order("e.id " + model.OrderModeToDesc).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail 专家信息
|
||||||
|
func (m *ManageExpert) Detail(limit int, id uint64) (*ManageExpertInfo, error) {
|
||||||
|
// 专利信息
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
// 用户专利信息
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||||
|
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword", "e.research", "e.introduce",
|
||||||
|
"p.title AS patent_title").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = p.patent_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
|
||||||
|
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||||
|
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||||
|
FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND p.shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||||
|
limit, mUserPatent.TableName(), mSysPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||||
|
Where("e.id = ?", id)
|
||||||
|
|
||||||
|
out := new(ManageExpertInfo)
|
||||||
|
|
||||||
|
if err := db.Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Distribution 分布信息
|
// Distribution 分布信息
|
||||||
func (m *ManageExpert) Distribution() ([]*DataAreaDistributionInfo, error) {
|
func (m *ManageExpert) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||||
out := make([]*DataAreaDistributionInfo, 0)
|
out := make([]*DataAreaDistributionInfo, 0)
|
||||||
|
@ -20,11 +20,11 @@ type TechnologyAchievementInfo struct {
|
|||||||
// Achievement 成果信息
|
// Achievement 成果信息
|
||||||
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||||
Select("a.id", "a.title", "a.mode", "a.image", "a.industry", "a.customer", "a.maturity",
|
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
|
||||||
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS v ON a.id = v.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS v ON a.id = v.achievement_id",
|
||||||
model.NewTechnologyAchievementVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewTechnologyAchievementVisit().TableName(), model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS c ON a.id = c.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS c ON a.id = c.achievement_id",
|
||||||
model.NewTechnologyAchievementCollect().TableName(), model.DeleteStatusForNot)).
|
model.NewTechnologyAchievementCollect().TableName(), model.DeleteStatusForNot)).
|
||||||
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
|
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
|
||||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
11
app/api/website/model/user_expert.go
Normal file
11
app/api/website/model/user_expert.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type UserExpert struct {
|
||||||
|
*model.UserExpert
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserExpert() *UserExpert {
|
||||||
|
return &UserExpert{model.NewUserExpert()}
|
||||||
|
}
|
@ -14,6 +14,7 @@ type TechnologyAchievement struct {
|
|||||||
Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"`
|
Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"`
|
||||||
Image
|
Image
|
||||||
File string `gorm:"column:file;type:varchar(255);default:'';comment:证明材料" json:"file"`
|
File string `gorm:"column:file;type:varchar(255);default:'';comment:证明材料" json:"file"`
|
||||||
|
ChargeInfo string `gorm:"column:charge_info;type:varchar(255);default:'';comment:收费信息" json:"charge_info"`
|
||||||
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
|
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
|
||||||
Customer string `gorm:"column:customer;type:varchar(255);default:'';comment:应用客户" json:"-"`
|
Customer string `gorm:"column:customer;type:varchar(255);default:'';comment:应用客户" json:"-"`
|
||||||
Maturity config.TechnologyMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:技术成熟度" json:"maturity"`
|
Maturity config.TechnologyMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:技术成熟度" json:"maturity"`
|
||||||
@ -28,6 +29,13 @@ type TechnologyAchievement struct {
|
|||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TechnologyAchievementChargeInfo 成果收费参数信息
|
||||||
|
type TechnologyAchievementChargeInfo struct {
|
||||||
|
VideoFile string `json:"video_file"` // 视频文件
|
||||||
|
VideoPrice float64 `json:"video_price"` // 视频价格
|
||||||
|
VideoFreeTime int `json:"video_free_time"` // 视频观看免费时长
|
||||||
|
}
|
||||||
|
|
||||||
// TechnologyAchievementMode 技术成本模式
|
// TechnologyAchievementMode 技术成本模式
|
||||||
type TechnologyAchievementMode int
|
type TechnologyAchievementMode int
|
||||||
|
|
||||||
@ -56,6 +64,17 @@ func (m *TechnologyAchievement) TableName() string {
|
|||||||
return "technology_achievement"
|
return "technology_achievement"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *TechnologyAchievement) GetChargeInfoAttribute() *TechnologyAchievementChargeInfo {
|
||||||
|
out := new(TechnologyAchievementChargeInfo)
|
||||||
|
_ = json.Unmarshal([]byte(m.Industry), &out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TechnologyAchievement) SetChargeInfoAttribute(value *TechnologyAchievementChargeInfo) {
|
||||||
|
_bytes, _ := json.Marshal(value)
|
||||||
|
m.ChargeInfo = string(_bytes)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *TechnologyAchievement) GetIndustryAttribute() []string {
|
func (m *TechnologyAchievement) GetIndustryAttribute() []string {
|
||||||
out := make([]string, 0)
|
out := make([]string, 0)
|
||||||
_ = json.Unmarshal([]byte(m.Industry), &out)
|
_ = json.Unmarshal([]byte(m.Industry), &out)
|
||||||
|
@ -73,6 +73,8 @@ func registerAPI(app *gin.Engine) {
|
|||||||
manageV1.POST("/search", _api.Search)
|
manageV1.POST("/search", _api.Search)
|
||||||
manageV1.POST("/company", _api.Company)
|
manageV1.POST("/company", _api.Company)
|
||||||
manageV1.POST("/company/product", _api.CompanyProduct)
|
manageV1.POST("/company/product", _api.CompanyProduct)
|
||||||
|
manageV1.POST("/expert", _api.Expert)
|
||||||
|
manageV1.POST("/expert/achievement", _api.ExpertAchievement)
|
||||||
}
|
}
|
||||||
//Technology 技术信息管理
|
//Technology 技术信息管理
|
||||||
technologyV1 := v1.Group("/technology")
|
technologyV1 := v1.Group("/technology")
|
||||||
|
Reference in New Issue
Block a user