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 上下架操作
|
||||
|
Reference in New Issue
Block a user