|
@@ -16,7 +16,7 @@ type ReportChapterTypeController struct {
|
|
|
// List
|
|
|
// @Title 报告章节列表
|
|
|
// @Description 报告章节列表
|
|
|
-// @Param ReportType query string true "报告类型: day-晨报; week-周报"
|
|
|
+// @Param ClassifyId query int true "所属分类id"
|
|
|
// @Success 200 {object} models.ReportChapterTypePageListResp
|
|
|
// @router /chapter_type/list [get]
|
|
|
func (this *ReportChapterTypeController) List() {
|
|
@@ -33,22 +33,27 @@ func (this *ReportChapterTypeController) List() {
|
|
|
br.Ret = 408
|
|
|
return
|
|
|
}
|
|
|
- reportType := this.GetString("ReportType")
|
|
|
- typeArr := []string{utils.REPORT_TYPE_DAY, utils.REPORT_TYPE_WEEK}
|
|
|
- if !utils.InArrayByStr(typeArr, reportType) {
|
|
|
- br.Msg = "请选择报告类型"
|
|
|
+ classifyId, _ := this.GetInt("ClassifyId", 0)
|
|
|
+ if classifyId <= 0 {
|
|
|
+ br.Msg = "请选择分类"
|
|
|
return
|
|
|
}
|
|
|
- cond := ` AND research_type = ?`
|
|
|
+
|
|
|
+ cond := ` AND report_classify_id = ?`
|
|
|
pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, reportType)
|
|
|
+ pars = append(pars, classifyId)
|
|
|
list, e := models.GetReportChapterTypePageList(cond, pars)
|
|
|
if e != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取报告章节列表失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- mappingList, e := models.GetChapterTypePermissionByResearchType(reportType)
|
|
|
+ chapterTypeIdList := make([]int, 0)
|
|
|
+ for _, v := range list {
|
|
|
+ chapterTypeIdList = append(chapterTypeIdList, v.ReportChapterTypeId)
|
|
|
+ }
|
|
|
+
|
|
|
+ mappingList, e := models.GetChapterTypePermissionByChapterTypeIdList(chapterTypeIdList)
|
|
|
if e != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取章节类型权限列表失败, Err: " + e.Error()
|
|
@@ -116,15 +121,16 @@ func (this *ReportChapterTypeController) Add() {
|
|
|
br.Msg = "请输入章节名称"
|
|
|
return
|
|
|
}
|
|
|
- typeArr := []string{utils.REPORT_TYPE_DAY, utils.REPORT_TYPE_WEEK}
|
|
|
- if !utils.InArrayByStr(typeArr, req.ResearchType) {
|
|
|
- br.Msg = "请选择报告类型"
|
|
|
+
|
|
|
+ if req.ClassifyId <= 0 {
|
|
|
+ br.Msg = "请选择分类"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
// 重名校验
|
|
|
- cond := ` AND report_chapter_type_name = ? AND research_type = ?`
|
|
|
+ cond := ` AND report_chapter_type_name = ? AND report_classify_id = ?`
|
|
|
pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, req.ReportChapterTypeName, req.ResearchType)
|
|
|
+ pars = append(pars, req.ReportChapterTypeName, req.ClassifyId)
|
|
|
exists, e := models.GetReportChapterTypeByCondition(cond, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "操作失败"
|
|
@@ -149,7 +155,8 @@ func (this *ReportChapterTypeController) Add() {
|
|
|
item.Enabled = 1
|
|
|
item.CreatedTime = nowTime
|
|
|
item.LastUpdatedTime = nowTime
|
|
|
- item.ResearchType = req.ResearchType
|
|
|
+ //item.ResearchType = req.ResearchType
|
|
|
+ item.ReportClassifyId = req.ClassifyId
|
|
|
item.IsSet = 0
|
|
|
item.ReportChapterTypeKey = req.ReportChapterTypeName
|
|
|
item.TickerTitle = req.ReportChapterTypeName
|
|
@@ -174,29 +181,20 @@ func (this *ReportChapterTypeController) Add() {
|
|
|
permissionIdName[permissionList[i].ChartPermissionId] = permissionList[i].PermissionName
|
|
|
}
|
|
|
|
|
|
- researchType := item.ResearchType
|
|
|
- newPermissions := make([]*models.ReportChapterTypePermission, 0) // 报告章节权限表(新)
|
|
|
- newWeekPermissions := make([]*models.ChartPermissionChapterMapping, 0) // 报告章节权限表(老)
|
|
|
+ newPermissions := make([]*models.ReportChapterTypePermission, 0) // 报告章节权限表(新)
|
|
|
for i := range req.ChartPermissionIdList {
|
|
|
newPermissions = append(newPermissions, &models.ReportChapterTypePermission{
|
|
|
ReportChapterTypeId: item.ReportChapterTypeId,
|
|
|
ReportChapterTypeName: item.ReportChapterTypeName,
|
|
|
ChartPermissionId: req.ChartPermissionIdList[i],
|
|
|
PermissionName: permissionIdName[req.ChartPermissionIdList[i]],
|
|
|
- ResearchType: researchType,
|
|
|
- CreatedTime: nowTime,
|
|
|
+ //ResearchType: researchType,
|
|
|
+ CreatedTime: nowTime,
|
|
|
})
|
|
|
- if researchType == utils.REPORT_TYPE_WEEK {
|
|
|
- newWeekPermissions = append(newWeekPermissions, &models.ChartPermissionChapterMapping{
|
|
|
- ChartPermissionId: req.ChartPermissionIdList[i],
|
|
|
- ReportChapterTypeId: item.ReportChapterTypeId,
|
|
|
- ResearchType: researchType,
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// 设置权限
|
|
|
- e = models.SetReportChapterTypePermission(item.ReportChapterTypeId, researchType, newPermissions, newWeekPermissions)
|
|
|
+ e = models.SetReportChapterTypePermission(item.ReportChapterTypeId, newPermissions)
|
|
|
if e != nil {
|
|
|
br.Msg = "操作失败"
|
|
|
br.ErrMsg = "设置章节类型权限失败, Err: " + e.Error()
|
|
@@ -211,7 +209,7 @@ func (this *ReportChapterTypeController) Add() {
|
|
|
//todo 同步更新crm章节权限和章节类型
|
|
|
go func() {
|
|
|
var syncReq services.ChapterTypeSyncReq
|
|
|
- syncReq.ResearchType = researchType
|
|
|
+ //syncReq.ResearchType = researchType
|
|
|
syncReq.ReportChapterTypeId = item.ReportChapterTypeId
|
|
|
_, _ = services.ReportChapterTypeSync(&syncReq)
|
|
|
}()
|
|
@@ -254,15 +252,16 @@ func (this *ReportChapterTypeController) Edit() {
|
|
|
br.Msg = "请输入章节名称"
|
|
|
return
|
|
|
}
|
|
|
- typeArr := []string{utils.REPORT_TYPE_DAY, utils.REPORT_TYPE_WEEK}
|
|
|
- if !utils.InArrayByStr(typeArr, req.ResearchType) {
|
|
|
- br.Msg = "请选择报告类型"
|
|
|
+
|
|
|
+ if req.ClassifyId <= 0 {
|
|
|
+ br.Msg = "请选择分类"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
// 重名校验
|
|
|
- cond := ` AND report_chapter_type_name = ? AND research_type = ?`
|
|
|
+ cond := ` AND report_chapter_type_name = ? AND report_classify_id = ?`
|
|
|
pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, req.ReportChapterTypeName, req.ResearchType)
|
|
|
+ pars = append(pars, req.ReportChapterTypeName, req.ClassifyId)
|
|
|
exists, e := models.GetReportChapterTypeByCondition(cond, pars)
|
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "操作失败"
|
|
@@ -297,29 +296,20 @@ func (this *ReportChapterTypeController) Edit() {
|
|
|
permissionIdName[permissionList[i].ChartPermissionId] = permissionList[i].PermissionName
|
|
|
}
|
|
|
|
|
|
- researchType := item.ResearchType
|
|
|
- newPermissions := make([]*models.ReportChapterTypePermission, 0) // 报告章节权限表(新)
|
|
|
- newWeekPermissions := make([]*models.ChartPermissionChapterMapping, 0) // 报告章节权限表(老)
|
|
|
+ newPermissions := make([]*models.ReportChapterTypePermission, 0) // 报告章节权限表(新)
|
|
|
for i := range req.ChartPermissionIdList {
|
|
|
newPermissions = append(newPermissions, &models.ReportChapterTypePermission{
|
|
|
ReportChapterTypeId: item.ReportChapterTypeId,
|
|
|
ReportChapterTypeName: item.ReportChapterTypeName,
|
|
|
ChartPermissionId: req.ChartPermissionIdList[i],
|
|
|
PermissionName: permissionIdName[req.ChartPermissionIdList[i]],
|
|
|
- ResearchType: researchType,
|
|
|
- CreatedTime: nowTime,
|
|
|
+ //ResearchType: researchType,
|
|
|
+ CreatedTime: nowTime,
|
|
|
})
|
|
|
- if researchType == utils.REPORT_TYPE_WEEK {
|
|
|
- newWeekPermissions = append(newWeekPermissions, &models.ChartPermissionChapterMapping{
|
|
|
- ChartPermissionId: req.ChartPermissionIdList[i],
|
|
|
- ReportChapterTypeId: item.ReportChapterTypeId,
|
|
|
- ResearchType: researchType,
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// 设置权限
|
|
|
- e = models.SetReportChapterTypePermission(item.ReportChapterTypeId, researchType, newPermissions, newWeekPermissions)
|
|
|
+ e = models.SetReportChapterTypePermission(item.ReportChapterTypeId, newPermissions)
|
|
|
if e != nil {
|
|
|
br.Msg = "操作失败"
|
|
|
br.ErrMsg = "设置章节类型权限失败, Err: " + e.Error()
|
|
@@ -338,9 +328,10 @@ func (this *ReportChapterTypeController) Edit() {
|
|
|
_ = utils.Rc.Delete(key)
|
|
|
}
|
|
|
|
|
|
+ // todo 处理crm那边的报告权限逻辑
|
|
|
go func() {
|
|
|
var syncReq services.ChapterTypeSyncReq
|
|
|
- syncReq.ResearchType = researchType
|
|
|
+ //syncReq.ResearchType = researchType
|
|
|
syncReq.ReportChapterTypeId = item.ReportChapterTypeId
|
|
|
_, _ = services.ReportChapterTypeSync(&syncReq)
|
|
|
}()
|
|
@@ -474,30 +465,21 @@ func (this *ReportChapterTypeController) AuthSetting() {
|
|
|
permissionIdName[permissionList[i].ChartPermissionId] = permissionList[i].PermissionName
|
|
|
}
|
|
|
|
|
|
- researchType := item.ResearchType
|
|
|
nowTime := time.Now().Local()
|
|
|
- newPermissions := make([]*models.ReportChapterTypePermission, 0) // 报告章节权限表(新)
|
|
|
- newWeekPermissions := make([]*models.ChartPermissionChapterMapping, 0) // 报告章节权限表(老)
|
|
|
+ newPermissions := make([]*models.ReportChapterTypePermission, 0) // 报告章节权限表(新)
|
|
|
for i := range req.ChartPermissionIdList {
|
|
|
newPermissions = append(newPermissions, &models.ReportChapterTypePermission{
|
|
|
ReportChapterTypeId: item.ReportChapterTypeId,
|
|
|
ReportChapterTypeName: item.ReportChapterTypeName,
|
|
|
ChartPermissionId: req.ChartPermissionIdList[i],
|
|
|
PermissionName: permissionIdName[req.ChartPermissionIdList[i]],
|
|
|
- ResearchType: researchType,
|
|
|
- CreatedTime: nowTime,
|
|
|
+ //ResearchType: researchType,
|
|
|
+ CreatedTime: nowTime,
|
|
|
})
|
|
|
- if researchType == utils.REPORT_TYPE_WEEK {
|
|
|
- newWeekPermissions = append(newWeekPermissions, &models.ChartPermissionChapterMapping{
|
|
|
- ChartPermissionId: req.ChartPermissionIdList[i],
|
|
|
- ReportChapterTypeId: item.ReportChapterTypeId,
|
|
|
- ResearchType: researchType,
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// 设置权限
|
|
|
- e = models.SetReportChapterTypePermission(item.ReportChapterTypeId, researchType, newPermissions, newWeekPermissions)
|
|
|
+ e = models.SetReportChapterTypePermission(item.ReportChapterTypeId, newPermissions)
|
|
|
if e != nil {
|
|
|
br.Msg = "操作失败"
|
|
|
br.ErrMsg = "设置章节类型权限失败, Err: " + e.Error()
|
|
@@ -546,7 +528,7 @@ func (this *ReportChapterTypeController) PermissionList() {
|
|
|
br.Msg = "章节不存在或已被删除"
|
|
|
return
|
|
|
}
|
|
|
- list, e := models.GetChapterTypePermissionByTypeIdAndResearchType(typeId, item.ResearchType)
|
|
|
+ list, e := models.GetChapterTypePermissionByReportChapterTypeId(typeId)
|
|
|
if e != nil {
|
|
|
br.Msg = "章节不存在或已被删除"
|
|
|
br.ErrMsg = "获取章节类型权限列表失败, Err: " + e.Error()
|