|
@@ -5,7 +5,6 @@ import (
|
|
|
"eta/eta_api/models"
|
|
|
"eta/eta_api/services"
|
|
|
"eta/eta_api/utils"
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -40,53 +39,15 @@ func (this *ReportChapterTypeController) List() {
|
|
|
br.Msg = "请选择报告类型"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- pageSize, _ := this.GetInt("PageSize")
|
|
|
- currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
- var startSize int
|
|
|
- if pageSize <= 0 {
|
|
|
- pageSize = utils.PageSize20
|
|
|
- }
|
|
|
- if currentIndex <= 0 {
|
|
|
- currentIndex = 1
|
|
|
- }
|
|
|
- startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
-
|
|
|
- cond := ` AND research_type = ?`
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, reportType)
|
|
|
- total, e := models.GetReportChapterTypeCount(cond, pars)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取报告章节列表总数失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- list, e := models.GetReportChapterTypePageList(cond, pars, startSize, pageSize)
|
|
|
+ var req services.ChapterTypeReq
|
|
|
+ req.ReportType = reportType
|
|
|
+ resp, e := services.GetReportChapterType(req)
|
|
|
if e != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取报告章节列表失败, Err: " + e.Error()
|
|
|
+ br.ErrMsg = "获取章节列表失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- respList := make([]*models.ReportChapterTypeListItem, 0)
|
|
|
- for i := range list {
|
|
|
- respList = append(respList, &models.ReportChapterTypeListItem{
|
|
|
- ReportChapterTypeId: list[i].ReportChapterTypeId,
|
|
|
- ReportChapterTypeName: list[i].ReportChapterTypeName,
|
|
|
- Sort: list[i].Sort,
|
|
|
- CreatedTime: list[i].CreatedTime.Format(utils.FormatDateTime),
|
|
|
- ResearchType: list[i].ResearchType,
|
|
|
- SelectedImage: list[i].SelectedImage,
|
|
|
- UnselectedImage: list[i].UnselectedImage,
|
|
|
- WordsImage: list[i].YbBottomIcon, // 此处的不一样
|
|
|
- EditImgUrl: list[i].EditImgUrl,
|
|
|
- IsShow: list[i].IsShow,
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
- resp := new(models.ReportChapterTypePageListResp)
|
|
|
- page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
- resp.List = respList
|
|
|
- resp.Paging = page
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
@@ -129,48 +90,12 @@ func (this *ReportChapterTypeController) Add() {
|
|
|
return
|
|
|
}
|
|
|
// 重名校验
|
|
|
- cond := ` AND report_chapter_type_name = ? AND research_type = ?`
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, req.ReportChapterTypeName, req.ResearchType)
|
|
|
- exists, e := models.GetReportChapterTypeByCondition(cond, pars)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "获取重名报告章节失败, Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if exists != nil {
|
|
|
- br.Msg = "章节名称已存在"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- nowTime := time.Now().Local()
|
|
|
- item := new(models.ReportChapterType)
|
|
|
- item.ReportChapterTypeName = req.ReportChapterTypeName
|
|
|
- item.Sort = req.Sort
|
|
|
- item.Enabled = 1
|
|
|
- item.CreatedTime = nowTime
|
|
|
- item.LastUpdatedTime = nowTime
|
|
|
- item.ResearchType = req.ResearchType
|
|
|
- item.ReportChapterTypeName = req.ReportChapterTypeName
|
|
|
- item.SelectedImage = req.SelectedImage
|
|
|
- item.UnselectedImage = req.UnselectedImage
|
|
|
- item.PcSelectedImage = req.SelectedImage
|
|
|
- item.PcUnselectedImage = req.UnselectedImage
|
|
|
- item.EditImgUrl = req.EditImgUrl
|
|
|
- item.IsSet = 0
|
|
|
- item.YbIconUrl = req.UnselectedImage
|
|
|
- item.YbBottomIcon = req.WordsImage
|
|
|
- item.IsShow = req.IsShow
|
|
|
- item.ReportChapterTypeThumb = req.EditImgUrl
|
|
|
- item.BannerUrl = req.UnselectedImage
|
|
|
- item.ReportChapterTypeKey = req.ReportChapterTypeName
|
|
|
- item.TickerTitle = req.ReportChapterTypeName
|
|
|
- if e = item.Create(); e != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "新增报告章节失败, Err:" + e.Error()
|
|
|
+ e, msg := services.AddReportChapterType(&req)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = msg
|
|
|
+ br.ErrMsg = "新增章节失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
// 清除小程序端的章节缓存
|
|
|
{
|
|
|
key := "hongze_yb:report_chapter_type:GetEffectTypeID"
|
|
@@ -221,58 +146,16 @@ func (this *ReportChapterTypeController) Edit() {
|
|
|
br.Msg = "请选择报告类型"
|
|
|
return
|
|
|
}
|
|
|
- // 重名校验
|
|
|
- cond := ` AND report_chapter_type_name = ? AND research_type = ?`
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, req.ReportChapterTypeName, req.ResearchType)
|
|
|
- exists, e := models.GetReportChapterTypeByCondition(cond, pars)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "获取重名报告章节失败, Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if exists != nil && exists.ReportChapterTypeId != req.ReportChapterTypeId {
|
|
|
- br.Msg = "章节名称已存在"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- item, e := models.GetReportChapterTypeById(req.ReportChapterTypeId)
|
|
|
+ ret, e, msg := services.EditReportChapterType(&req)
|
|
|
if e != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "获取报告章节失败, Err:" + e.Error()
|
|
|
+ br.Msg = msg
|
|
|
+ br.ErrMsg = "编辑章节失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- originName := item.ReportChapterTypeName
|
|
|
-
|
|
|
- item.ReportChapterTypeName = req.ReportChapterTypeName
|
|
|
- item.Sort = req.Sort
|
|
|
- item.ResearchType = req.ResearchType
|
|
|
- item.SelectedImage = req.SelectedImage
|
|
|
- item.UnselectedImage = req.UnselectedImage
|
|
|
- item.PcSelectedImage = req.SelectedImage
|
|
|
- item.PcUnselectedImage = req.UnselectedImage
|
|
|
- item.EditImgUrl = req.EditImgUrl
|
|
|
- item.YbIconUrl = req.UnselectedImage
|
|
|
- item.YbBottomIcon = req.WordsImage
|
|
|
- item.IsShow = req.IsShow
|
|
|
- item.ReportChapterTypeThumb = req.EditImgUrl
|
|
|
- item.BannerUrl = req.UnselectedImage
|
|
|
- item.ReportChapterTypeKey = req.ReportChapterTypeName
|
|
|
- item.TickerTitle = req.ReportChapterTypeName
|
|
|
- updateCols := []string{"ReportChapterTypeName", "Sort", "ResearchType", "SelectedImage", "UnselectedImage",
|
|
|
- "PcSelectedImage", "PcUnselectedImage", "EditImgUrl", "YbIconUrl", "YbBottomIcon", "IsShow",
|
|
|
- "ReportChapterTypeThumb", "BannerUrl", "ReportChapterTypeKey", "TickerTitle",
|
|
|
- }
|
|
|
- if e = item.Update(updateCols); e != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "更新报告章节失败, Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
// 更新研报章节表冗余
|
|
|
- if originName != req.ReportChapterTypeName {
|
|
|
+ if ret.OriginReportChapterTypeName != req.ReportChapterTypeName {
|
|
|
go func() {
|
|
|
- _ = models.UpdateReportChapterTypeNameByTypeId(item.ReportChapterTypeId, req.ReportChapterTypeName)
|
|
|
+ _ = models.UpdateReportChapterTypeNameByTypeId(req.ReportChapterTypeId, req.ReportChapterTypeName)
|
|
|
}()
|
|
|
}
|
|
|
|
|
@@ -502,3 +385,97 @@ func (this *ReportChapterTypeController) PermissionList() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = respList
|
|
|
}
|
|
|
+
|
|
|
+// Move
|
|
|
+// @Title 移动章节类型
|
|
|
+// @Description 移动章节类型
|
|
|
+// @Param request body models.PermissionMoveReq true "type json string"
|
|
|
+// @Success 200 Ret=200 操作成功
|
|
|
+// @router /chapter_type/move [post]
|
|
|
+func (this *ReportChapterTypeController) Move() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var req models.ReportChapterTypeMoveReq
|
|
|
+ if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.ReportChapterTypeId == 0 {
|
|
|
+ br.Msg = "请选择要移动的章节类型"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e, msg := services.MoveReportChapterType(&req)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = msg
|
|
|
+ br.ErrMsg = "移动品种失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|
|
|
+
|
|
|
+// SetEnabled
|
|
|
+// @Title 设置启用/禁用
|
|
|
+// @Description 移动章节类型
|
|
|
+// @Param request body models.PermissionMoveReq true "type json string"
|
|
|
+// @Success 200 Ret=200 操作成功
|
|
|
+// @router /chapter_type/enabled/set [post]
|
|
|
+func (this *ReportChapterTypeController) SetEnabled() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var req models.ReportChapterTypeEnabledReq
|
|
|
+ if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.ReportChapterTypeId == 0 {
|
|
|
+ br.Msg = "请选择正确的章节类型"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.Enabled != 0 && req.Enabled != 1 {
|
|
|
+ br.Msg = "请选择正确的启用禁用状态"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e := services.SetEnabledReportChapterType(&req)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "设置报告章节状态失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|