浏览代码

Merge branch 'master' into debug

hsun 1 年之前
父节点
当前提交
91ca673229

+ 0 - 334
controllers/ai/ai.go

@@ -1,334 +0,0 @@
-package ai
-
-import (
-	"encoding/json"
-	"fmt"
-	"hongze/hz_eta_api/controllers"
-	"hongze/hz_eta_api/models"
-	"hongze/hz_eta_api/models/aimod"
-	"hongze/hz_eta_api/services/aiser"
-	"hongze/hz_eta_api/utils"
-	"strconv"
-	"time"
-)
-
-// AI
-type AiController struct {
-	controllers.BaseAuthController
-}
-
-// @Title 聊天接口
-// @Description 聊天接口
-// @Param	request	body aimod.ChatReq true "type json string"
-// @Success 200 {object} response.ListResp
-// @router /chat [post]
-func (this *AiController) List() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	var req aimod.ChatReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
-	if req.Model == "" {
-		br.Msg = "请选择模型!"
-		br.ErrMsg = "请选择模型!"
-		return
-	}
-
-	if req.Ask == "" {
-		br.Msg = "请输入提问内容!"
-		br.ErrMsg = "请输入提问内容"
-		return
-	}
-
-	if utils.Re == nil {
-		key := "CACHE_CHAT_" + strconv.Itoa(this.SysUser.AdminId)
-		cacheVal, err := utils.Rc.RedisInt(key)
-		fmt.Println("RedisString:", cacheVal, "err:", err)
-		if err != nil && err.Error() != "redigo: nil returned" {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "获取数据失败,Err:" + err.Error()
-			return
-		}
-		putVal := 0
-		if cacheVal <= 0 {
-			putVal = utils.AiChatLimit
-		} else {
-			putVal = cacheVal - 1
-		}
-
-		if putVal <= 0 {
-			br.Msg = "您今日50次问答已达上限,请明天再来!"
-			br.ErrMsg = "您今日50次问答已达上限,请明天再来!"
-			return
-		}
-		lastSecond := utils.GetTodayLastSecond()
-		utils.Rc.Put(key, putVal, lastSecond)
-	}
-
-	//根据提问,获取信息
-	askUuid := utils.MD5(req.Ask)
-	chatMode, err := aimod.GetAiChatByAsk(askUuid, req.Model)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取数据失败!"
-		br.ErrMsg = "获取数据失败,GetAiChatByAsk,Err:" + err.Error()
-		return
-	}
-	resp := new(aimod.ChatResp)
-	var answer string
-	//answerArr := []string{
-	//	"周度数据显示,成品油现货市场价格跟随原油下跌,但近期相对抗跌,裂解价差走扩。批零价差方面汽油收窄,柴油走扩",
-	//	"出口利润在原油下跌海外成品油矛盾更大的情况下汽柴油出口窗口完全关闭",
-	//	"汽油需求在经历五一假期的一段高峰后将回归平稳,总体没有明显矛盾,后期我们担心更多的还是柴油。"}
-	if chatMode != nil && chatMode.Answer != "" {
-		answer = chatMode.Answer
-	} else {
-		//rnd := utils.GetRandInt(0, 3)
-		//if rnd >= 3 {
-		//	rnd = 2
-		//}
-		//answer = answerArr[rnd]
-		var model int
-		if req.Model == "gpt-3.5-turbo" {
-			model = 1
-		} else if req.Model == "gpt-3.5-turbo-16k" {
-			model = 3
-		} else {
-			model = 2
-		}
-		answer, _ = aiser.ChatAutoMsg(req.Ask, model)
-	}
-	resp.Ask = req.Ask
-	resp.Answer = answer
-
-	if req.AiChatTopicId <= 0 { //新增
-		topic := new(aimod.AiChatTopic)
-		topic.TopicName = req.Ask
-		topic.SysUserId = this.SysUser.AdminId
-		topic.SysUserRealName = this.SysUser.RealName
-		topic.CreateTime = time.Now()
-		topic.ModifyTime = time.Now()
-		topicId, err := aimod.AddAiChatTopic(topic)
-		if err != nil {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "生成话题失败,Err:" + err.Error()
-			return
-		}
-		resp.AiChatTopicId = int(topicId)
-		chatItem := new(aimod.AiChat)
-		chatItem.AiChatTopicId = resp.AiChatTopicId
-		chatItem.Ask = req.Ask
-		chatItem.AskUuid = utils.MD5(req.Ask)
-		chatItem.Answer = answer
-		chatItem.Model = req.Model
-		chatItem.SysUserId = this.SysUser.AdminId
-		chatItem.SysUserRealName = this.SysUser.RealName
-		chatItem.CreateTime = time.Now()
-		chatItem.ModifyTime = time.Now()
-		_, err = aimod.AddAiChat(chatItem)
-		if err != nil {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
-			return
-		}
-	} else {
-		resp.AiChatTopicId = req.AiChatTopicId
-		chatItem := new(aimod.AiChat)
-		chatItem.AiChatTopicId = resp.AiChatTopicId
-		chatItem.Ask = req.Ask
-		chatItem.AskUuid = utils.MD5(req.Ask)
-		chatItem.Answer = answer
-		chatItem.Model = req.Model
-		chatItem.SysUserId = this.SysUser.AdminId
-		chatItem.SysUserRealName = this.SysUser.RealName
-		chatItem.CreateTime = time.Now()
-		chatItem.ModifyTime = time.Now()
-		_, err = aimod.AddAiChat(chatItem)
-		if err != nil {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
-			return
-		}
-	}
-	resp.Model = req.Model
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
-// @Title 获取话题列表
-// @Description 获取话题列表接口
-// @Success 200 {object} aimod.AiChatTopicListResp
-// @router /topic/list [get]
-func (this *AiController) TopicList() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
-	list, err := aimod.GetAiChatTopicList(sysUser.AdminId)
-	if err != nil {
-		br.Msg = "获取数据失败!"
-		br.ErrMsg = "获取主题记录信息失败,Err:" + err.Error()
-		return
-	}
-	resp := new(aimod.AiChatTopicListResp)
-	resp.List = list
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
-// @Title 获取话题详情
-// @Description 获取话题详情接口
-// @Param   AiChatTopicId   query   int  true       "主题id"
-// @Success 200 {object} aimod.AiChatDetailResp
-// @router /topic/detail [get]
-func (this *AiController) TopicDetail() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
-
-	aiChatTopicId, _ := this.GetInt("AiChatTopicId")
-	list, err := aimod.GetAiChatList(aiChatTopicId)
-	if err != nil {
-		br.Msg = "获取数据失败!"
-		br.ErrMsg = "获取主题记录信息失败,Err:" + err.Error()
-		return
-	}
-	resp := new(aimod.AiChatDetailResp)
-	resp.List = list
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
-// @Title 删除话题接口
-// @Description 删除话题接口
-// @Param	request	body aimod.TopicDeleteReq true "type json string"
-// @Success Ret=200 删除成功
-// @router /topic/delete [post]
-func (this *AiController) TopicDelete() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		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 aimod.TopicDeleteReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
-	if req.AiChatTopicId <= 0 {
-		br.Msg = "参数错误!"
-		br.ErrMsg = "参数错误!AiChatTopicId:" + strconv.Itoa(req.AiChatTopicId)
-		return
-	}
-	err = aimod.DeleteTopic(req.AiChatTopicId)
-	if err != nil {
-		br.Msg = "删除失败!"
-		br.ErrMsg = "删除失败,Err:" + err.Error()
-		return
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "删除成功"
-	br.IsAddLog = true
-}
-
-// @Title 编辑话题接口
-// @Description 编辑话题接口
-// @Param	request	body aimod.TopicEditReq true "type json string"
-// @Success Ret=200 编辑成功
-// @router /topic/edit [post]
-func (this *AiController) TopicEdit() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		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 aimod.TopicEditReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
-	if req.AiChatTopicId <= 0 {
-		br.Msg = "参数错误!"
-		br.ErrMsg = "参数错误!AiChatTopicId:" + strconv.Itoa(req.AiChatTopicId)
-		return
-	}
-	topic, err := aimod.GetAiChatTopicByTopicName(req.TopicName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "编辑失败!"
-		br.ErrMsg = "获取数据失败!Err:" + err.Error()
-		return
-	}
-	if topic != nil && topic.AiChatTopicId != req.AiChatTopicId {
-		br.Msg = "话题名称已存在,请重新修改!"
-		return
-	}
-
-	err = aimod.EditTopic(req.AiChatTopicId, req.TopicName)
-	if err != nil {
-		br.Msg = "编辑失败!"
-		br.ErrMsg = "编辑失败,Err:" + err.Error()
-		return
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "编辑成功"
-	br.IsAddLog = true
-}

+ 37 - 8
controllers/classify.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hz_eta_api/models"
+	"hongze/hz_eta_api/models/system"
 	"hongze/hz_eta_api/services"
 	"hongze/hz_eta_api/utils"
 	"time"
@@ -32,20 +33,34 @@ func (this *ClassifyController) Add() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+
+	// 获取系统菜单, 如果没有对应的字段的特殊处理项, 则忽略必填
+	menus, e := system.GetSysMenuItemsByCondition("", make([]interface{}, 0), []string{}, ``)
+	if e != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "获取菜单列表失败, Err: " + e.Error()
+		return
+	}
+	menuMap := make(map[string]bool)
+	for _, m := range menus {
+		if m.ButtonCode != "" {
+			menuMap[m.ButtonCode] = true
+		}
+	}
+
 	if req.ClassifyName == "" {
 		br.Msg = "分类名称不可为空"
 		return
 	}
-	if req.ParentId != 0 && req.ShowType == 0 {
+	if menuMap[system.MenuSpecialHandleClassifyShowType] && req.ParentId != 0 && req.ShowType == 0 {
 		br.Msg = "展示类型不可为空"
 		return
 	}
-	if len(req.MenuList) > 0 && req.ParentId != 0 {
+	if menuMap[system.MenuSpecialHandleClassifyChildMenu] && len(req.MenuList) > 0 && req.ParentId != 0 {
 		br.Msg = "非一级分类不可添加子目录"
 		return
 	}
-
-	if (req.ShowType == 1 || req.ShowType == 3) && req.YbRightBanner == "" && req.ParentId == 0 { //当一级报告分类为列表、品种时,增加“报告合集配图”的配置项
+	if menuMap[system.MenuSpecialHandleClassifyReportImgs] && (req.ShowType == 1 || req.ShowType == 3) && req.YbRightBanner == "" && req.ParentId == 0 { //当一级报告分类为列表、品种时,增加“报告合集配图”的配置项
 		br.Msg = "报告合集配图不可为空"
 		return
 	}
@@ -345,6 +360,21 @@ func (this *ClassifyController) Edit() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+
+	// 获取系统菜单, 如果没有对应的字段的特殊处理项, 则忽略必填
+	menus, e := system.GetSysMenuItemsByCondition("", make([]interface{}, 0), []string{}, ``)
+	if e != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "获取菜单列表失败, Err: " + e.Error()
+		return
+	}
+	menuMap := make(map[string]bool)
+	for _, m := range menus {
+		if m.ButtonCode != "" {
+			menuMap[m.ButtonCode] = true
+		}
+	}
+
 	if req.ClassifyId <= 0 {
 		br.Msg = "参数错误"
 		return
@@ -353,7 +383,7 @@ func (this *ClassifyController) Edit() {
 		br.Msg = "分类名称不可为空"
 		return
 	}
-	if req.ParentId != 0 && req.ShowType == 0 {
+	if menuMap[system.MenuSpecialHandleClassifyShowType] && req.ParentId != 0 && req.ShowType == 0 {
 		br.Msg = "展示类型不可为空"
 		return
 	}
@@ -361,8 +391,7 @@ func (this *ClassifyController) Edit() {
 		br.Msg = "上级分类不能选择自己"
 		return
 	}
-
-	if (req.ShowType == 1 || req.ShowType == 3) && req.YbRightBanner == "" && req.ParentId == 0 { //当一级报告分类为列表、品种时,增加“报告合集配图”的配置项
+	if menuMap[system.MenuSpecialHandleClassifyReportImgs] && (req.ShowType == 1 || req.ShowType == 3) && req.YbRightBanner == "" && req.ParentId == 0 { //当一级报告分类为列表、品种时,增加“报告合集配图”的配置项
 		br.Msg = "报告合集配图不可为空"
 		return
 	}
@@ -870,7 +899,7 @@ func (this *ClassifyController) TelListClassify() {
 	resp := make([]*models.SimpleClassifyList, 0)
 	var condition, orderRule string
 	var pars []interface{}
-	if utils.SystemType == "hz" {
+	if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
 		condition += ` AND classify_name <> '晨报' AND classify_name <> '周报' `
 	}
 	telList, e := models.GetClassifyByCondition(condition, orderRule, pars)

+ 16 - 1
controllers/company_permission.go

@@ -32,11 +32,20 @@ func (this *CompanyPermissionController) List() {
 		br.Ret = 408
 		return
 	}
+	// 非自用无需查询
+	resp := new(company.PermissionSetResp)
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+
 	// Tips:目前这个接口权益在添加客户、申请转正、领取客户、续约申请均有用到
 
 	companyType := this.GetString("CompanyType")
 	var productId int
-	resp := new(company.PermissionSetResp)
 
 	roleTypeCode := sysUser.RoleTypeCode
 	productId = services.GetProductId(roleTypeCode)
@@ -92,6 +101,12 @@ func (this *CompanyPermissionController) PermissionVariety() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
 
 	companyType := this.GetString("CompanyType")
 

+ 42 - 10
controllers/data_manage/edb_info.go

@@ -4183,7 +4183,6 @@ func (this *EdbInfoController) GetEdbBeforeAndAfterDateData() {
 	br.Data = resp
 }
 
-
 // EdbChartAdminList
 // @Title 获取创建人员分组
 // @Description 获取创建人员分组
@@ -4219,7 +4218,7 @@ func (this *EdbInfoController) EdbChartAdminList() {
 		return
 	}
 
-	fmt.Println("idlist:",idList)
+	fmt.Println("idlist:", idList)
 	systemAdminMap := make(map[int]*system.Admin)
 	departmentMap := make(map[string]string)
 	departmentAdminMap := make(map[int]string)
@@ -4243,27 +4242,25 @@ func (this *EdbInfoController) EdbChartAdminList() {
 	i := 1
 	for _, v := range departmentMap {
 		item := company.DepartmentGroupAdmins{
-			AdminId:      "dep_" + strconv.Itoa(i),
-			RealName:     v,
+			AdminId:  "dep_" + strconv.Itoa(i),
+			RealName: v,
 		}
 		i++
 		depList = append(depList, item)
 	}
 
-	for k:=0;k<len(depList);k++{
+	for k := 0; k < len(depList); k++ {
 		for k1, v1 := range groupMap {
 			if v1 == depList[k].RealName && v1 != "" {
 				item := &company.DepartmentGroupAdmins{
-					AdminId:      "group_" + strconv.Itoa(k),
-					RealName:     k1,
+					AdminId:  "group_" + strconv.Itoa(k),
+					RealName: k1,
 				}
 				depList[k].ChildrenList = append(depList[k].ChildrenList, item)
 			}
 		}
 	}
 
-
-
 	for _, admin := range systemAdminList {
 		for i, v := range depList {
 			for _, group := range v.ChildrenList {
@@ -4296,4 +4293,39 @@ func (this *EdbInfoController) EdbChartAdminList() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = depList
-}
+}
+
+// EdbSourceList
+// @Title 指标来源列表
+// @Description 指标来源列表
+// @Param   IsBase   query   int  false	"是否为基础指标: 1-是"
+// @Success 200 {object} data_manage.EdbInfoListResp
+// @router /edb_source/list [get]
+func (this *EdbInfoController) EdbSourceList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	isBase, _ := this.GetInt("IsBase", 0)
+
+	cond := ``
+	if isBase > 0 {
+		cond = ` AND is_base = 1`
+	}
+	pars := make([]interface{}, 0)
+	list, e := data_manage.GetEdbSourceItemsByCondition(cond, pars, []string{}, "")
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取指标来源列表失败, Err: " + e.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 12 - 3
controllers/data_manage/excel_info.go

@@ -1242,12 +1242,21 @@ func (c *ExcelInfoController) Calculate() {
 		br.ErrMsg = "计算失败:计算结果是:NAN;formulaStr:" + formulaFormStr
 		return
 	}
-	calVal := calResult.String()
-	if err != nil {
+	// 计算结果格式化
+	calFloat, e := calResult.Float64()
+	if e != nil {
 		br.Msg = "计算失败"
-		br.ErrMsg = "计算失败,结果转 string 失败:Err:" + err.Error() + ";formulaStr:" + formulaFormStr
+		br.ErrMsg = "计算失败, Err: " + e.Error()
 		return
 	}
+	calVal := utils.FormatTableDataShowValue(calFloat)
+
+	//calVal := calResult.String()
+	//if err != nil {
+	//	br.Msg = "计算失败"
+	//	br.ErrMsg = "计算失败,结果转 string 失败:Err:" + err.Error() + ";formulaStr:" + formulaFormStr
+	//	return
+	//}
 
 	br.Ret = 200
 	br.Success = true

+ 146 - 45
controllers/report.go

@@ -493,26 +493,30 @@ func (this *ReportController) Add() {
 		br.ErrMsg = "保存失败,Err:" + err.Error()
 		return
 	}
-	//处理权限
-	{
-		permissionItems, err := models.GetPermission(req.ClassifyNameSecond)
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("获取权限失败,Err:"+err.Error(), 3)
-			//utils.SendEmail(utils.APPNAME+"失败提醒", "获取权限失败,Err:"+err.Error(), utils.EmailSendToUsers)
-		}
-		for _, v := range permissionItems {
-			err = models.AddChartPermissionChapterMapping(v.ChartPermissionId, newReportId)
-			if err != nil {
-				go alarm_msg.SendAlarmMsg("新增权限失败,Err:"+err.Error(), 3)
-				//utils.SendEmail(utils.APPNAME+"失败提醒", "新增权限失败,Err:"+err.Error()+strconv.FormatInt(newReportId, 10), utils.EmailSendToUsers)
-			}
-		}
-	}
 	reportCode := utils.MD5(strconv.Itoa(int(newReportId)))
 	//修改唯一编码
 	{
 		go models.ModifyReportCode(newReportId, reportCode)
 	}
+
+	//处理权限
+	if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+		go func() {
+			permissionItems, e := models.GetPermission(req.ClassifyNameSecond)
+			if e != nil {
+				alarm_msg.SendAlarmMsg("获取权限失败,Err:"+e.Error(), 3)
+				return
+			}
+			for _, v := range permissionItems {
+				e = models.AddChartPermissionChapterMapping(v.ChartPermissionId, newReportId)
+				if e != nil {
+					alarm_msg.SendAlarmMsg("新增权限失败,Err:"+e.Error(), 3)
+					return
+				}
+			}
+		}()
+	}
+
 	resp := new(models.AddResp)
 	resp.ReportId = newReportId
 	resp.ReportCode = reportCode
@@ -534,6 +538,14 @@ func (this *ReportController) Edit() {
 		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.EditReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -562,14 +574,6 @@ func (this *ReportController) Edit() {
 		}
 	}
 
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
-
 	//更新标记key
 	markStatus, err := services.UpdateReportEditMark(int(req.ReportId), sysUser.AdminId, 1, sysUser.RealName)
 	if err != nil {
@@ -619,26 +623,30 @@ func (this *ReportController) Edit() {
 		br.ErrMsg = "保存失败,Err:" + err.Error()
 		return
 	}
+
 	//处理权限
-	{
-		err = models.RemoveChartPermissionChapterMapping(req.ReportId)
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("修改删除报告权限失败,Err:"+err.Error(), 3)
-			//utils.SendEmail(utils.APPNAME+"失败提醒", "修改删除报告权限失败,Err:"+err.Error(), utils.EmailSendToUsers)
-		}
-		permissionItems, err := models.GetPermission(req.ClassifyNameSecond)
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("获取权限失败,Err:"+err.Error(), 3)
-			//utils.SendEmail(utils.APPNAME+"失败提醒", "获取权限失败,Err:"+err.Error(), utils.EmailSendToUsers)
-		}
-		for _, v := range permissionItems {
-			err = models.AddChartPermissionChapterMapping(v.ChartPermissionId, req.ReportId)
-			if err != nil {
-				go alarm_msg.SendAlarmMsg("新增权限失败,Err:"+err.Error(), 3)
-				//utils.SendEmail(utils.APPNAME+"失败提醒", "新增权限失败,Err:"+err.Error()+strconv.FormatInt(req.ReportId, 10), utils.EmailSendToUsers)
+	if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+		go func() {
+			e := models.RemoveChartPermissionChapterMapping(req.ReportId)
+			if e != nil {
+				alarm_msg.SendAlarmMsg("修改删除报告权限失败,Err:"+e.Error(), 3)
+				return
 			}
-		}
+			permissionItems, e := models.GetPermission(req.ClassifyNameSecond)
+			if e != nil {
+				alarm_msg.SendAlarmMsg("获取权限失败,Err:"+e.Error(), 3)
+				return
+			}
+			for _, v := range permissionItems {
+				e = models.AddChartPermissionChapterMapping(v.ChartPermissionId, req.ReportId)
+				if e != nil {
+					alarm_msg.SendAlarmMsg("新增权限失败,Err:"+e.Error(), 3)
+					return
+				}
+			}
+		}()
 	}
+
 	reportCode := utils.MD5(strconv.Itoa(int(req.ReportId)))
 	resp := new(models.EditResp)
 	resp.ReportId = req.ReportId
@@ -887,6 +895,13 @@ func (this *ReportController) SendTemplateMsg() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
 	var req models.SendTemplateMsgReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -1425,7 +1440,6 @@ func (this *ReportController) GetDayWeekReportChapterTypeList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	sysUser := this.SysUser
 	if sysUser == nil {
 		br.Msg = "请登录"
@@ -1433,6 +1447,12 @@ func (this *ReportController) GetDayWeekReportChapterTypeList() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var condition string
 	var pars []interface{}
@@ -1537,6 +1557,12 @@ func (this *ReportController) GetDayWeekReportPauseTime() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	list, err := models.GetDayWeekReportPauseTimeList()
 	if err != nil {
@@ -1571,6 +1597,12 @@ func (this *ReportController) SetDayWeekReportUpdateRule() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var req models.SetDayWeekReportUpdateRuleReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
@@ -1618,6 +1650,12 @@ func (this *ReportController) SetDayWeekReportEnableRule() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var req models.SetDayWeekReportEnableUpdateRuleReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
@@ -1659,7 +1697,6 @@ func (this *ReportController) AddDayWeekReport() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	sysUser := this.SysUser
 	if sysUser == nil {
 		br.Msg = "请登录"
@@ -1667,6 +1704,12 @@ func (this *ReportController) AddDayWeekReport() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var req models.SaveDayWeekReportReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
@@ -1858,7 +1901,6 @@ func (this *ReportController) EditDayWeekReport() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	sysUser := this.SysUser
 	if sysUser == nil {
 		br.Msg = "请登录"
@@ -1866,6 +1908,12 @@ func (this *ReportController) EditDayWeekReport() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var req models.SaveDayWeekReportReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
@@ -1937,6 +1985,12 @@ func (this *ReportController) GetReportChapterList() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	reqReportId := this.GetString("ReportId")
 	reportId, _ := strconv.Atoi(reqReportId)
@@ -2055,6 +2109,12 @@ func (this *ReportController) GetLastDayWeekReportChapter() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	typeId, _ := this.GetInt("TypeId")
 	reportType := this.GetString("ReportType")
@@ -2358,7 +2418,6 @@ func (this *ReportController) GetDayReportTickerList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	sysUser := this.SysUser
 	if sysUser == nil {
 		br.Msg = "请登录"
@@ -2366,6 +2425,12 @@ func (this *ReportController) GetDayReportTickerList() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	reportChapterId, _ := this.GetInt("ReportChapterId")
 	if reportChapterId <= 0 {
@@ -2467,6 +2532,12 @@ func (this *ReportController) IsLastDayWeekReportChapter() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	reportChapterId, _ := this.GetInt("ReportChapterId")
 	if reportChapterId <= 0 {
@@ -2524,6 +2595,12 @@ func (this *ReportController) PublishDayWeekReportChapter() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var req models.PublishReportChapterReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
@@ -2713,6 +2790,12 @@ func (this *ReportController) PublishDayWeekReport() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 
 	var req models.PublishDayWeekReportReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
@@ -2772,6 +2855,13 @@ func (this *ReportController) GetSunCode() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
 	var req models.SunCodeReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -2818,7 +2908,6 @@ func (this *ReportController) GetStopDayWeekReportChapterTypeList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	sysUser := this.SysUser
 	if sysUser == nil {
 		br.Msg = "请登录"
@@ -2826,6 +2915,12 @@ func (this *ReportController) GetStopDayWeekReportChapterTypeList() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
 
 	stopDay := make([]*models.ReportChapterType, 0)
 	stopWeek := make([]*models.ReportChapterType, 0)
@@ -2941,6 +3036,12 @@ func (this *ReportController) SendMsg() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
 	if req.ReportId <= 0 {
 		br.Msg = "参数错误"
 		br.ErrMsg = "参数错误"

+ 15 - 0
controllers/report_chapter_type.go

@@ -370,6 +370,14 @@ func (this *ReportChapterTypeController) AuthSetting() {
 		br.Ret = 408
 		return
 	}
+	// 非自用直接返回
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
 	var req models.ReportChapterTypeAuthSettingReq
 	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
 		br.Msg = "参数解析异常!"
@@ -456,6 +464,13 @@ func (this *ReportChapterTypeController) PermissionList() {
 		br.Ret = 408
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
 	typeId, _ := this.GetInt("ReportChapterTypeId")
 	if typeId <= 0 {
 		br.Msg = "参数有误"

+ 14 - 0
controllers/research_group.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"hongze/hz_eta_api/models"
 	"hongze/hz_eta_api/services"
+	"hongze/hz_eta_api/utils"
 )
 
 type ResearchGroupController struct {
@@ -20,6 +21,13 @@ func (this *ResearchGroupController) GetResearchGroupList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
 	include, _ := this.GetInt("Include")
 	list, err := services.GetResearchGroupTree(include)
 	if err != nil {
@@ -50,6 +58,12 @@ func (this *ResearchGroupController) GetAdminResearchGroup() {
 		br.Msg = "参数有误"
 		return
 	}
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
 	//list, err := system.ResearchGroupRelationListByAdminId(adminId)
 	list, err := models.ResearchTagRelationListByAdminId(adminId)
 	if err != nil {

+ 22 - 2
controllers/sandbox/sandbox.go

@@ -9,6 +9,7 @@ import (
 	"hongze/hz_eta_api/models/sandbox"
 	"hongze/hz_eta_api/models/sandbox/request"
 	"hongze/hz_eta_api/models/sandbox/response"
+	"hongze/hz_eta_api/models/system"
 	sandboxService "hongze/hz_eta_api/services/sandbox"
 	"hongze/hz_eta_api/utils"
 )
@@ -326,10 +327,29 @@ func (this *SandboxController) Save() {
 	}
 
 	var sandboxResp *sandbox.SandboxSaveResp
+	// 获取系统菜单, 如果没有对应的字段的特殊处理项, 则忽略必填
+	menus, e := system.GetSysMenuItemsByCondition("", make([]interface{}, 0), []string{}, ``)
+	if e != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "获取菜单列表失败, Err: " + e.Error()
+		return
+	}
+	menuMap := make(map[string]bool)
+	for _, m := range menus {
+		if m.ButtonCode != "" {
+			menuMap[m.ButtonCode] = true
+		}
+	}
+	ignoreVariety := false
+	if !menuMap[system.MenuSpecialHandleSandboxVariety] {
+		ignoreVariety = true
+		return
+	}
+
 	var errMsg string
 	if req.SandboxVersionCode == `` {
 		//新增沙盘
-		sandboxResp, err = sandboxService.AddSandbox(req, sysUser.AdminId, sysUser.RealName)
+		sandboxResp, err = sandboxService.AddSandbox(req, sysUser.AdminId, sysUser.RealName, ignoreVariety)
 	} else {
 		////更新当前编辑中的状态缓存
 		//err = sandboxService.UpdateSandboxEditMark(req.SandboxId, sysUser.AdminId, 1)
@@ -339,7 +359,7 @@ func (this *SandboxController) Save() {
 		//}
 
 		//编辑沙盘
-		sandboxResp, err, errMsg = sandboxService.UpdateSandbox(req, sysUser.AdminId, sysUser.RealName)
+		sandboxResp, err, errMsg = sandboxService.UpdateSandbox(req, sysUser.AdminId, sysUser.RealName, ignoreVariety)
 	}
 	if err != nil {
 		br.Msg = "保存失败!"

+ 1 - 1
controllers/sys_admin.go

@@ -267,7 +267,7 @@ func (this *SysAdminController) ListSysuser() {
 		}
 	}
 	// 研究方向分组
-	if len(adminIdArr) > 0 {
+	if len(adminIdArr) > 0 && (utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox) {
 		//adminIds := strings.Join(adminIdArr, ",")
 		//researchGroupList, e := system.GetAdminResearchGroupListByAdminId(adminIds)
 		researchGroupList, e := models.GetAdminVarietyTagRelationListByAdminId(adminIdArr)

+ 249 - 2
controllers/sys_role.go

@@ -248,7 +248,8 @@ func (this *SysRoleController) ListSysRole() {
 	br.Data = resp
 }
 
-// @Title 角色设置权限-菜单列表
+// SysRoleMenusList
+// @Title 角色设置权限-菜单列表-CRM14.1弃用
 // @Description 角色设置权限-菜单列表
 // @Param   RoleId   query   int  true       "角色Id"
 // @Success 200 {object} system.SysRoleListResp
@@ -313,7 +314,8 @@ func (this *SysRoleController) SysRoleMenusList() {
 	br.Data = resp
 }
 
-// @Title 角色设置权限
+// SysRoleMenusAdd
+// @Title 角色设置权限-CRM14.1弃用
 // @Description 角色设置权限
 // @Param	request	body system.RoleMenusAddReq true "type json string"
 // @Success 200 {object} system.SysRoleListResp
@@ -453,3 +455,248 @@ func (this *SysRoleController) AllSysRole() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// SysRoleMenuAuthList
+// @Title 角色设置权限-菜单列表
+// @Description 角色设置权限-菜单列表
+// @Param   RoleId   query   int  true       "角色Id"
+// @Success 200 {object} system.SysRoleListResp
+// @router /role/menu/auth_list [get]
+func (this *SysRoleController) SysRoleMenuAuthList() {
+	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"
+		return
+	}
+	resp := new(system.SysMenuListResp)
+	resp.ChoiceList = make([]int, 0)
+	resp.HalfChoiceList = make([]int, 0)
+	resp.List = make([]*system.SysMenuItem, 0)
+
+	// 角色勾选的权限
+	roleId, _ := this.GetInt("RoleId", 0)
+	if roleId > 0 {
+		relates, e := system.GetSysRoleMenuByRoleId(roleId)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取角色关联菜单失败, Err: " + e.Error()
+			return
+		}
+		for _, r := range relates {
+			if r.Type == 1 {
+				resp.HalfChoiceList = append(resp.HalfChoiceList, r.MenuId)
+				continue
+			}
+			resp.ChoiceList = append(resp.ChoiceList, r.MenuId)
+		}
+	}
+
+	order := `sort ASC, create_time DESC, menu_id DESC`
+	list, e := system.GetSysMenuItemsByCondition("", make([]interface{}, 0), []string{}, order)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取菜单列表失败, Err: " + e.Error()
+		return
+	}
+
+	items := make([]*system.SysMenuItem, 0)
+	for _, v := range list {
+		t := &system.SysMenuItem{
+			MenuId:       v.MenuId,
+			ParentId:     v.ParentId,
+			Name:         v.Name,
+			Sort:         v.Sort,
+			Path:         v.Path,
+			PathName:     v.PathName,
+			IconPath:     v.IconPath,
+			Component:    v.Component,
+			Hidden:       v.Hidden,
+			HiddenLayout: v.HiddenLayout,
+			Level:        v.Level,
+			MenuType:     v.MenuType,
+			ButtonCode:   v.ButtonCode,
+			Children:     make([]*system.SysMenuItem, 0),
+		}
+		items = append(items, t)
+	}
+
+	// 递归返回树形结构
+	items = services.GetMenuTreeRecursive(items, 0)
+
+	resp.List = items
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// SysRoleMenuAuthSave
+// @Title 角色设置权限-保存
+// @Description 角色设置权限-保存
+// @Param	request	body RoleMenusSaveReq true "type json string"
+// @Success 200 {object} system.SysRoleListResp
+// @router /role/menu/auth_save [post]
+func (this *SysRoleController) SysRoleMenuAuthSave() {
+	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
+	}
+
+	type RoleMenusSaveReq struct {
+		RoleId      int   `description:"角色ID"`
+		MenuIds     []int `description:"菜单IDs"`
+		HalfMenuIds []int `description:"半选菜单IDs-仅供前端回显用的"`
+	}
+	var req RoleMenusSaveReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.RoleId <= 0 {
+		br.Msg = "参数有误"
+		return
+	}
+	if len(req.MenuIds) == 0 {
+		br.Msg = "请选择菜单"
+		return
+	}
+
+	items := make([]*system.SysRoleMenu, 0)
+	for _, v := range req.MenuIds {
+		t := new(system.SysRoleMenu)
+		t.MenuId = v
+		t.RoleId = req.RoleId
+		items = append(items, t)
+	}
+	for _, v := range req.HalfMenuIds {
+		t := new(system.SysRoleMenu)
+		t.MenuId = v
+		t.Type = 1
+		t.RoleId = req.RoleId
+		items = append(items, t)
+	}
+	if e := system.CreateMultiSysRoleMenu(req.RoleId, items); e != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存角色菜单权限失败, Err: " + e.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "设置成功"
+}
+
+// ButtonList
+// @Title 角色-按钮权限列表
+// @Description 角色-按钮权限列表
+// @Param   RoleId   query   int  true       "角色Id"
+// @Success 200 {object} system.SysRoleListResp
+// @router /role/menu/buttons [get]
+func (this *SysRoleController) ButtonList() {
+	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
+	}
+
+	roleId := sysUser.RoleId
+	list, e := system.GetMenuButtonsByRoleId(roleId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取角色按钮权限失败, Err: " + e.Error()
+		return
+	}
+
+	buttonList := make([]*system.SysMenuButtonResp, 0)
+	for _, v := range list {
+		tmp := new(system.SysMenuButtonResp)
+		tmp.MenuId = v.MenuId
+		tmp.ParentId = v.ParentId
+		tmp.MenuType = v.MenuType
+		tmp.Name = v.Name
+		tmp.ButtonCode = v.ButtonCode
+		buttonList = append(buttonList, tmp)
+	}
+
+	br.Data = buttonList
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// SystemConfig
+// @Title 系统配置列表
+// @Description 系统配置列表
+// @Success 200 {object} []system.BusinessConf
+// @router /config [get]
+func (this *SysRoleController) SystemConfig() {
+	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
+	}
+	list := make([]system.BusinessConf, 0)
+
+	// 获取基础配置, 若未配置则直接返回
+	conf, e := models.GetBusinessConf()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取基础配置失败, Err: " + e.Error()
+		return
+	}
+
+	list = append(list, system.BusinessConf{
+		ConfKey: "ReportViewUrl",
+		ConfVal: conf["ReportViewUrl"],
+	}, system.BusinessConf{
+		ConfKey: "ChartViewUrl",
+		ConfVal: conf["ChartViewUrl"],
+	})
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 14 - 1
controllers/variety_tag.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"hongze/hz_eta_api/models"
 	"hongze/hz_eta_api/services"
+	"hongze/hz_eta_api/utils"
 )
 
 type VarietyTagController struct {
@@ -21,15 +22,27 @@ func (this *VarietyTagController) TagTree() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	// 非自用不请求
+	resp := make([]*services.TagTreeItem, 0)
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+
 	hasResearcher, _ := this.GetInt("HasResearcher")    // 是否展示研究员:1展示, 0不展示
 	include, _ := this.GetInt("IncludeDisableMember")   // 是否包含被禁用的研究员标签
 	questionId, _ := this.GetInt("CommunityQuestionId") // 问答社区ID-用于区分哪些研究员不可选
-	resp, e := services.GetTagTree(hasResearcher, include, questionId)
+	list, e := services.GetTagTree(hasResearcher, include, questionId)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "TagTree-获取标签树失败, Err: " + e.Error()
 		return
 	}
+	resp = list
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 0 - 147
models/aimod/ai.go

@@ -1,147 +0,0 @@
-package aimod
-
-import (
-	"github.com/beego/beego/v2/client/orm"
-	"time"
-)
-
-type AiChatTopic struct {
-	AiChatTopicId   int `orm:"column(ai_chat_topic_id);pk"`
-	TopicName       string
-	SysUserId       int
-	SysUserRealName string
-	CreateTime      time.Time
-	ModifyTime      time.Time
-}
-
-type AiChat struct {
-	AiChatId        int `orm:"column(ai_chat_id);pk"`
-	AiChatTopicId   int
-	Ask             string
-	AskUuid         string
-	Answer          string
-	Model           string
-	SysUserId       int
-	SysUserRealName string
-	CreateTime      time.Time
-	ModifyTime      time.Time
-}
-
-type ChatReq struct {
-	AiChatTopicId int    `description:"主题id"`
-	Model         string `description:"模型:gpt-3.5-turbo,eta,gpt-3.5-turbo-16k"`
-	Ask           string `description:"提问"`
-}
-
-func GetAiChatByAsk(askUuid, model string) (item *AiChat, err error) {
-	sql := `SELECT * FROM ai_chat WHERE ask_uuid=? AND model =? `
-	o := orm.NewOrmUsingDB("weekly")
-	err = o.Raw(sql, askUuid, model).QueryRow(&item)
-	return
-}
-
-type ChatResp struct {
-	AiChatTopicId int    `description:"主题id"`
-	Ask           string `description:"提问"`
-	Answer        string `description:"回答"`
-	Model         string
-}
-
-// AddAiChatTopic 新增主题
-func AddAiChatTopic(item *AiChatTopic) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(item)
-	return
-}
-
-// AddAiChat 新增聊天
-func AddAiChat(item *AiChat) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(item)
-	return
-}
-
-type AiChatTopicView struct {
-	AiChatTopicId int    `description:"主题id"`
-	TopicName     string `description:"主题名称"`
-	CreateTime    string `description:"创建时间"`
-	ModifyTime    string `description:"修改时间"`
-}
-
-func GetAiChatTopicList(sysUserId int) (item []*AiChatTopicView, err error) {
-	sql := ` SELECT * FROM ai_chat_topic WHERE sys_user_id=? ORDER BY create_time DESC `
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Raw(sql, sysUserId).QueryRows(&item)
-	return
-}
-
-type AiChatTopicListResp struct {
-	List []*AiChatTopicView
-}
-
-type AiChatView struct {
-	AiChatId      int    `description:"记录id"`
-	AiChatTopicId int    `description:"主题id"`
-	Ask           string `description:"提问"`
-	Answer        string `description:"答案"`
-	Model         string
-	CreateTime    string `description:"创建时间"`
-	ModifyTime    string `description:"修改时间"`
-}
-
-func GetAiChatList(aiChatTopicId int) (item []*AiChatView, err error) {
-	sql := ` SELECT * FROM ai_chat WHERE ai_chat_topic_id=? ORDER BY create_time ASC `
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Raw(sql, aiChatTopicId).QueryRows(&item)
-	return
-}
-
-type AiChatDetailResp struct {
-	List []*AiChatView
-}
-
-type TopicDeleteReq struct {
-	AiChatTopicId int `description:"主题id"`
-}
-
-func DeleteTopic(topicId int) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	tx, err := o.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-	sql := ` DELETE FROM ai_chat_topic WHERE  ai_chat_topic_id=? `
-	_, err = tx.Raw(sql, topicId).Exec()
-	if err != nil {
-		return err
-	}
-	sql = ` DELETE FROM ai_chat WHERE  ai_chat_topic_id=? `
-	_, err = tx.Raw(sql, topicId).Exec()
-	if err != nil {
-		return err
-	}
-	return err
-}
-
-type TopicEditReq struct {
-	AiChatTopicId int    `description:"主题id"`
-	TopicName     string `description:"主题名称"`
-}
-
-func GetAiChatTopicByTopicName(topicName string) (item *AiChatTopicView, err error) {
-	sql := ` SELECT * FROM ai_chat_topic WHERE topic_name=? `
-	o := orm.NewOrmUsingDB("weekly")
-	err = o.Raw(sql, topicName).QueryRow(&item)
-	return
-}
-
-func EditTopic(topicId int, topicName string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` UPDATE ai_chat_topic SET topic_name=? WHERE  ai_chat_topic_id=? `
-	_, err = o.Raw(sql, topicName, topicId).Exec()
-	return err
-}

+ 31 - 0
models/data_manage/edb_source.go

@@ -0,0 +1,31 @@
+package data_manage
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"strings"
+)
+
+// EdbSource 指标来源表
+type EdbSource struct {
+	EdbSourceId int    `orm:"column(edb_source_id);pk"`
+	SourceName  string `description:"指标来源名称"`
+	TableName   string `description:"数据表名"`
+	IsBase      int    `description:"是否为基础指标: 0-否; 1-是"`
+}
+
+// GetEdbSourceItemsByCondition 获取指标来源
+func GetEdbSourceItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*EdbSource, err error) {
+	o := orm.NewOrmUsingDB("data")
+	fields := strings.Join(fieldArr, ",")
+	if len(fieldArr) == 0 {
+		fields = `*`
+	}
+	order := `ORDER BY edb_source_id ASC`
+	if orderRule != "" {
+		order = ` ORDER BY ` + orderRule
+	}
+	sql := fmt.Sprintf(`SELECT %s FROM edb_source WHERE 1=1 %s %s`, fields, condition, order)
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 1 - 15
models/db.go

@@ -2,7 +2,6 @@ package models
 
 import (
 	_ "github.com/go-sql-driver/mysql"
-	"hongze/hz_eta_api/models/aimod"
 	"hongze/hz_eta_api/models/company"
 	"hongze/hz_eta_api/models/data_manage"
 	future_good2 "hongze/hz_eta_api/models/data_manage/future_good"
@@ -56,7 +55,7 @@ func init() {
 	gl.SetConnMaxLifetime(10 * time.Minute)
 
 	// 用户主库
-	if utils.MYSQL_WEEKLY_URL != `` {
+	if utils.MYSQL_WEEKLY_URL != `` && (utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox) {
 		_ = orm.RegisterDataBase("weekly", "mysql", utils.MYSQL_WEEKLY_URL)
 		orm.SetMaxIdleConns("weekly", 50)
 		orm.SetMaxOpenConns("weekly", 100)
@@ -131,9 +130,6 @@ func init() {
 	//多图配置
 	initMultipleGraphConfig()
 
-	//AI 聊天记录
-	initAiChat()
-
 	// 商家配置
 	initBusinessConf()
 
@@ -181,12 +177,10 @@ func initReport() {
 	orm.RegisterModel(
 		new(Report),
 		new(ReportViewRecord),
-		new(ResearchReport),                      //日报、周报信息
 		new(ChartPermissionSearchKeyWordMapping), //报告分类权限表
 		new(ReportChapter),                       // 报告章节表
 		new(ReportChapterTicker),                 // 晨报章节ticker
 		new(ReportChapterTypePermission),         // 晨周报章节类型权限表
-		new(GroupSendMsg),                        //群发消息
 		new(ChartPermission),                     // 权限表
 		new(YbPcSuncode),
 		new(YbSuncodePars),
@@ -394,14 +388,6 @@ func initMultipleGraphConfig() {
 	)
 }
 
-func initAiChat() {
-	//注册对象
-	orm.RegisterModel(
-		new(aimod.AiChatTopic), //主题
-		new(aimod.AiChat),      //聊天
-	)
-}
-
 // initBusinessConf 商家配置
 func initBusinessConf() {
 	orm.RegisterModel(

+ 0 - 48
models/group_send_msg.go

@@ -1,48 +0,0 @@
-package models
-
-import (
-	"github.com/beego/beego/v2/client/orm"
-	"time"
-)
-
-// GroupSendMsgAddReq 群发消息请求
-type GroupSendMsgAddReq struct {
-	JumpType    int8   `description:"跳转类型,1:h5;2:小程序;3:文字;4-图片"`
-	LinkUrl     string `description:"跳转地址,长度255"`
-	ImgUrl      string `description:"图片地址,长度255"`
-	Title       string `description:"标题,长度64"`
-	Description string `description:"摘要"`
-	Label       string `description:"标签,多个标签用、隔开;长度255"`
-}
-
-// 群发消息
-type GroupSendMsg struct {
-	MsgId       int       `orm:"column(msg_id);pk" description:"消息Id"`
-	JumpType    int8      `description:"跳转类型,1:h5;2:小程序;3:文字;4-图片"`
-	LinkUrl     string    `description:"跳转地址"`
-	ImgUrl      string    `description:"图片地址"`
-	Title       string    `description:"标题"`
-	Description string    `description:"摘要"`
-	Label       string    `description:"标签"`
-	Status      int8      `description:"发送结果,0:待发送,-1发送失败,1发送成功"`
-	Remark      string    `description:"发送失败原因"`
-	CreateTime  time.Time `description:"发送时间"`
-}
-
-// Add 新增群发消息
-func (groupSendMsg *GroupSendMsg) Add() (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	id, err := o.Insert(groupSendMsg)
-	if err != nil {
-		return
-	}
-	groupSendMsg.MsgId = int(id)
-	return
-}
-
-// Update 修改群发消息
-func (groupSendMsg *GroupSendMsg) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Update(groupSendMsg, cols...)
-	return
-}

+ 3 - 3
models/report.go

@@ -869,14 +869,14 @@ type YbPcSuncode struct {
 
 // GetYbPcSunCode 获取太阳码
 func GetYbPcSunCode(scene, page string) (item *YbPcSuncode, err error) {
-	o := orm.NewOrmUsingDB("default")
+	o := orm.NewOrmUsingDB("weekly")
 	sql := `SELECT * FROM yb_pc_suncode WHERE scene = ? AND code_page = ? `
 	err = o.Raw(sql, scene, page).QueryRow(&item)
 	return
 }
 
 func AddYbPcSunCode(item *YbPcSuncode) (err error) {
-	o := orm.NewOrmUsingDB("default")
+	o := orm.NewOrmUsingDB("weekly")
 	_, err = o.Insert(item)
 	return
 }
@@ -890,7 +890,7 @@ type YbSuncodePars struct {
 }
 
 func AddYbSuncodePars(item *YbSuncodePars) (err error) {
-	o := orm.NewOrmUsingDB("default")
+	o := orm.NewOrmUsingDB("weekly")
 	_, err = o.Insert(item)
 	return
 }

+ 2 - 2
models/report_chapter_type.go

@@ -142,7 +142,7 @@ func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterT
 	return
 }
 
-// 晨报周报暂停时间
+// DayWeekReportPauseTime 晨报周报暂停时间
 type DayWeekReportPauseTime struct {
 	ResearchType   string `description:"报告类型 day; week;"`
 	PauseStartTime string `description:"暂停开始时间"`
@@ -313,7 +313,7 @@ func GetReportChapterTypeCount(condition string, pars []interface{}) (count int,
 	return
 }
 
-// GetReportChapterTypeList 获取章节类型列表
+// GetReportChapterTypePageList 获取章节类型列表
 func GetReportChapterTypePageList(condition string, pars []interface{}, startSize, pageSize int) (list []*ReportChapterType, err error) {
 	o := orm.NewOrmUsingDB("weekly")
 	sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `

+ 0 - 264
models/research_report.go

@@ -1,272 +1,8 @@
 package models
 
-import (
-	"fmt"
-	"github.com/beego/beego/v2/client/orm"
-	"hongze/hz_eta_api/utils"
-	"strconv"
-	"time"
-)
-
-// ResearchReport 研究报告表(晨报、周报等)结构体
-type ResearchReport struct {
-	ResearchReportId    int       `orm:"column(research_report_id);pk" description:"研究报告id"`
-	ResearchReportName  string    `description:"研究报告名称"`
-	ResearchReportTitle string    `description:"研究报告标题"`
-	ResearchReportImg   string    `description:"报告缩略图URL"`
-	ResearchReportDate  time.Time `description:"报告日期"`
-	Type                string    `description:"报告类型,枚举值:day 晨报  week 周报 twoweek双周报 month 月报;默认:day"`
-	Author              string    `description:"作者"`
-	ReportVariety       string    `description:"研究报告的品种,双周报和月报有标识"`
-	IsHasMenu           int8      `description:"报告是否含有目录"`
-	IsSendedMsg         int8      `description:"是否发送过模板消息"`
-	Periods             int       `description:"期数"`
-	Status              string    `description:"状态,draft:草稿,"`
-	Enabled             int8      `description:"报告状态"`
-	CreatedTime         string    `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次更新时间"`
-	Viewers             int       `description:"H5观看用户数"`
-}
-
-// Update 更新数据
-func (researchReport *ResearchReport) Update(updateCols []string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Update(researchReport, updateCols...)
-	return
-}
-
-type ResearchReportList struct {
-	ResearchReportId    int       `orm:"column(research_report_id);pk" description:"研究报告id"`
-	ResearchReportName  string    `description:"研究报告名称"`
-	ResearchReportTitle string    `description:"研究报告标题"`
-	ResearchReportImg   string    `description:"报告缩略图URL"`
-	ResearchReportDate  time.Time `description:"报告日期"`
-	Type                string    `description:"报告类型,枚举值:day 晨报  week 周报 twoweek双周报 month 月报;默认:day"`
-	Author              string    `description:"作者"`
-	ReportVariety       string    `description:"研究报告的品种,双周报和月报有标识"`
-	IsHasMenu           int8      `description:"报告是否含有目录"`
-	IsSendedMsg         int8      `description:"是否发送过模板消息"`
-	Periods             int       `description:"期数"`
-	Status              string    `description:"状态,draft:草稿,"`
-	Enabled             int8      `description:"报告状态"`
-	CreatedTime         string    `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次更新时间"`
-	Viewers             int       `description:"H5观看用户数"`
-	LinkUrl             string    `description:"报告阅读地址"`
-}
-
-// 获取今年报告
-func GetMigrateReportList() (list []*ResearchReport, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT
-				*
-			FROM
-				research_report AS a
-			WHERE
-				a.enabled = 1
-			AND a.status = "report"
-			AND a.research_report_date >= "2022-01-01"
-			ORDER BY a.research_report_date ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-
-	return
-}
-
-// ResearchReport 研究报告表(晨报、周报等)结构体
-type ResearchReportType struct {
-	ResearchReportTypeId    int       `orm:"column(research_report_type_id);pk" description:"报告章节ID"`
-	ResearchReportId        int       `description:"报告ID"`
-	TypeId                  int       `description:"分类ID"`
-	Edit                    int       `description:"是否编辑过"`
-	Trend                   string    `description:"趋势观点"`
-	ResearchReportTypeTitle string    `description:"报告标题"`
-	CreatedTime             string    `description:"创建时间"`
-	LastUpdatedTime         time.Time `description:"最近一次更新时间"`
-}
-
-type ResearchReportTypeContent struct {
-	ResearchReportTypeContentId int       `orm:"column(research_report_type_content_id);pk" description:"章节内容ID"`
-	ResearchReportTypeId        int       `description:"报告章节ID"`
-	Sort                        int       `description:"排序"`
-	ContentType                 string    `description:"内容分类类型"`
-	Content                     string    `description:"内容"`
-	ImgUrl                      string    `description:"图片路径"`
-	CreatedTime                 time.Time `description:"创建时间"`
-	LastUpdatedTime             time.Time `description:"最近一次更新时间"`
-}
-
-type ResearchReportTypeTicker struct {
-	ResearchReportTypeTickerId int       `orm:"column(research_report_type_ticker_id);pk" description:"章节tickerID"`
-	ResearchReportTypeId       int       `description:"报告章节ID"`
-	Sort                       int       `description:"排序"`
-	Ticker                     string    `description:"指标的ticker"`
-	CreatedTime                time.Time `description:"创建时间"`
-	LastUpdatedTime            time.Time `description:"最近一次更新时间"`
-}
-
-func GetResearchReportTypeListByReportIds(reportIds []int) (list []*ResearchReportType, err error) {
-	if len(reportIds) == 0 {
-		return
-	}
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) ORDER BY created_time ASC,research_report_type_id ASC `
-	_, err = o.Raw(sql, reportIds).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeContentListByReportTypeIds(reportTypeIds []int) (list []*ResearchReportTypeContent, err error) {
-	if len(reportTypeIds) == 0 {
-		return
-	}
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type_content WHERE research_report_type_id IN (` + utils.GetOrmInReplace(len(reportTypeIds)) + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql, reportTypeIds).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeTickerListByReportTypeIds(reportTypeIds []int) (list []*ResearchReportTypeTicker, err error) {
-	if len(reportTypeIds) == 0 {
-		return
-	}
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type_ticker WHERE research_report_type_id IN (` + utils.GetOrmInReplace(len(reportTypeIds)) + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql, reportTypeIds).QueryRows(&list)
-	return
-}
-
-type CreateDayWeekReport struct {
-	Report      *Report
-	ChapterList []*CreateDayWeekReportChapter
-}
-
-type CreateDayWeekReportChapter struct {
-	Chapter    *ReportChapter
-	TickerList []*ReportChapterTicker
-}
-
-// 新增迁移晨周报
-func CreateMigrateNewDayWeekReport(newDayWeekReport *CreateDayWeekReport) (newReportId int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 新增报告
-	reportId, err := to.Insert(newDayWeekReport.Report)
-	if err != nil {
-		fmt.Println("InsertReportErr:" + err.Error())
-		return
-	}
-	// 新增章节
-	for _, chapter := range newDayWeekReport.ChapterList {
-		chapter.Chapter.ReportId = int(reportId)
-		lastChapterId, tmpErr := to.Insert(chapter.Chapter)
-		if tmpErr != nil {
-			err = tmpErr
-			return
-		}
-		// 新增晨报ticker
-		for _, ticker := range chapter.TickerList {
-			ticker.ReportChapterId = int(lastChapterId)
-			if _, tmpErr = to.Insert(ticker); tmpErr != nil {
-				err = tmpErr
-				return
-			}
-		}
-	}
-	// 修改报告code
-	reportCode := utils.MD5(strconv.Itoa(int(reportId)))
-	sql := `UPDATE report SET report_code = ? WHERE id = ? `
-	if _, err = to.Raw(sql, reportCode, reportId).Exec(); err != nil {
-		fmt.Println("UpdateReportCodeErr:" + err.Error())
-	}
-	newReportId = int(reportId)
-
-	return
-}
-
-// 新增迁移其他报告
-func CreateMigrateNewOtherReport(reportInfo *Report, mappingList []*ChartPermissionChapterMapping) (newReportId int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 新增报告
-	reportId, err := to.Insert(reportInfo)
-	if err != nil {
-		fmt.Println("InsertReportErr:" + err.Error())
-		return
-	}
-	// 修改报告code
-	reportCode := utils.MD5(strconv.Itoa(int(reportId)))
-	sql := `UPDATE report SET report_code = ? WHERE id = ? `
-	if _, err = to.Raw(sql, reportCode, reportId).Exec(); err != nil {
-		fmt.Println("UpdateReportCodeErr:" + err.Error())
-		return
-	}
-
-	// 新增权限
-	newReportId = int(reportId)
-	if len(mappingList) > 0 {
-		r := orm.NewOrmUsingDB("weekly")
-		for _, mapping := range mappingList {
-			sql := ` INSERT INTO chart_permission_chapter_mapping (chart_permission_id, report_chapter_type_id,research_type) VALUES(?,?,?) `
-			if _, err = r.Raw(sql, mapping.ChartPermissionId, newReportId, "rddp").Exec(); err != nil {
-				fmt.Println("InsertChartPermissionErr:" + err.Error())
-				return
-			}
-		}
-	}
-
-	return
-}
-
 type ChartPermissionChapterMapping struct {
 	Id                  int    `orm:"column(id);pk"`
 	ChartPermissionId   int    `description:"权限ID"`
 	ReportChapterTypeId int    `description:"report_chapter_type表主键id或research_report表主键id或tactic表主键id"`
 	ResearchType        string `description:"报告类型 week;two_week;tactic;month;other;rddp; "`
 }
-
-func GetChapterPermissionMappingByResearchReportIds(researchReportIds []int) (list []*ChartPermissionChapterMapping, err error) {
-	if len(researchReportIds) == 0 {
-		return
-	}
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM chart_permission_chapter_mapping WHERE report_chapter_type_id IN (` + utils.GetOrmInReplace(len(researchReportIds)) + `) AND research_type != "rddp" ORDER BY report_chapter_type_id ASC `
-	_, err = o.Raw(sql, researchReportIds).QueryRows(&list)
-	return
-}
-
-// GetResearchReportTypeListByReportId 根据报告ID获取报告章节
-func GetResearchReportTypeListByReportId(reportId int) (list []*ResearchReportType, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id = ? ORDER BY created_time ASC,research_report_type_id ASC `
-	_, err = o.Raw(sql, reportId).QueryRows(&list)
-	return
-}
-
-// GetResearchReportById 主键获取报告
-func GetResearchReportById(reportId int) (item *ResearchReport, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM research_report WHERE research_report_id = ? LIMIT 1`
-	err = o.Raw(sql, reportId).QueryRow(&item)
-	return
-}

+ 113 - 5
models/system/sys_menu.go

@@ -1,6 +1,56 @@
 package system
 
-import "github.com/beego/beego/v2/client/orm"
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"strings"
+	"time"
+)
+
+// 需要特殊处理的菜单字段项
+const (
+	MenuSpecialHandleClassifyChildMenu  = "classifyList:cnClassify:childMenu"
+	MenuSpecialHandleClassifyShowType   = "classifyList:cnClassify:showType"
+	MenuSpecialHandleClassifyReportImgs = "classifyList:cnClassify:reportImgs"
+	MenuSpecialHandleSandboxVariety     = "sandbox:variety"
+)
+
+type SysMenu struct {
+	MenuId       int       `orm:"column(menu_id);pk"`
+	ParentId     int       `description:"父级菜单ID"`
+	Name         string    `description:"菜单名称或者按钮名称"`
+	RootId       int       `description:"顶层菜单ID"`
+	Sort         string    `description:"排序"`
+	Path         string    `description:"路由地址"`
+	PathName     string    `description:"路由名称"`
+	IconPath     string    `description:"菜单图标地址"`
+	Component    int       `description:"组件路径"`
+	Hidden       int       `description:"是否隐藏:1-隐藏 0-显示"`
+	HiddenLayout int       `description:"是否隐藏layout:1-隐藏 0-显示"`
+	Level        int       `description:"菜单等级:1-2-3"`
+	IsLevel      int       `description:"是否为多级菜单:1,只有一级;2,有多级"`
+	LevelPath    string    `description:"兼容以前menu表的字段"`
+	MenuType     int       `description:"菜单类型: 0-菜单; 1-按钮; 2-字段(需要特殊处理)"`
+	ButtonCode   string    `description:"按钮/菜单唯一标识"`
+	CreateTime   time.Time `description:"创建时间"`
+	ModifyTime   time.Time `description:"更新时间"`
+}
+
+// GetSysMenuItemsByCondition 获取菜单列表
+func GetSysMenuItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*SysMenu, err error) {
+	o := orm.NewOrm()
+	fields := strings.Join(fieldArr, ",")
+	if len(fieldArr) == 0 {
+		fields = `*`
+	}
+	order := `ORDER BY create_time DESC`
+	if orderRule != "" {
+		order = ` ORDER BY ` + orderRule
+	}
+	sql := fmt.Sprintf(`SELECT %s FROM sys_menu WHERE 1=1 %s %s`, fields, condition, order)
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
 
 type MenuList struct {
 	MenuId    int          `description:"导航唯一标识"`
@@ -52,22 +102,80 @@ func GetMenuByParentId(roleId, parentId int) (items []*ChildMenu, err error) {
 // GetMenuListByRoleIds 根据管理员多个角色查询菜单ID
 func GetMenuListByRoleIds(roleIds string) (items []*MenuList, err error) {
 	sql := ` SELECT DISTINCT a.* FROM sys_menu AS a
-			INNER JOIN sys_role_menu AS b ON a.menu_id=b.menu_id
+			INNER JOIN sys_role_menu AS b ON a.menu_id=b.menu_id AND b.type = 0
 			INNER JOIN sys_role AS c ON b.role_id=c.role_id
-			WHERE c.role_id in (`+roleIds+`)
+			WHERE c.role_id in (` + roleIds + `)
 			AND a.parent_id=0 
             ORDER BY sort ASC `
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }
+
 // GetMenuByParentIdRoleIds 根据管理员多个角色查询子菜单ID
 func GetMenuByParentIdRoleIds(roleIds string, parentId int) (items []*ChildMenu, err error) {
 	sql := ` SELECT DISTINCT a.* FROM sys_menu AS a
-			INNER JOIN sys_role_menu AS b ON a.menu_id=b.menu_id
+			INNER JOIN sys_role_menu AS b ON a.menu_id=b.menu_id AND b.type = 0
 			INNER JOIN sys_role AS c ON b.role_id=c.role_id
-			WHERE c.role_id in (`+roleIds+`)
+			WHERE c.role_id in (` + roleIds + `)
 			AND a.parent_id=? 
             ORDER BY a.sort ASC`
 	_, err = orm.NewOrm().Raw(sql, parentId).QueryRows(&items)
 	return
 }
+
+// GetMenuButtonsByRoleId 获取角色按钮菜单
+func GetMenuButtonsByRoleId(roleId int) (items []*SysMenu, err error) {
+	sql := `SELECT
+				r.*
+			FROM
+				sys_menu AS r
+			JOIN sys_role_menu AS rm ON r.menu_id = rm.menu_id AND rm.type = 0
+			WHERE
+				rm.role_id = ? AND r.menu_type <> 0
+			ORDER BY
+				r.sort ASC,
+				r.create_time DESC`
+	_, err = orm.NewOrm().Raw(sql, roleId).QueryRows(&items)
+	return
+}
+
+// SysMenuButtonResp 按钮菜单响应体
+type SysMenuButtonResp struct {
+	MenuId     int    `description:"菜单ID"`
+	ParentId   int    `description:"父级菜单ID"`
+	Name       string `description:"菜单名称或者按钮名称"`
+	MenuType   int    `description:"菜单类型: 0-菜单; 1-按钮"`
+	ButtonCode string `description:"按钮唯一标识"`
+}
+
+// SysMenuListResp ETA商家菜单列表响应体
+type SysMenuListResp struct {
+	ChoiceList     []int          `description:"已选菜单"`
+	HalfChoiceList []int          `description:"半选菜单-方便前端回显用的"`
+	List           []*SysMenuItem `description:"菜单列表"`
+}
+
+// SysMenuItem ETA商家菜单
+type SysMenuItem struct {
+	MenuId       int
+	ParentId     int            `description:"父级菜单ID"`
+	Name         string         `description:"菜单名称或者按钮名称"`
+	RootId       int            `description:"顶层菜单ID"`
+	Sort         string         `description:"排序"`
+	Path         string         `description:"路由地址"`
+	PathName     string         `description:"路由名称"`
+	IconPath     string         `description:"菜单图标地址"`
+	Component    int            `description:"组件路径"`
+	Hidden       int            `description:"是否隐藏:1-隐藏 0-显示"`
+	HiddenLayout int            `description:"是否隐藏layout:1-隐藏 0-显示"`
+	Level        int            `description:"菜单等级:1-2-3"`
+	MenuType     int            `description:"菜单类型: 0-菜单; 1-按钮; 2-字段(需要特殊处理)"`
+	ButtonCode   string         `description:"按钮/菜单唯一标识"`
+	Children     []*SysMenuItem `description:"子菜单"`
+}
+
+// BusinessConf 商户配置表
+type BusinessConf struct {
+	ConfKey string `description:"配置Key"`
+	ConfVal string `description:"配置值"`
+}

+ 44 - 1
models/system/sys_role.go

@@ -152,7 +152,7 @@ func GetRoleMenuByParentId(parentId int) (items []*RoleMenu, err error) {
 func GetCheckListRoleMenu(roleId, parentId int) (items []*RoleMenuList, err error) {
 	sql := ` SELECT b.menu_id FROM sys_role_menu AS a
 				INNER JOIN sys_menu AS b ON a.menu_id=b.menu_id
-				WHERE a.role_id=?
+				WHERE a.role_id=? AND a.type = 0
 				AND b.parent_id=? `
 	_, err = orm.NewOrm().Raw(sql, roleId, parentId).QueryRows(&items)
 	return
@@ -175,6 +175,7 @@ type SysRoleMenu struct {
 	RoleMenuId int `orm:"column(role_menu_id);pk" description:"关联id"`
 	RoleId     int
 	MenuId     int
+	Type       int `description:"类型:0-全选;1-半选(此字段仅用于前端的回显)"`
 }
 
 func AddSysRoleMenu(item *SysRoleMenu) (lastId int64, err error) {
@@ -183,6 +184,36 @@ func AddSysRoleMenu(item *SysRoleMenu) (lastId int64, err error) {
 	return
 }
 
+// CreateMultiSysRoleMenu 删除并新增角色权限
+func CreateMultiSysRoleMenu(roleId int, items []*SysRoleMenu) (err error) {
+	if roleId == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	tx, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = tx.Rollback()
+			return
+		}
+		_ = tx.Commit()
+	}()
+
+	sql := `DELETE FROM sys_role_menu WHERE role_id = ?`
+	_, err = tx.Raw(sql, roleId).Exec()
+	if err != nil {
+		return
+	}
+
+	if len(items) > 0 {
+		_, err = tx.InsertMulti(len(items), items)
+	}
+	return
+}
+
 func GetSysRoleAll(levelFlag bool) (items []*SysRoleItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM sys_role WHERE 1=1`
@@ -208,3 +239,15 @@ func GetEnglishAuthRoleIds(roleCodes []string) (roleIds []int, err error) {
 	_, err = o.Raw(sql, roleCodes).QueryRows(&roleIds)
 	return
 }
+
+// GetSysRoleMenuByRoleId 获取角色关联菜单
+func GetSysRoleMenuByRoleId(roleId int) (items []*SysRoleMenu, err error) {
+	sql := `SELECT
+				*
+			FROM
+				sys_role_menu
+			WHERE
+				role_id = ?`
+	_, err = orm.NewOrm().Raw(sql, roleId).QueryRows(&items)
+	return
+}

+ 0 - 104
models/variety_tag.go

@@ -46,50 +46,6 @@ func GetEnableVarietyClassifyList(hasForbidden bool) (list []*VarietyClassify, e
 	return
 }
 
-// GetVarietyClassifyPageList 获取标签分类分页列表
-func GetVarietyClassifyPageList(condition string, pars []interface{}, orderRule string, startSize, pageSize int) (total int, list []*VarietyClassify, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_classify WHERE 1=1 `
-	sql += condition
-	if orderRule == "" {
-		orderRule = "modify_time DESC"
-	}
-	sql += ` ORDER BY ` + orderRule
-
-	totalSQL := `SELECT COUNT(1) total FROM (` + sql + `) z`
-	if err = o.Raw(totalSQL, pars).QueryRow(&total); err != nil {
-		return
-	}
-	sql += ` LIMIT ?,?`
-
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-	return
-}
-
-// GetVarietyClassifyById 主键获取分类
-func GetVarietyClassifyById(classifyId int) (item *VarietyClassify, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_classify WHERE variety_classify_id = ? LIMIT 1`
-	err = o.Raw(sql, classifyId).QueryRow(&item)
-	return
-}
-
-// GetVarietyClassifyByName 名称获取分类
-func GetVarietyClassifyByName(classifyName string) (item *VarietyClassify, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_classify WHERE classify_name = ? LIMIT 1`
-	err = o.Raw(sql, classifyName).QueryRow(&item)
-	return
-}
-
-// GetCountEnableClassifyByClassifyId 根据分类ID获取启用分类数
-func GetCountEnableClassifyByClassifyId(classifyId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT COUNT(1) FROM variety_classify WHERE state = 1 AND variety_classify_id != ?`
-	err = o.Raw(sql, classifyId).QueryRow(&count)
-	return
-}
-
 // VarietyTag 标签表
 type VarietyTag struct {
 	VarietyTagId                int       `orm:"column(variety_tag_id);pk" description:"标签ID"`
@@ -121,22 +77,6 @@ func (varietyTag *VarietyTag) Update(cols []string) (err error) {
 	return
 }
 
-// GetVarietyTagById 主键获取标签
-func GetVarietyTagById(tagId int) (item *VarietyTag, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_tag WHERE variety_tag_id = ? LIMIT 1`
-	err = o.Raw(sql, tagId).QueryRow(&item)
-	return
-}
-
-// GetCountEnableTagByTagId 根据标签ID获取启用标签数
-func GetCountEnableTagByTagId(classifyId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT COUNT(1) FROM variety_tag WHERE state = 1 AND variety_tag_id != ?`
-	err = o.Raw(sql, classifyId).QueryRow(&count)
-	return
-}
-
 // GetEnableVarietyTagList 获取启用状态标签列表
 func GetEnableVarietyTagList(hasForbidden bool) (list []*VarietyTag, err error) {
 	o := orm.NewOrmUsingDB("weekly")
@@ -151,42 +91,6 @@ func GetEnableVarietyTagList(hasForbidden bool) (list []*VarietyTag, err error)
 	return
 }
 
-// GetVarietyTagList 获取标签列表
-func GetVarietyTagList() (list []*VarietyTag, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_tag ORDER BY sort`
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-// GetVarietyTagPageList 获取标签分页列表
-func GetVarietyTagPageList(condition string, pars []interface{}, orderRule string, startSize, pageSize int) (total int, list []*VarietyTag, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_tag WHERE 1=1 `
-	sql += condition
-	if orderRule == "" {
-		orderRule = "modify_time DESC"
-	}
-	sql += ` ORDER BY ` + orderRule
-
-	totalSQL := `SELECT COUNT(1) total FROM (` + sql + `) z`
-	if err = o.Raw(totalSQL, pars).QueryRow(&total); err != nil {
-		return
-	}
-	sql += ` LIMIT ?,?`
-
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-	return
-}
-
-// GetVarietyTagListByClassifyId 根据分类获取标签列表
-func GetVarietyTagListByClassifyId(classifyId int) (list []*VarietyTag, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM variety_tag WHERE variety_classify_id = ? AND state = 1 ORDER BY sort`
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
 // ResearchVarietyTagRelation 研究员标签关系表
 type ResearchVarietyTagRelation struct {
 	Id           int `orm:"column(id);pk"`
@@ -194,14 +98,6 @@ type ResearchVarietyTagRelation struct {
 	AdminId      int `json:"admin_id" description:"研究员ID"`
 }
 
-// ResearchVarietyTagRelationListByAdminId 根据研究员ID获取标签关系列表
-func ResearchVarietyTagRelationListByAdminId(adminId int) (list []*ResearchVarietyTagRelation, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM research_variety_tag_relation WHERE admin_id = ?`
-	_, err = o.Raw(sql, adminId).QueryRows(&list)
-	return
-}
-
 type ResearchTagRelation struct {
 	Id              int `json:"id"`
 	ResearchGroupId int `json:"research_group_id" description:"分组ID"`

+ 1 - 84
models/wx_user.go

@@ -2,7 +2,6 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -33,12 +32,6 @@ type WxUser struct {
 	UserLabel           string    `description:"查研观向用户标签"`
 }
 
-func AddWxUser(item *WxUser) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(item)
-	return
-}
-
 func GetWxUserByMobile(mobile string) (item *WxUser, err error) {
 	o := orm.NewOrmUsingDB("weekly")
 	sql := `SELECT * FROM wx_user WHERE mobile = ? LIMIT 1`
@@ -46,53 +39,13 @@ func GetWxUserByMobile(mobile string) (item *WxUser, err error) {
 	return
 }
 
-// GetWxUserByMobileCountryCode 根据手机号和区号获取用户信息
-func GetWxUserByMobileCountryCode(mobile, countryCode string) (item *WxUser, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM wx_user WHERE mobile = ? `
-	sql += ` and country_code in ("","` + countryCode + `") `
-	sql += ` LIMIT 1 `
-	err = o.Raw(sql, mobile).QueryRow(&item)
-	return
-}
-
-func GetWxUserByUserId(userId int) (item *WxUser, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM wx_user WHERE user_id=? `
-	err = o.Raw(sql, userId).QueryRow(&item)
-	return
-}
-
-// 更新wxUser信息
+// Update 更新wxUser信息
 func (wxUser *WxUser) Update(cols []string) (err error) {
 	o := orm.NewOrmUsingDB("weekly")
 	_, err = o.Update(wxUser, cols...)
 	return
 }
 
-type PotentialUserItem struct {
-	UserId          int       `description:"用户id"`
-	RealName        string    `description:"姓名"`
-	CountryCode     string    `description:"区号,86、852、886等"`
-	Mobile          string    `description:"手机号"`
-	Email           string    `description:"邮箱"`
-	CreatedTime     string    `description:"注册时间"`
-	ApplyMethod     int       `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
-	CompanyName     string    `description:"客户名称"`
-	ViewTotal       int       `description:"累计阅读次数"`
-	LastViewTime    time.Time `json:"-" description:"最后一次阅读时间"`
-	LastViewTimeStr string    `description:"最后一次阅读时间"`
-	FromType        string    `description:"report:研报,teleconference:电话会"`
-	BusinessCardUrl string    `description:"名片"`
-	Source          int       `description:"来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询,5:电话会"`
-	IsDeal          int       `description:"是否标记处理,0是未处理,1是已处理"`
-}
-
-type PotentialUserListResp struct {
-	List   []*PotentialUserItem
-	Paging *paging.PagingItem `description:"分页数据"`
-}
-
 // GetWxUserByCompanyIdAndMobile 根据客户ID及手机号获取用户
 func GetWxUserByCompanyIdAndMobile(companyId int, mobile string) (item *WxUser, err error) {
 	o := orm.NewOrmUsingDB("weekly")
@@ -127,39 +80,3 @@ func DeleteWxUserAndRecordByUserId(userId int) (err error) {
 
 	return
 }
-
-// 获取这个公司下面所有用户的手机号
-func SetUserSubscribe(openId string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` UPDATE user_record SET subscribe=1,subscribe_time=NOW() WHERE open_id=? `
-	_, err = o.Raw(sql, openId).Exec()
-	return
-}
-
-type WxUserItem struct {
-	UserId              int       `description:"用户id"`
-	OpenId              string    `description:"open_id"`
-	UnionId             string    `description:"union_id"`
-	CompanyId           int       `description:"客户id"`
-	NickName            string    `description:"用户昵称"`
-	RealName            string    `description:"用户实际名称"`
-	Mobile              string    `description:"手机号码"`
-	BindAccount         string    `description:"绑定时的账号"`
-	Email               string    `description:"邮箱"`
-	Headimgurl          string    `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
-	ApplyMethod         int       `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
-	FirstLogin          int       `description:"是否第一次登陆"`
-	IsFreeLogin         int       `description:"是否免登陆,true:免登陆,false:非免登陆"`
-	LoginTime           time.Time `description:"登录时间"`
-	CreatedTime         time.Time `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次修改时间"`
-	SessionKey          string    `description:"微信小程序会话密钥"`
-	CompanyName         string    `description:"公司名称"`
-	IsRegister          int       `description:"是否注册:1:已注册,0:未注册"`
-	CountryCode         string    `description:"手机国家区号"`
-	OutboundMobile      string    `description:"外呼手机号"`
-	OutboundCountryCode string    `description:"外呼手机号区号"`
-	IsMsgOutboundMobile int       `description:"是否弹窗过绑定外呼手机号区号"`
-	IsMaker             int       `description:"是否是决策人"`
-	Source              int
-}

+ 1 - 27
models/yb/price_driven_tag.go

@@ -5,7 +5,7 @@ import (
 	"time"
 )
 
-// VarietyClassify 标签库分类表
+// PriceDrivenTag 标签库分类表
 type PriceDrivenTag struct {
 	Id             int       `orm:"column(id);pk" `
 	VarietyTagId   int       `json:"variety_tag_id" description:"标签ID"`
@@ -20,24 +20,6 @@ func (priceDrivenTag *PriceDrivenTag) TableName() string {
 	return "yb_price_driven_tag"
 }
 
-// Add 新增
-func (priceDrivenTag *PriceDrivenTag) Add() (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(priceDrivenTag)
-	if err != nil {
-		return
-	}
-	priceDrivenTag.Id = int(lastId)
-	return
-}
-
-// Update 更新
-func (priceDrivenTag *PriceDrivenTag) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Update(priceDrivenTag, cols...)
-	return
-}
-
 // GetPriceDrivenTagList 获取价格驱动标签列表
 func GetPriceDrivenTagList() (list []*PriceDrivenTag, err error) {
 	o := orm.NewOrmUsingDB("weekly")
@@ -45,11 +27,3 @@ func GetPriceDrivenTagList() (list []*PriceDrivenTag, err error) {
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
-
-// GetPriceDrivenTagByTagId 通过标签ID获取价格驱动标签
-func GetPriceDrivenTagByTagId(tagId int) (item *PriceDrivenTag, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM yb_price_driven_tag WHERE variety_tag_id = ? LIMIT 1`
-	err = o.Raw(sql, tagId).QueryRow(&item)
-	return
-}

+ 45 - 45
routers/commentsRouter.go

@@ -7,51 +7,6 @@ import (
 
 func init() {
 
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "List",
-            Router: `/chat`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicDelete",
-            Router: `/topic/delete`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicDetail",
-            Router: `/topic/detail`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicEdit",
-            Router: `/topic/edit`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicList",
-            Router: `/topic/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage/correlation:CorrelationChartClassifyController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage/correlation:CorrelationChartClassifyController"],
         beego.ControllerComments{
             Method: "AddChartClassify",
@@ -2221,6 +2176,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"],
+        beego.ControllerComments{
+            Method: "EdbSourceList",
+            Router: `/edb_source/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"],
         beego.ControllerComments{
             Method: "EiaSteoClassify",
@@ -5956,6 +5920,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"],
+        beego.ControllerComments{
+            Method: "SystemConfig",
+            Router: `/config`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"],
         beego.ControllerComments{
             Method: "SysMenuButtons",
@@ -6028,6 +6001,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"],
+        beego.ControllerComments{
+            Method: "SysRoleMenuAuthList",
+            Router: `/role/menu/auth_list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"],
+        beego.ControllerComments{
+            Method: "SysRoleMenuAuthSave",
+            Router: `/role/menu/auth_save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"],
+        beego.ControllerComments{
+            Method: "ButtonList",
+            Router: `/role/menu/buttons`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers:SysRoleController"],
         beego.ControllerComments{
             Method: "SysRoleMenusList",

+ 0 - 6
routers/router.go

@@ -11,7 +11,6 @@ import (
 	"github.com/beego/beego/v2/server/web"
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	"hongze/hz_eta_api/controllers"
-	"hongze/hz_eta_api/controllers/ai"
 	"hongze/hz_eta_api/controllers/data_manage"
 	"hongze/hz_eta_api/controllers/data_manage/correlation"
 	future_good2 "hongze/hz_eta_api/controllers/data_manage/future_good"
@@ -245,11 +244,6 @@ func init() {
 				&supply_analysis.VarietyController{},
 			),
 		),
-		web.NSNamespace("/ai",
-			web.NSInclude(
-				&ai.AiController{},
-			),
-		),
 		web.NSNamespace("/en_permission",
 			web.NSInclude(
 				&english_report.EnPermissionController{},

+ 0 - 47
services/aiser/ai.go

@@ -1,47 +0,0 @@
-package aiser
-
-import (
-	"encoding/json"
-	"errors"
-	"github.com/rdlucklib/rdluck_tools/http"
-	"hongze/hz_eta_api/utils"
-)
-
-func ChatAutoMsg(prompt string, model int) (result string, err error) {
-	if utils.ChatUrl == `` {
-		err = errors.New("chatGPT服务未配置")
-		return
-	}
-	chatUrl := `http://8.210.169.38:8399/v1/chat/auto_msg`
-	param := make(map[string]interface{})
-	param["Prompt"] = prompt
-	param["Model"] = model
-	postData, err := json.Marshal(param)
-	if err != nil {
-		return result, err
-	}
-
-	utils.FileLogChat.Info("postData:" + string(postData))
-	body, err := http.HttpPost(chatUrl, string(postData), "application/json; charset=utf-8")
-	if err != nil {
-		return result, err
-	}
-	utils.FileLogChat.Info("result:" + string(body))
-
-	resp := new(ChatAutoMsgResp)
-	err = json.Unmarshal(body, &resp)
-	if err != nil {
-		return result, err
-	}
-	if resp.Ret != 200 {
-		return resp.Msg, nil
-	}
-	result = resp.Data
-	return result, nil
-}
-
-type ChatAutoMsgResp struct {
-	Ret  int
-	Data string
-	Msg  string
-}

文件差异内容过多而无法显示
+ 0 - 46
services/data/base_from_smm.go


+ 24 - 1
services/data/excel_info.go

@@ -777,6 +777,28 @@ func GetDataByTableDataConfig(tableDataConfig TableDataConfig) (resultResp reque
 		data = append(data, tmpEdbInfoData)
 	}
 
+	// 处理一下数据格式
+	for _, d := range data {
+		for k2, d2 := range d.Data {
+			// 可能有ShowValue非数值, 转换一下报错则continue
+			vf, e := strconv.ParseFloat(d2.ShowValue, 64)
+			if e != nil {
+				continue
+			}
+			d.Data[k2].ShowValue = utils.FormatTableDataShowValue(vf)
+		}
+	}
+	for _, d := range textRowListDataResp {
+		for k2, d2 := range d {
+			// 可能有ShowValue非数值, 转换一下报错则continue
+			vf, e := strconv.ParseFloat(d2.ShowValue, 64)
+			if e != nil {
+				continue
+			}
+			d[k2].ShowValue = utils.FormatTableDataShowValue(vf)
+		}
+	}
+
 	resultResp = request.TableDataReq{
 		EdbInfoIdList: edbInfoIdList,
 		Sort:          tableDataConfig.Sort,
@@ -1307,7 +1329,8 @@ func GetMixedTableCellData(config [][]request.MixedTableCellDataReq) (newMixedTa
 
 				}
 				if val, ok2 := tmpDateValMap[cell.DataTime]; ok2 {
-					cell.ShowValue = fmt.Sprint(val)
+					//cell.ShowValue = fmt.Sprint(val)
+					cell.ShowValue = utils.FormatTableDataShowValue(val)
 				}
 			}
 

+ 11 - 334
services/report.go

@@ -405,16 +405,18 @@ func UpdateReportEs(reportId int, publishState int) (err error) {
 			}
 		}
 	} else {
-		permissionList, tmpErr := models.GetChartPermissionNameFromMappingByKeyword(reportInfo.ClassifyNameSecond, "rddp")
-		if tmpErr != nil {
-			return
-		}
-		categoryArr := make([]string, 0)
-		for i := 0; i < len(permissionList); i++ {
-			categoryArr = append(categoryArr, permissionList[i].PermissionName)
+		if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+			permissionList, tmpErr := models.GetChartPermissionNameFromMappingByKeyword(reportInfo.ClassifyNameSecond, "rddp")
+			if tmpErr != nil {
+				return
+			}
+			categoryArr := make([]string, 0)
+			for i := 0; i < len(permissionList); i++ {
+				categoryArr = append(categoryArr, permissionList[i].PermissionName)
+			}
+			aliasArr, _ := addCategoryAliasToArr(categoryArr)
+			categories = strings.Join(aliasArr, ",")
 		}
-		aliasArr, _ := addCategoryAliasToArr(categoryArr)
-		categories = strings.Join(aliasArr, ",")
 	}
 
 	// 新增报告ES
@@ -576,331 +578,6 @@ func UpdatePublishedReportToEs() (err error) {
 	return
 }
 
-// MigrateOldReport 迁移今年旧数据
-func MigrateOldReport() (err error) {
-	// 查询本年度报告
-	// 20220616查询本年度周报
-	reportList, err := models.GetMigrateReportList()
-	if err != nil {
-		fmt.Println("获取今年报告失败, Err: " + err.Error())
-		return
-	}
-	lenReport := len(reportList)
-
-	frequencyMap := map[string]string{
-		"day":      "日度",
-		"week":     "周度",
-		"two_week": "双周度",
-		"month":    "月度",
-		"other":    "不定时",
-	}
-	classifyList, err := models.GetAllClassify()
-	if err != nil {
-		fmt.Println("获取分类失败, Err: " + err.Error())
-		return
-	}
-	classifyIdName := make(map[int]string, 0)
-	classifyNameId := make(map[string]int, 0)
-	classifyIdParentId := make(map[int]int, 0)
-	for i := 0; i < len(classifyList); i++ {
-		classifyIdName[classifyList[i].Id] = classifyList[i].ClassifyName
-		classifyNameId[classifyList[i].ClassifyName] = classifyList[i].Id
-		classifyIdParentId[classifyList[i].Id] = classifyList[i].ParentId
-	}
-	typeList, err := models.GetReportChapterTypeList()
-	if err != nil {
-		fmt.Println("获取章节类型失败, Err: " + err.Error())
-		return
-	}
-	typeIdName := make(map[int]string, 0)
-	typeIdSort := make(map[int]int, 0)
-	for i := 0; i < len(typeList); i++ {
-		typeIdName[typeList[i].ReportChapterTypeId] = typeList[i].ReportChapterTypeName
-		typeIdSort[typeList[i].ReportChapterTypeId] = typeList[i].Sort
-	}
-
-	// 报告ID集合
-	idArr := make([]int, 0)
-	for i := 0; i < lenReport; i++ {
-		//idArr = append(idArr, strconv.Itoa(reportList[i].ResearchReportId))
-		idArr = append(idArr, reportList[i].ResearchReportId)
-	}
-	//idStr := strings.Join(idArr, ",")
-
-	// 获取报告章节
-	reportTypeList, err := models.GetResearchReportTypeListByReportIds(idArr)
-	if err != nil {
-		fmt.Println("获取报告章节失败, Err: " + err.Error())
-		return
-	}
-	// 获取非晨周报权限mapping
-	reportPermissionList, err := models.GetChapterPermissionMappingByResearchReportIds(idArr)
-	if err != nil {
-		fmt.Println("获取报告权限失败, Err: " + err.Error())
-		return
-	}
-	reportTypeListMap := make(map[int][]*models.ResearchReportType, 0)
-	reportPermissionListMap := make(map[int][]*models.ChartPermissionChapterMapping, 0)
-	for i := 0; i < lenReport; i++ {
-		// 报告章节map
-		rid := reportList[i].ResearchReportId
-		reportTypeMap := make([]*models.ResearchReportType, 0)
-		for ii := 0; ii < len(reportTypeList); ii++ {
-			if rid == reportTypeList[ii].ResearchReportId {
-				reportTypeMap = append(reportTypeMap, reportTypeList[ii])
-			}
-		}
-		reportTypeListMap[rid] = reportTypeMap
-		// 报告权限map
-		reportPermissionMap := make([]*models.ChartPermissionChapterMapping, 0)
-		for iii := 0; iii < len(reportPermissionList); iii++ {
-			if rid == reportPermissionList[iii].ReportChapterTypeId {
-				reportPermissionMap = append(reportPermissionMap, reportPermissionList[iii])
-			}
-		}
-		reportPermissionListMap[rid] = reportPermissionMap
-	}
-
-	// 获取章节内容
-	typeIdArr := make([]int, 0)
-	for i := 0; i < len(reportTypeList); i++ {
-		//typeIdArr = append(typeIdArr, strconv.Itoa(reportTypeList[i].ResearchReportTypeId))
-		typeIdArr = append(typeIdArr, reportTypeList[i].ResearchReportTypeId)
-	}
-	//typeIdStr := strings.Join(typeIdArr, ",")
-	reportContentList, err := models.GetResearchReportTypeContentListByReportTypeIds(typeIdArr)
-	if err != nil {
-		fmt.Println("获取报告内容失败, Err: " + err.Error())
-		return
-	}
-	// 获取章节ticker
-	reportTickerList, err := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdArr)
-	if err != nil {
-		fmt.Println("获取报告ticker失败, Err: " + err.Error())
-		return
-	}
-	reportContentListMap := make(map[int][]*models.ResearchReportTypeContent, 0)
-	reportTickerListMap := make(map[int][]*models.ResearchReportTypeTicker, 0)
-	for i := 0; i < len(reportTypeList); i++ {
-		// 报告章节map
-		rtid := reportTypeList[i].ResearchReportTypeId
-		reportContentMap := make([]*models.ResearchReportTypeContent, 0)
-		for ii := 0; ii < len(reportContentList); ii++ {
-			if rtid == reportContentList[ii].ResearchReportTypeId {
-				reportContentMap = append(reportContentMap, reportContentList[ii])
-			}
-		}
-		reportContentListMap[rtid] = reportContentMap
-		// 报告ticker
-		reportTickerMap := make([]*models.ResearchReportTypeTicker, 0)
-		for iii := 0; iii < len(reportTickerList); iii++ {
-			if rtid == reportTickerList[iii].ResearchReportTypeId {
-				reportTickerMap = append(reportTickerMap, reportTickerList[iii])
-			}
-		}
-		reportTickerListMap[rtid] = reportTickerMap
-	}
-
-	fmt.Printf("开始写入, 总数:%d\n", lenReport)
-	countSuccess := 0
-	countIgnore := 0
-	for i := 0; i < lenReport; i++ {
-		fmt.Printf("正在写入报告:%d\n", reportList[i].ResearchReportId)
-		// 报告去重
-		exist, tmpErr := models.GetNewReportExist(reportList[i].ResearchReportId)
-		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
-			fmt.Println("查询是否迁移过该报告失败: ", reportList[i].ResearchReportId)
-			return
-		}
-		if exist != nil {
-			countIgnore += 1
-			fmt.Println("跳过报告: ", reportList[i].ResearchReportId)
-			continue
-		}
-
-		newReportId := 0
-		item := reportList[i]
-		reportTypeList = reportTypeListMap[item.ResearchReportId]
-		isIgnore := false
-		// 报告内容、章节
-		if len(reportTypeList) > 0 {
-			newReport := new(models.Report)
-			newReport.AddType = 1
-			// 标题去掉【】
-			re, _ := regexp.Compile("^【[^】]*】")
-			newTitle := re.ReplaceAllString(item.ResearchReportName, "")
-			prefix := ""
-			newReport.Title = prefix + newTitle
-			newReport.Author = item.Author
-			newReport.Frequency = frequencyMap[item.Type]
-			newReport.CreateTime = item.CreatedTime
-			modifyTime, _ := time.ParseInLocation(utils.FormatDateTime, item.CreatedTime, time.Local)
-			newReport.ModifyTime = modifyTime
-			newReport.State = 2
-			newReport.PublishTime = item.ResearchReportDate
-			newReport.Stage = item.Periods
-			newReport.MsgIsSend = 1
-			newReport.ThsMsgIsSend = 1
-			newReport.ReportVersion = 1
-			newReport.OldReportId = item.ResearchReportId
-
-			if item.Type == utils.REPORT_TYPE_DAY || item.Type == utils.REPORT_TYPE_WEEK {
-				// 晨周报
-				newReport.HasChapter = 1
-				newReport.ChapterType = item.Type
-				classifyIdFirst := 0
-				classifyNameFirst := ""
-				if item.Type == utils.REPORT_TYPE_DAY {
-					newReport.ClassifyIdFirst = classifyNameId["晨报"]
-					newReport.ClassifyNameFirst = "晨报"
-					classifyIdFirst = classifyNameId["晨报"]
-					classifyNameFirst = "晨报"
-				} else {
-					newReport.ClassifyIdFirst = classifyNameId["周报"]
-					newReport.ClassifyNameFirst = "周报"
-					classifyIdFirst = classifyNameId["周报"]
-					classifyNameFirst = "周报"
-				}
-
-				newDayWeekReport := new(models.CreateDayWeekReport)
-				newChapterList := make([]*models.CreateDayWeekReportChapter, 0)
-				for _, chapter := range reportTypeList {
-					chapterAndTicker := new(models.CreateDayWeekReportChapter)
-					tmpTickerList := make([]*models.ReportChapterTicker, 0)
-					chapterContents := ""
-					// 章节内容列表
-					contentList := reportContentListMap[chapter.ResearchReportTypeId]
-					for _, contents := range contentList {
-						chapterContents += contents.Content
-					}
-					chapterContents, tmpErr := replaceReportBase64ToImg(chapterContents)
-					if tmpErr != nil {
-						fmt.Println("转换章节base64图片失败, Err: " + tmpErr.Error())
-						return
-					}
-					state := 2
-					if chapterContents == "" {
-						state = 1
-					}
-					contentSub, tmpErr := GetReportContentSub(chapterContents)
-					if tmpErr != nil {
-						fmt.Println("解析 ContentSub 失败, Err: " + tmpErr.Error())
-						return
-					}
-					chapterContents = html.EscapeString(chapterContents)
-					contentSub = html.EscapeString(contentSub)
-
-					chapterAndTicker.Chapter = &models.ReportChapter{
-						ReportType:        item.Type,
-						ClassifyIdFirst:   classifyIdFirst,
-						ClassifyNameFirst: classifyNameFirst,
-						TypeId:            chapter.TypeId,
-						TypeName:          typeIdName[chapter.TypeId],
-						Sort:              typeIdSort[chapter.TypeId],
-						Title:             chapter.ResearchReportTypeTitle,
-						AddType:           1,
-						Author:            item.Author,
-						Content:           chapterContents,
-						ContentSub:        contentSub,
-						Stage:             item.Periods,
-						Trend:             chapter.Trend,
-						IsEdit:            1,
-						PublishState:      state,
-						PublishTime:       chapter.LastUpdatedTime,
-						CreateTime:        chapter.CreatedTime,
-						ModifyTime:        chapter.LastUpdatedTime,
-					}
-					// 晨报数据指标
-					if item.Type == utils.REPORT_TYPE_DAY {
-						tickerList := reportTickerListMap[chapter.ResearchReportTypeId]
-						for _, ticker := range tickerList {
-							tmpTickerList = append(tmpTickerList, &models.ReportChapterTicker{
-								Sort:       ticker.Sort,
-								Ticker:     ticker.Ticker,
-								CreateTime: ticker.CreatedTime,
-								UpdateTime: ticker.LastUpdatedTime,
-							})
-						}
-					}
-					chapterAndTicker.TickerList = tmpTickerList
-					newChapterList = append(newChapterList, chapterAndTicker)
-				}
-
-				newDayWeekReport.Report = newReport
-				newDayWeekReport.ChapterList = newChapterList
-				// 新增晨周报
-				newId, newErr := models.CreateMigrateNewDayWeekReport(newDayWeekReport)
-				if newErr != nil {
-					fmt.Println("新增晨周报失败, Err: " + newErr.Error())
-					return
-				}
-				newReportId = newId
-			} else {
-				// 非晨周报
-				if item.ReportVariety == "铁矿库存点评" {
-					item.ReportVariety = "铁矿库存数据点评"
-				}
-				//newReport.Abstract = newTitle
-				newReport.ClassifyIdSecond = classifyNameId[item.ReportVariety]
-				newReport.ClassifyNameSecond = item.ReportVariety
-				newReport.ClassifyIdFirst = classifyIdParentId[newReport.ClassifyIdSecond]
-				newReport.ClassifyNameFirst = classifyIdName[newReport.ClassifyIdFirst]
-				// 忽略分类不完整的
-				if newReport.ClassifyIdFirst == 0 || newReport.ClassifyIdSecond == 0 || newReport.ClassifyNameFirst == "" || newReport.ClassifyNameSecond == "" {
-					isIgnore = true
-					countIgnore += 1
-					continue
-				}
-
-				reportContents := ""
-				for _, chapter := range reportTypeList {
-					// 章节内容列表
-					contentList := reportContentListMap[chapter.ResearchReportTypeId]
-					for _, contents := range contentList {
-						reportContents += contents.Content
-					}
-				}
-				reportContents, tmpErr := replaceReportBase64ToImg(reportContents)
-				if tmpErr != nil {
-					fmt.Println("转换报告base64图片失败, Err: " + tmpErr.Error())
-					return
-				}
-				newReport.State = 2
-				if reportContents == "" {
-					newReport.State = 1
-				}
-				reportContentSub, tmpErr := GetReportContentSub(reportContents)
-				if tmpErr != nil {
-					fmt.Println("解析 ContentSub 失败, Err: " + tmpErr.Error())
-					return
-				}
-				newReport.Content = html.EscapeString(reportContents)
-				newReport.ContentSub = html.EscapeString(reportContentSub)
-
-				// 报告权限列表
-				oldMapping := reportPermissionListMap[item.ResearchReportId]
-				// 新增非晨周报
-				newId, newErr := models.CreateMigrateNewOtherReport(newReport, oldMapping)
-				if newErr != nil {
-					fmt.Println("新增非晨周报失败, Err: " + newErr.Error())
-					return
-				}
-				newReportId = newId
-			}
-		}
-		// 更新音频
-		if !isIgnore {
-			countSuccess += 1
-			fmt.Printf("写入报告%d成功, 新ID%d\n", reportList[i].ResearchReportId, newReportId)
-			//go UpdateReportVideo(newReportId)
-			UpdateReportVideo(newReportId)
-		}
-	}
-	fmt.Printf("结束写入, 总数:%d, 忽略:%d, 成功:%d\n", lenReport, countIgnore, countSuccess)
-
-	return
-}
-
 // 替换报告内容中的base64图片
 func replaceReportBase64ToImg(content string) (newContent string, err error) {
 	if content == "" {

+ 1 - 1
services/report_push.go

@@ -16,7 +16,7 @@ import (
 
 // SendReportToEmail 发送报告邮件
 func SendReportToEmail(report *models.ReportDetail) (err error) {
-	if utils.SystemType == "custom" {
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
 		// 客户不做报告邮件推送
 		return
 	}

+ 21 - 12
services/sandbox/sandbox.go

@@ -15,18 +15,22 @@ import (
 )
 
 // AddSandbox 新增沙盘
-func AddSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string) (resp *sandbox.SandboxSaveResp, err error) {
-	resp = new(sandbox.SandboxSaveResp)
+func AddSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string, ignoreVariety bool) (resp *sandbox.SandboxSaveResp, err error) {
 	// 获取产品权限详情
-	chartPermissionInfo, err := company.GetChartPermissionListById(req.ChartPermissionId)
-	if err != nil {
-		return
+	var permissionName string
+	if !ignoreVariety {
+		chartPermissionInfo, e := company.GetChartPermissionListById(req.ChartPermissionId)
+		if e != nil {
+			err = e
+			return
+		}
+		permissionName = chartPermissionInfo.PermissionName
 	}
 	//沙盘主表信息
 	sandboxInfo := &sandbox.Sandbox{
 		Name:                utils.TrimStr(req.Name),
 		ChartPermissionId:   req.ChartPermissionId,
-		ChartPermissionName: chartPermissionInfo.PermissionName,
+		ChartPermissionName: permissionName,
 		CurrVersion:         1,
 		Code:                GenerateCode(),
 		Content:             req.Content,
@@ -74,7 +78,7 @@ func AddSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string)
 }
 
 // UpdateSandbox 更新沙盘
-func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string) (resp *sandbox.SandboxSaveResp, err error, errMsg string) {
+func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string, ignoreVariety bool) (resp *sandbox.SandboxSaveResp, err error, errMsg string) {
 	resp = new(sandbox.SandboxSaveResp)
 	// 获取沙盘版本信息
 	sandboxVersion, err := sandbox.GetSandboxVersionBySandboxVersionCode(req.SandboxVersionCode)
@@ -114,16 +118,21 @@ func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName strin
 	}
 
 	// 获取产品权限详情
-	chartPermissionInfo, err := company.GetChartPermissionListById(req.ChartPermissionId)
-	if err != nil {
-		return
+	var permissionName string
+	if !ignoreVariety {
+		chartPermissionInfo, e := company.GetChartPermissionListById(req.ChartPermissionId)
+		if e != nil {
+			err = e
+			return
+		}
+		permissionName = chartPermissionInfo.PermissionName
 	}
 
 	//如果只更新了沙盘名称,那么只去修改最新版本的沙盘名称,而不去累计版本
 	if isUpdateName == true && isUpdateContent == false {
 		sandboxInfo.Name = utils.TrimStr(req.Name)
 		sandboxInfo.ChartPermissionId = req.ChartPermissionId
-		sandboxInfo.ChartPermissionName = chartPermissionInfo.PermissionName
+		sandboxInfo.ChartPermissionName = permissionName
 		sandboxInfo.Content = req.Content
 		sandboxInfo.PicUrl = utils.TrimStr(req.PicUrl)
 		sandboxInfo.OpUserId = opUserId
@@ -167,7 +176,7 @@ func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName strin
 	} else {
 		sandboxInfo.Name = utils.TrimStr(req.Name)
 		sandboxInfo.ChartPermissionId = req.ChartPermissionId
-		sandboxInfo.ChartPermissionName = chartPermissionInfo.PermissionName
+		sandboxInfo.ChartPermissionName = permissionName
 		sandboxInfo.CurrVersion = sandboxInfo.CurrVersion + 1
 		sandboxInfo.Content = req.Content
 		sandboxInfo.PicUrl = utils.TrimStr(req.PicUrl)

+ 12 - 0
services/system.go

@@ -108,3 +108,15 @@ func CheckRaiAdmin(adminId int) (isRai bool, err error) {
 	}
 	return
 }
+
+// GetMenuTreeRecursive 递归菜单树
+func GetMenuTreeRecursive(list []*system.SysMenuItem, parentId int) []*system.SysMenuItem {
+	res := make([]*system.SysMenuItem, 0)
+	for _, v := range list {
+		if v.ParentId == parentId {
+			v.Children = GetMenuTreeRecursive(list, v.MenuId)
+			res = append(res, v)
+		}
+	}
+	return res
+}

+ 0 - 3
services/task.go

@@ -34,13 +34,10 @@ func Task() {
 
 	//手工数据表格导入后的指标库刷新
 	go ImportManualDataRefresh()
-	//ImportManualDataRefresh()
 
 	//修复用户关注标识
 	//GetWxUsersSubscribe()
 
-	//go UpdateOldTrialUsersManualAuth()
-
 	go AutoInsertAdminOperateRecordToDB()
 
 	// TODO:修复权限

+ 3 - 0
services/user.go

@@ -39,6 +39,9 @@ func SwitchHzUserEnabledByMobile(opEnabled int, mobile string) (err error) {
 
 // DeleteHzUserByMobile 根据手机号删除弘则研究下的联系人
 func DeleteHzUserByMobile(mobile string) (err error) {
+	if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
+		return
+	}
 	if mobile == "" {
 		return
 	}

+ 66 - 0
utils/common.go

@@ -2006,3 +2006,69 @@ func GetPredictEdbDayListByNum(startDate time.Time, num int, frequency string) (
 	}
 	return
 }
+
+// FormatTableDataShowValue 格式化自定表格显示数据
+func FormatTableDataShowValue(x float64) (res string) {
+	if x > 1 || x < -1 {
+		res = decimal.NewFromFloat(x).Round(2).String()
+		return
+	}
+	// 介于-1到1之间
+	xStr := strconv.FormatFloat(x, 'f', -10, 64)
+
+	// 使用 strings.Split 函数将小数拆分为整数部分和小数部分
+	xParts := strings.Split(xStr, ".")
+	if len(xParts) < 2 {
+		res = fmt.Sprint(x)
+		return
+	}
+
+	// 计算小数部分的长度,即小数点后面的位数
+	xDecimals := len(xParts[1])
+	if xDecimals > 2 {
+		parts := xParts[1]
+		// 小数点后小于等于两位, 直接拼接返回
+		partLen := len(xParts[1])
+		if partLen <= 2 {
+			res = xParts[0] + "." + parts
+			return
+		}
+		// 找出第一个有效数字, 算出n
+		one := 0
+		for k, p := range parts {
+			// 48->0
+			if p != 48 {
+				if one == 0 {
+					one = k + 1
+				}
+			}
+		}
+		n := partLen - one
+		if n >= 1 {
+			n -= 1
+		} else {
+			one -= 1
+		}
+
+		var partFloat float64
+		partInt, _ := strconv.Atoi(parts)
+		partFloat, _ = decimal.NewFromInt(int64(partInt)).Div(decimal.NewFromFloat(math.Pow(10, float64(n)))).Float64()
+		partFloat = math.Round(partFloat)
+		partFloat, _ = decimal.NewFromFloat(partFloat).Div(decimal.NewFromFloat(math.Pow(10, float64(one+1)))).Float64()
+		resParts := strings.Split(fmt.Sprint(partFloat), ".")
+		resPart := ""
+		if len(resParts) > 1 {
+			resPart = resParts[1]
+		} else {
+			resPart = resParts[0]
+		}
+		res = xParts[0] + "." + resPart
+	}
+
+	if xDecimals < 2 {
+		xDecimalsStr := xParts[1]
+		x, _ = strconv.ParseFloat(xParts[0]+"."+xDecimalsStr, 64)
+		res = xParts[0] + "." + xDecimalsStr
+	}
+	return
+}

+ 0 - 9
utils/config.go

@@ -23,8 +23,6 @@ var (
 	Re          error        //redis错误
 )
 
-var SystemType string // 系统类型; hz:弘则;trial:试用平台;custom:客户
-
 // 基础配置
 var (
 	STATIC_DIR       string
@@ -221,13 +219,6 @@ func init() {
 		panic(any(Re))
 	}
 
-	// 系统类型
-	systemType, err := web.AppConfig.String("system_type")
-	if err != nil {
-		panic(any("配置文件读取system_type错误 " + err.Error()))
-	}
-	SystemType = systemType
-
 	// 项目中文名称
 	appNameCn, err := web.AppConfig.String("app_name_cn")
 	if err != nil {

+ 6 - 0
utils/constants.go

@@ -299,3 +299,9 @@ const (
 
 // BusinessCodeSalt 商家编码盐值
 const BusinessCodeSalt = "dr7WY0OZgGR7upw1"
+
+// 自用商户号
+const (
+	BusinessCodeSandbox = "E2023080700" // 试用平台
+	BusinessCodeRelease = "E2023080900" // 生产环境
+)

部分文件因为文件数量过多而无法显示