feat:完善项目信息

This commit is contained in:
henry
2022-01-04 11:59:58 +08:00
parent c3da1ebc51
commit e29371da3e
20 changed files with 357 additions and 62 deletions

View File

@ -51,7 +51,7 @@ func (c *Instance) Login() InstanceLoginCallback {
_session.Identity = params.Identity
_session.SelectIdentity = params.SelectIdentity
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccount, _session.UIDToString(), _session)
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccountEnterprise, _session.UIDToString(), _session)
return &InstanceLoginReturn{Token: token, TokenEffectTime: config.SettingInfo.TokenEffectTime}
}

View File

@ -15,7 +15,7 @@ type LogoutHandle func(session *session.Enterprise) *Logout
func (c *Logout) Launch() error {
if c.Enterprise != nil && c.UID > 0 {
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccountEnterprise, utils.UintToString(c.UID))
}
return nil
}

View File

@ -5,8 +5,10 @@ import (
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/app/session"
"errors"
"strings"
"time"
)
@ -25,6 +27,14 @@ type (
*model.TechnologyAchievementInfo
Industrys []string `json:"industrys"`
}
// AchievementMatchInfo 成果匹配信息
AchievementMatchInfo struct {
ID string `json:"id"`
*model.TechnologyAchievementInstance
Industrys []string `json:"industrys"`
Keywords []string `json:"keywords"`
Customers []string `json:"customers"`
}
// AchievementDetail 成果详情
AchievementDetail struct {
ID string `json:"id"`
@ -69,6 +79,53 @@ func (c *Achievement) Instance(status, page, pageSize int) (*controller.ReturnPa
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Match 匹配信息
func (c *Achievement) Match(title string, industrys, keywords []string) ([]*AchievementMatchInfo, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
achievement := service.NewESAchievement(
service.WithAchievementTitle(params),
service.WithAchievementIndustry(params),
service.WithAchievementKeyword(params),
)
out, err := achievement.Search(0, 0)
if err != nil {
return nil, err
}
ids := make([]uint64, 0)
for _, v := range out.([]interface{}) {
val := v.(*service.ESAchievement)
ids = append(ids, val.ID)
}
achievements := make([]*model.TechnologyAchievementInstance, 0)
mTechnologyAchievement := model.NewTechnologyAchievement()
if achievements, err = mTechnologyAchievement.Instance(model2.NewWhereIn("a.id", ids),
model2.NewWhere("a.shelf_status", model2.ShelfStatusForUp)); err != nil {
return nil, err
}
list := make([]*AchievementMatchInfo, 0)
for _, v := range achievements {
mTechnologyAchievement.Industry = v.Industry
mTechnologyAchievement.Keyword = v.Keyword
mTechnologyAchievement.Customer = v.Customer
list = append(list, &AchievementMatchInfo{
ID: v.GetEncodeID(),
TechnologyAchievementInstance: v,
Industrys: mTechnologyAchievement.GetIndustryAttribute(),
Keywords: mTechnologyAchievement.GetKeywordAttribute(),
Customers: mTechnologyAchievement.GetCustomerAttribute(),
})
}
return list, nil
}
// Detail 详情信息
func (c *Achievement) Detail(id uint64) (*AchievementDetail, error) {
mTechnologyAchievement := model.NewTechnologyAchievement()

View File

@ -5,10 +5,12 @@ import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/api/manage/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/app/session"
"SciencesServer/serve/orm"
"errors"
"gorm.io/gorm"
"strings"
"time"
)
@ -27,6 +29,14 @@ type (
ShelfStatus model2.ShelfStatusKind
Status model2.SysParentStatus
}
// PatentMatchInfo 专利匹配信息
PatentMatchInfo struct {
ID string `json:"id"`
Kind model2.SysParentKind `json:"kind"`
Title string `json:"title"`
Description string `json:"description"`
ApplyAt string `json:"apply_at"`
}
// PatentDetailInfo 专利详细信息
PatentDetailInfo struct {
ID string `json:"id"`
@ -182,6 +192,46 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Search 搜索信息
func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMatchInfo, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
patent := service.NewESPatent(
service.WithPatentTitle(params),
service.WithPatentIndustry(params),
)
out, err := patent.Search(0, 0)
if err != nil {
return nil, err
}
ids := make([]uint64, 0)
for _, v := range out.([]interface{}) {
val := v.(*service.ESAchievement)
ids = append(ids, val.ID)
}
mSysPatent := model.NewSysPatent()
patents := make([]*model2.SysPatent, 0)
if err = model2.ScanFields(mSysPatent.SysPatent, &patents, []string{"id", "kind", "title", "description", "apply_at"}, &model2.ModelWhereOrder{
Where: model2.NewWhereIn("id", ids),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}); err != nil {
return nil, err
}
list := make([]*PatentMatchInfo, 0)
for _, v := range patents {
list = append(list, &PatentMatchInfo{
ID: v.GetEncodeID(), Title: v.Title, Description: v.Description, ApplyAt: v.ApplyAt,
})
}
return list, nil
}
// Detail 详细信息
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
mUserPatent := model.NewUserPatent()

View File

@ -23,7 +23,7 @@ type (
// ProductInfo 产品信息
ProductInfo struct {
ID string `json:"id"`
*model2.TechnologyProduct
*model.TechnologyProductInfo
}
// ProductDetailInfo 产品详细信息
ProductDetailInfo struct {
@ -49,44 +49,60 @@ type (
}
)
// List 列表信息
func (c *Product) List(title string, status, page, pageSize int) ([]*ProductInfo, error) {
var matchHandle = map[int]func(title string, industrys, keywords []string) (interface{}, error){
1: matchAchievement, 2: matchPatent, 3: matchExpect, 4: matchLaboratory, 5: matchCompany,
}
// matchAchievement 成果匹配
func matchAchievement(title string, industrys, keywords []string) (interface{}, error) {
return (&Achievement{}).Match(title, industrys, keywords)
}
// matchPatent 专利匹配
func matchPatent(title string, industrys, keywords []string) (interface{}, error) {
return (&Patent{}).Match(title, industrys, keywords)
}
// matchExpect 专家匹配
func matchExpect(title string, industrys, keywords []string) (interface{}, error) {
return nil, nil
}
// matchLaboratory 实验室匹配
func matchLaboratory(title string, industrys, keywords []string) (interface{}, error) {
return nil, nil
}
// matchCompany 公司匹配
func matchCompany(title string, industrys, keywords []string) (interface{}, error) {
return nil, nil
}
// Instance 列表信息
func (c *Product) Instance(title string, status, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyProduct := model.NewTechnologyProduct()
where := []*model2.ModelWhereOrder{
&model2.ModelWhereOrder{
Where: model2.NewWhere("local", c.local),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
},
&model2.ModelWhereOrder{
Where: model2.NewWhere("uid", c.UID),
},
&model2.ModelWhereOrder{
Where: model2.NewWhere("status", status),
},
}
if title != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("title", title),
})
}
out := make([]*model2.TechnologyProduct, 0)
where := []*model2.ModelWhere{model2.NewWhere("p.uid", c.UID), model2.NewWhere("p.status", status)}
if title != "" {
where = append(where, model2.NewWhereLike("p.title", title))
}
var count int64
if err := model2.PagesFields(mTechnologyProduct.TechnologyProduct, &out, []string{},
page, pageSize, &count, where...); err != nil {
out, err := mTechnologyProduct.Product(page, pageSize, &count, where...)
if err != nil {
return nil, err
}
list := make([]*ProductInfo, 0)
for _, v := range out {
list = append(list, &ProductInfo{
ID: v.GetEncodeID(),
TechnologyProduct: v,
ID: v.GetEncodeID(), TechnologyProductInfo: v,
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 产品详情
@ -110,8 +126,13 @@ func (c *Product) Detail(id uint64) (*ProductDetailInfo, error) {
}
// Match 匹配结果
func (c *Product) Match(id uint64) {
func (c *Product) Match(kind int, title string, industrys, keywords []string) (interface{}, error) {
handle, has := matchHandle[kind]
if !has {
return nil, errors.New("操作错误,未知的匹配模式")
}
return handle(title, industrys, keywords)
}
// Visit 访问信息

View File

@ -236,7 +236,7 @@ func (c *Identity) Switch(identity int) error {
}
c.IdentityUID = mUserIdentity.UUID
c.SelectIdentity = identity
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccountEnterprise, c.UIDToString(), c.Enterprise)
return nil
}
return errors.New("操作错误,无效的身份信息")

View File

@ -17,13 +17,13 @@ type Withdrawal struct {
type WithdrawalHandle func(session *session.Enterprise) *Withdrawal
type (
// WithdrawalBasic 基本信息
WithdrawalBasic struct {
// WithdrawalInfo 基本信息
WithdrawalInfo struct {
ID string `json:"id"`
*model.UserWithdrawalInfo
}
// WithdrawalInfo 提现数据信息
WithdrawalInfo struct {
// WithdrawalPageInfo 提现数据信息
WithdrawalPageInfo struct {
controller.ReturnPages
TotalAmount float64 `json:"total_amount"`
TotalActualAmount float64 `json:"total_actual_amount"`
@ -36,10 +36,10 @@ type (
)
// Instance 数据信息
func (c *Withdrawal) Instance(status int, createdAt string, page, pageSize int) (*WithdrawalInfo, error) {
func (c *Withdrawal) Instance(status int, createdAt string, page, pageSize int) (*WithdrawalPageInfo, error) {
mUserWithdrawal := model.NewUserWithdrawal()
out := new(WithdrawalInfo)
out := new(WithdrawalPageInfo)
where := []*model2.ModelWhere{model2.NewWhere("w.uid", c.UID), model2.NewWhere("w.status", status)}
@ -51,10 +51,10 @@ func (c *Withdrawal) Instance(status int, createdAt string, page, pageSize int)
if err != nil {
return nil, err
}
list := make([]*WithdrawalBasic, 0)
list := make([]*WithdrawalInfo, 0)
for _, v := range ret {
list = append(list, &WithdrawalBasic{ID: v.GetEncodeID(), UserWithdrawalInfo: v})
list = append(list, &WithdrawalInfo{ID: v.GetEncodeID(), UserWithdrawalInfo: v})
}
out.Data = list