feat:优化项目信息
This commit is contained in:
@ -9,7 +9,6 @@ import (
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -152,7 +151,6 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println(utils.AnyToJSON(other))
|
||||
mManageExpert.TenantID = c.TenantID
|
||||
mManageExpert.ResearchID = other.ConvertResearch()
|
||||
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
||||
|
@ -2,10 +2,13 @@ package technology
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Achievement struct {
|
||||
@ -87,7 +90,8 @@ func (c *Achievement) Examine(id uint64, status int, remark string) error {
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
mTechnologyAchievement.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyAchievement.TechnologyAchievement, []string{"id", "tenant_id", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyAchievement.TechnologyAchievement, []string{"id", "tenant_id", "title",
|
||||
"industry", "keyword", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -100,7 +104,28 @@ func (c *Achievement) Examine(id uint64, status int, remark string) error {
|
||||
if mTechnologyAchievement.Status != model2.TechnologyStatusKindForExamining {
|
||||
return errors.New("操作错误,当前成果状态不允许审核")
|
||||
}
|
||||
return handleExamine(mTechnologyAchievement.TechnologyAchievement, c.UID, model2.SysUserExamineLogKindForAchievement, status, remark)
|
||||
if err = handleExamine(mTechnologyAchievement.TechnologyAchievement, c.UID, model2.SysUserExamineLogKindForAchievement, status, remark, func() error {
|
||||
if model2.ExamineStatusKind(status) == model2.ExamineStatusForAgree {
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range mTechnologyAchievement.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||
}
|
||||
// 存放ES中
|
||||
manage := service.NewESAchievement(
|
||||
service.WithAchievementID(mTechnologyAchievement.ID),
|
||||
service.WithAchievementTitle(mTechnologyAchievement.Title),
|
||||
service.WithAchievementIndustry(strings.Join(_industrys, ";")),
|
||||
service.WithAchievementKeyword(strings.Join(mTechnologyAchievement.GetKeywordAttribute(), ";")),
|
||||
)
|
||||
return manage.Create()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shelf 上下架
|
||||
|
@ -8,7 +8,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineLogKind, status int, remark string) error {
|
||||
type callback func() error
|
||||
|
||||
func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineLogKind, status int, remark string, callback2 callback) error {
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
err := model2.Updates(iModel, map[string]interface{}{
|
||||
"status": status, "updated_at": time.Now(),
|
||||
@ -23,6 +25,13 @@ func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineL
|
||||
mSysUserExamineLog.ObjectID = iModel.GetID()
|
||||
mSysUserExamineLog.Status = status
|
||||
mSysUserExamineLog.Remark = remark
|
||||
return model2.Create(mSysUserExamineLog.SysUserExamineLog, tx)
|
||||
|
||||
if err = model2.Create(mSysUserExamineLog.SysUserExamineLog, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if callback2 != nil {
|
||||
return callback2()
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func (c *Demand) Examine(id uint64, status int, remark string) error {
|
||||
if mTechnologyDemand.Status != model2.TechnologyStatusKindForExamining {
|
||||
return errors.New("操作错误,当前需求状态不允许审核")
|
||||
}
|
||||
return handleExamine(mTechnologyDemand.TechnologyDemand, c.UID, model2.SysUserExamineLogKindForDemandTechnology, status, remark)
|
||||
return handleExamine(mTechnologyDemand.TechnologyDemand, c.UID, model2.SysUserExamineLogKindForDemandTechnology, status, remark, nil)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
|
@ -100,7 +100,7 @@ func (c *Product) Examine(id uint64, status int, remark string) error {
|
||||
if mTechnologyProduct.Status != model2.TechnologyStatusKindForExamining {
|
||||
return errors.New("操作错误,当前产品状态不允许审核")
|
||||
}
|
||||
return handleExamine(mTechnologyProduct.TechnologyProduct, c.UID, model2.SysUserExamineLogKindForProduct, status, remark)
|
||||
return handleExamine(mTechnologyProduct.TechnologyProduct, c.UID, model2.SysUserExamineLogKindForProduct, status, remark, nil)
|
||||
}
|
||||
|
||||
// Shelf 上下架操作
|
||||
|
@ -53,7 +53,7 @@ func (m *TechnologyAchievement) Achievements(page, pageSize int, count *int64, w
|
||||
// Achievement 成果信息
|
||||
func (m *TechnologyAchievement) Achievement(where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
|
||||
Select("a.id", "a.title", "a.mode", "a.image", "a.config", "a.industry", "a.customer", "a.maturity",
|
||||
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
||||
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.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||
|
@ -20,9 +20,6 @@ func (this *ESAchievement) Index() string {
|
||||
}
|
||||
|
||||
func (this *ESAchievement) Create() error {
|
||||
if this.Industry != "" {
|
||||
this.Title = this.Industry + " - " + this.Title
|
||||
}
|
||||
_bytes, _ := json.Marshal(this)
|
||||
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
||||
}
|
||||
|
14
app/service/es_test.go
Normal file
14
app/service/es_test.go
Normal file
@ -0,0 +1,14 @@
|
||||
package service
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestESAchievement_Create(t *testing.T) {
|
||||
manage := NewESAchievement(
|
||||
WithAchievementID(1),
|
||||
WithAchievementTitle("测试一"),
|
||||
WithAchievementIndustry("测试测试"),
|
||||
WithAchievementKeyword("关键词1;关键词2"),
|
||||
)
|
||||
err := manage.Create()
|
||||
t.Log(err)
|
||||
}
|
Reference in New Issue
Block a user