fix:修复bug

This commit is contained in:
henry
2022-05-02 14:37:37 +08:00
parent cb4e02e6e3
commit ae823d6aa8
2 changed files with 26 additions and 7 deletions

View File

@ -128,7 +128,12 @@ type (
CooperationMode int `json:"cooperation_mode" form:"cooperation_mode"`
Keywords []string `json:"keywords" form:"keywords"`
Introduce string `json:"introduce" form:"introduce"`
IsSubmit int `json:"is_submit" form:"is_submit"`
Config struct {
VideoFile string `json:"video_file" form:"video_file"` // 视频文件
VideoPrice float64 `json:"video_price" form:"video_price"` // 视频价格
VideoFreeTime int `json:"video_free_time" form:"video_free_time"`
} `json:"config" form:"config"`
IsSubmit int `json:"is_submit" form:"is_submit"`
}
)
@ -761,7 +766,9 @@ func (*Technology) AchievementAdd(c *gin.Context) {
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
Description: form.Description, Introduce: form.Introduce, Industrys: form.Industrys,
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
Customers: form.Customers, Keywords: form.Keywords,
VideoFile: form.Config.VideoFile, VideoPrice: form.Config.VideoPrice, VideoFreeTime: form.Config.VideoFreeTime,
IsSubmit: form.IsSubmit,
})
api.APIResponse(err)(c)
}
@ -780,6 +787,7 @@ func (*Technology) AchievementEdit(c *gin.Context) {
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
Description: form.Description, Introduce: form.Introduce, Industrys: form.Industrys,
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
VideoFile: form.Config.VideoFile, VideoPrice: form.Config.VideoPrice, VideoFreeTime: form.Config.VideoFreeTime,
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
})
api.APIResponse(err)(c)

View File

@ -39,8 +39,9 @@ type (
AchievementDetail struct {
ID string `json:"id"`
*model2.TechnologyAchievement
Customers []string `json:"customers"`
Keywords []string `json:"keywords"`
Customers []string `json:"customers"`
Keywords []string `json:"keywords"`
Config *model2.TechnologyAchievementConfig `json:"config"`
}
// AchievementParams 成果参数信息
AchievementParams struct {
@ -48,7 +49,10 @@ type (
Title, Image, File, Introduce, Description string
Mode, Maturity, LeadStandard, CooperationMode int // 技术成熟度 领先标准 合作模式
Industrys, Customers, Keywords []string // 所属客户 关键词
IsSubmit int // 是否提交审核
VideoFile string // 视频文件
VideoPrice float64 // 视频价格
VideoFreeTime int
IsSubmit int // 是否提交审核
}
)
@ -143,6 +147,7 @@ func (c *Achievement) Detail(id uint64) (*AchievementDetail, error) {
TechnologyAchievement: mTechnologyAchievement.TechnologyAchievement,
Customers: mTechnologyAchievement.GetCustomerAttribute(),
Keywords: mTechnologyAchievement.GetKeywordAttribute(),
Config: mTechnologyAchievement.GetConfigAttribute(),
}, nil
}
@ -178,6 +183,11 @@ func (c *Achievement) Form(params *AchievementParams) error {
mTechnologyAchievement.SetKeywordAttribute(params.Keywords)
mTechnologyAchievement.Introduce = params.Introduce
mTechnologyAchievement.Description = params.Description
mTechnologyAchievement.SetConfigAttribute(&model2.TechnologyAchievementConfig{
VideoFile: params.VideoFile,
VideoPrice: params.VideoPrice,
VideoFreeTime: params.VideoFreeTime,
})
if mTechnologyAchievement.ID > 0 {
mTechnologyAchievement.Status = model2.TechnologyStatusKindForExamining
@ -203,11 +213,12 @@ func (c *Achievement) Shelf(id uint64, status int) error {
return err
} else if !isExist {
return errors.New("操作错误,成果信息不存在或已被删除")
} else if mTechnologyAchievement.UID != c.UID {
return errors.New("无权限操作")
} else if mTechnologyAchievement.ShelfStatus == model2.ShelfStatusKind(status) {
return errors.New("操作错误,无需变更上下架状态")
}
//else if mTechnologyAchievement.UID != c.UID {
// return errors.New("无权限操作")
//}
if err = model2.Updates(mTechnologyAchievement.TechnologyAchievement, map[string]interface{}{
"shelf_status": status, "updated_at": time.Now(),