feat:完善项目信息
This commit is contained in:
@ -71,7 +71,7 @@ func (*Account) Logout(c *gin.Context) {
|
||||
|
||||
_session := session.NewEnterprise()
|
||||
|
||||
_ = service.NewAuthToken(token).Auth(_session)
|
||||
_ = service.NewAuthToken(token).Auth(config.RedisKeyForAccountEnterprise, _session)
|
||||
|
||||
err := account.NewLogout()(_session).Launch()
|
||||
api.APIResponse(err)(c)
|
||||
|
@ -518,7 +518,7 @@ func (*Technology) Product(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
data, err := technology2.NewProduct()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
List(form.Title, form.Status, form.Page, form.PageSize)
|
||||
Instance(form.Title, form.Status, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
|
@ -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}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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 访问信息
|
||||
|
@ -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("操作错误,无效的身份信息")
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
@ -20,6 +21,39 @@ type TechnologyAchievementInfo struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type TechnologyAchievementInstance struct {
|
||||
TechnologyAchievementInfo
|
||||
Customer string `json:"-"`
|
||||
LeadStandard model.TechnologyProductLeadStandard `json:"lead_standard"`
|
||||
CooperationMode config.TechnologyCooperationMode `json:"cooperation_mode"`
|
||||
Keyword string `json:"-"`
|
||||
CollectCount int `json:"collect_count"`
|
||||
}
|
||||
|
||||
// Instance 成果信息
|
||||
func (m *TechnologyAchievement) Instance(where ...*model.ModelWhere) ([]*TechnologyAchievementInstance, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.title", "a.industry", "v.count AS visit_count", "c.count AS collect_count",
|
||||
"a.customer", "a.lead_standard", "a.cooperation_mode", "a.keyword", "a.created_at").
|
||||
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 a.id = v.object_id",
|
||||
model.NewUserVisit().TableName(), model.UserVisitKindForTechnologyAchievement, 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 a.id = c.object_id",
|
||||
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*TechnologyAchievementInstance, 0)
|
||||
|
||||
if err := db.Order("a.id " + model.OrderModeToDesc).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Achievement 成果信息
|
||||
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
|
@ -84,7 +84,7 @@ func (a *Account) Logout(c *gin.Context) {
|
||||
|
||||
_session := session.NewManage()
|
||||
|
||||
_ = service.NewAuthToken(token).Auth(_session)
|
||||
_ = service.NewAuthToken(token).Auth(config.RedisKeyForAccountManage, _session)
|
||||
|
||||
err := controller.NewAccount()(_session).Logout()
|
||||
APIResponse(err)(c)
|
||||
|
@ -40,7 +40,7 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
|
||||
if !mSysUser.ValidatePassword(password) {
|
||||
return nil, errors.New("密码错误")
|
||||
}
|
||||
_session := service.NewSession()
|
||||
_session := session.NewManage()
|
||||
_session.UID = mSysUser.UUID
|
||||
_session.Name = mSysUser.Name
|
||||
_session.Mobile = mSysUser.Mobile
|
||||
@ -50,8 +50,8 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
|
||||
|
||||
_session.Token = utils.JWTEncrypt(config.SettingInfo.TokenEffectTime, map[string]interface{}{config.TokenForUID: uid})
|
||||
|
||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccount, uid, _session)
|
||||
service.Publish(config.EventForAccountLoginProduce, _session.TenantID, _session.UID, equipment, ip)
|
||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccountManage, uid, _session)
|
||||
service.Publish(config.EventForAccountLoginProduce, 0, _session.UID, equipment, ip)
|
||||
|
||||
return &AccountLoginResponse{Token: _session.Token, EffectTime: config.SettingInfo.TokenEffectTime}, nil
|
||||
}
|
||||
@ -59,7 +59,7 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
|
||||
// Logout 退出请求
|
||||
func (c *Account) Logout() error {
|
||||
if c.Manage != nil && c.UID > 0 {
|
||||
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
|
||||
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccountManage, utils.UintToString(c.UID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user