Ver código fonte

Merge remote-tracking branch 'origin/dm' into dm

Roc 1 mês atrás
pai
commit
a35c1e0e28

+ 1 - 1
controllers/ai/ai.go

@@ -322,7 +322,7 @@ func (this *AiController) TopicEdit() {
 		br.ErrMsg = "获取数据失败!Err:" + err.Error()
 		return
 	}
-	if topic != nil && topic.AiChatTopicId != req.AiChatTopicId {
+	if topic != nil && topic.AiChatTopicId != req.AiChatTopicId && topic.AiChatTopicId > 0 {
 		br.Msg = "话题名称已存在,请重新修改!"
 		return
 	}

+ 1 - 1
controllers/data_manage/chart_classify.go

@@ -822,7 +822,7 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 		br.ErrMsg = "获取父级目录下的同名分类失败, Err: " + e.Error()
 		return
 	}
-	if exists != nil {
+	if exists != nil && exists.ChartClassifyId > 0 {
 		br.Msg = "移动失败,分类名称已存在"
 		return
 	}

+ 3 - 3
controllers/data_manage/chart_framework.go

@@ -232,7 +232,7 @@ func (this *ChartFrameworkController) Add() {
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ChartFrameworkId > 0 {
 			br.Msg = "框架名称已存在"
 			return
 		}
@@ -358,7 +358,7 @@ func (this *ChartFrameworkController) Edit() {
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ChartFrameworkId > 0 {
 			br.Msg = "框架名称已存在"
 			return
 		}
@@ -542,7 +542,7 @@ func (this *ChartFrameworkController) Rename() {
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ChartFrameworkId > 0 {
 			br.Msg = "框架名称已存在"
 			return
 		}

+ 4 - 4
controllers/ppt_english.go

@@ -141,7 +141,7 @@ func (this *PptEnglishController) AddPpt() {
 			br.ErrMsg = "获取数据异常,Err:" + err.Error()
 			return
 		}
-		if item != nil {
+		if item != nil && item.PptId > 0 {
 			br.Msg = "标题已存在,不可重复添加"
 			br.IsSendEmail = false
 			return
@@ -265,7 +265,7 @@ func (this *PptEnglishController) EditPpt() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.PptId != int(req.PptId) {
+	if item != nil && item.PptId != int(req.PptId) && item.PptId > 0 {
 		br.Msg = "标题已存在,不可重复添加"
 		br.IsSendEmail = false
 		return
@@ -714,7 +714,7 @@ func (this *PptEnglishController) SaveLog() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.PptId != int(req.PptId) {
+	if item != nil && item.PptId != int(req.PptId) && item.PptId > 0 {
 		br.Msg = "标题已存在,不可重复添加"
 		br.IsSendEmail = false
 		return
@@ -1086,7 +1086,7 @@ func (this *PptEnglishController) TitleCheck() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.PptId != pptId {
+	if item != nil && item.PptId != pptId && item.PptId > 0 {
 		br.Msg = "标题已存在,不可重复添加"
 		br.IsSendEmail = false
 		return

+ 4 - 4
controllers/ppt_v2.go

@@ -141,7 +141,7 @@ func (this *PptV2Controller) AddPpt() {
 			br.ErrMsg = "获取数据异常,Err:" + err.Error()
 			return
 		}
-		if item != nil && item.PptId != int(req.PptId) {
+		if item != nil && item.PptId != int(req.PptId) && item.PptId > 0 {
 			br.Msg = "标题已存在,不可重复添加"
 			br.IsSendEmail = false
 			return
@@ -265,7 +265,7 @@ func (this *PptV2Controller) EditPpt() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.PptId != int(req.PptId) {
+	if item != nil && item.PptId != int(req.PptId) && item.PptId > 0 {
 		br.Msg = "标题已存在,不可重复添加"
 		br.IsSendEmail = false
 		return
@@ -683,7 +683,7 @@ func (this *PptV2Controller) SaveLog() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.PptId != int(req.PptId) {
+	if item != nil && item.PptId != int(req.PptId) && item.PptId > 0 {
 		br.Msg = "标题已存在,不可重复添加"
 		br.IsSendEmail = false
 		return
@@ -1263,7 +1263,7 @@ func (this *PptV2Controller) TitleCheck() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.PptId != pptId {
+	if item != nil && item.PptId != pptId && item.PptId > 0 {
 		br.Msg = "标题已存在,不可重复添加"
 		br.IsSendEmail = false
 		return

+ 2 - 2
controllers/report_author.go

@@ -117,7 +117,7 @@ func (this *ReportAuthorController) AddAuthor() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.Id > 0 {
 		br.Msg = "已存在该作者"
 		br.ErrMsg = "已存在该作者"
 		br.IsSendEmail = false
@@ -175,7 +175,7 @@ func (this *ReportAuthorController) EditAuthor() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	if otherItem != nil {
+	if otherItem != nil && otherItem.Id > 0 {
 		br.Msg = "已存在该作者名称,请重新输入"
 		br.ErrMsg = "已存在该作者名称,请重新输入"
 		br.IsSendEmail = false

+ 2 - 2
controllers/report_chapter_type.go

@@ -137,7 +137,7 @@ func (this *ReportChapterTypeController) Add() {
 		br.ErrMsg = "获取重名报告章节失败, Err:" + e.Error()
 		return
 	}
-	if exists != nil {
+	if exists != nil && exists.ReportChapterTypeId > 0 {
 		br.Msg = "章节名称已存在"
 		return
 	}
@@ -268,7 +268,7 @@ func (this *ReportChapterTypeController) Edit() {
 		br.ErrMsg = "获取重名报告章节失败, Err:" + e.Error()
 		return
 	}
-	if exists != nil && exists.ReportChapterTypeId != req.ReportChapterTypeId {
+	if exists != nil && exists.ReportChapterTypeId != req.ReportChapterTypeId && exists.ReportChapterTypeId > 0 {
 		br.Msg = "章节名称已存在"
 		return
 	}

+ 2 - 2
controllers/sys_admin.go

@@ -650,7 +650,7 @@ func (this *SysAdminController) Edit() {
 		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminName:" + req.AdminName
 		return
 	}
-	if item != nil && item.AdminId != req.AdminId {
+	if item != nil && item.AdminId != req.AdminId && item.AdminId > 0 {
 		br.Msg = "账号名称已存在,请重新输入"
 		return
 	}
@@ -693,7 +693,7 @@ func (this *SysAdminController) Edit() {
 			br.ErrMsg = "邮箱获取用户信息失败, Err: " + e.Error()
 			return
 		}
-		if emailUser != nil && emailUser.AdminId != adminInfo.AdminId {
+		if emailUser != nil && emailUser.AdminId != adminInfo.AdminId && emailUser.AdminId > 0 {
 			br.Msg = "邮箱已存在, 请检查"
 			return
 		}

+ 1 - 1
controllers/sys_department.go

@@ -106,7 +106,7 @@ func (this *SysDepartmentController) Edit() {
 		return
 	}
 	if item != nil {
-		if item.DepartmentId != req.DepartmentId {
+		if item.DepartmentId != req.DepartmentId && item.DepartmentId > 0 {
 			br.Msg = "名称已存在,请重新输入"
 			return
 		}

+ 1 - 1
controllers/sys_group.go

@@ -114,7 +114,7 @@ func (this *SysGroupController) Edit() {
 		return
 	}
 	if item != nil {
-		if item.GroupId != req.GroupId {
+		if item.GroupId != req.GroupId && item.GroupId > 0 {
 			br.Msg = "名称已存在,请重新输入"
 			return
 		}

+ 3 - 2
controllers/sys_role.go

@@ -8,10 +8,11 @@ import (
 	"eta/eta_api/services/eta_forum"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 type SysRoleController struct {
@@ -122,7 +123,7 @@ func (this *SysRoleController) Edit() {
 		br.ErrMsg = "获取重名角色失败, Err: " + e.Error()
 		return
 	}
-	if exists != nil && exists.RoleId != item.RoleId {
+	if exists != nil && exists.RoleId != item.RoleId && exists.RoleId > 0 {
 		br.Msg = "名称已存在,请重新输入"
 		return
 	}

+ 1 - 1
controllers/sys_team.go

@@ -110,7 +110,7 @@ func (this *SysTeamController) Edit() {
 		return
 	}
 	if item != nil {
-		if item.GroupId != req.TeamId {
+		if item.GroupId != req.TeamId && item.GroupId > 0 {
 			br.Msg = "名称已存在,请重新输入"
 			return
 		}

+ 2 - 2
controllers/target.go

@@ -610,7 +610,7 @@ func (this *TargetController) TargetAdd() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.TradeCode != "" {
 		br.Msg = "指标名称已存在"
 		return
 	}
@@ -674,7 +674,7 @@ func (this *TargetController) TargetEdit() {
 		return
 	}
 	if item != nil {
-		if req.TradeCode != item.TradeCode {
+		if req.TradeCode != item.TradeCode && item.TradeCode != "" {
 			br.Msg = "指标名称已存在"
 			return
 		}

+ 7 - 0
models/data_manage/edb_terminal.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
+	"gorm.io/gorm"
 	"time"
 )
 
@@ -36,6 +37,12 @@ type EdbTerminalItem struct {
 	CreateTime   string `description:"创建时间"`
 }
 
+func (e *EdbTerminalItem) AfterFind(db *gorm.DB) (err error) {
+	e.ModifyTime = utils.GormDateStrToDateTimeStr(e.ModifyTime)
+	e.CreateTime = utils.GormDateStrToDateTimeStr(e.CreateTime)
+	return
+}
+
 type EdbTerminalCode struct {
 	TerminalCode string `description:"终端编码,用于配置在机器上"`
 	Source       int    `description:"指标来源类型"`

+ 2 - 1
models/out_link.go

@@ -121,6 +121,7 @@ func (ol *OutLink) GetPageItemsByCondition(startSize, pageSize int, condition st
 		total = int(totalNull.Int64)
 	}
 	sql += ` LIMIT ?,?`
-	err = o.Raw(sql, pars, startSize, pageSize).Find(&items).Error
+	pars = append(pars, startSize, pageSize)
+	err = o.Raw(sql, pars...).Find(&items).Error
 	return
 }

+ 5 - 3
models/target.go

@@ -272,7 +272,8 @@ func GetEdbinfoItemList(condition string, pars []interface{}, startSize, pageSiz
 			sql += condition
 		}
 		sql += ` ORDER BY a.create_date DESC LIMIT ?,? `
-		err = o.Raw(sql, mobile, pars, startSize, pageSize).Find(&items).Error
+		pars = append(pars, startSize, pageSize)
+		err = o.Raw(sql, utils.ForwardPars(pars, mobile)...).Find(&items).Error
 	} else {
 		sql = `SELECT DISTINCT a.*,b.classify_name FROM edbinfo AS a
                      LEFT JOIN edbdata_classify AS b on a.classify_id=b.classify_id
@@ -281,7 +282,8 @@ func GetEdbinfoItemList(condition string, pars []interface{}, startSize, pageSiz
 			sql += condition
 		}
 		sql += ` ORDER BY a.create_date DESC LIMIT ?,? `
-		err = o.Raw(sql, pars, startSize, pageSize).Find(&items).Error
+		pars = append(pars, startSize, pageSize)
+		err = o.Raw(sql, pars...).Find(&items).Error
 	}
 	return
 }
@@ -438,7 +440,7 @@ type EdbdataClassifyList struct {
 	ClassifyId   int
 	ClassifyName string
 	ParentId     int
-	Child        []*EdbdataClassify
+	Child        []*EdbdataClassify `gorm:"-"`
 	TradeCode    string
 	UniqueCode   string
 }

+ 1 - 1
services/data/base_from_bloomberg.go

@@ -61,7 +61,7 @@ func BloombergIndexSource2Edb(req BloombergIndexSource2EdbReq, lang string) (edb
 		err = fmt.Errorf("获取指标是否存在失败, err: %s", e.Error())
 		return
 	}
-	if exist != nil {
+	if exist != nil && exist.EdbInfoId > 0 {
 		skip = true
 		return
 	}

+ 1 - 1
services/data/base_from_business.go

@@ -39,7 +39,7 @@ func BusinessIndexSource2Edb(req BusinessIndexSource2EdbReq, lang string) (edb *
 		err = fmt.Errorf("获取指标是否存在失败, err: %s", e.Error())
 		return
 	}
-	if exist != nil {
+	if exist != nil && exist.EdbInfoId > 0 {
 		skip = true
 		return
 	}

+ 23 - 0
utils/common.go

@@ -2902,3 +2902,26 @@ func GormDateStrToDateStr(originalString string) (formatStr string) {
 
 	return
 }
+
+// GormDateStrToDateTimeStr
+// @Description: gorm日期字符串格式转正常显示的日期时间字符串
+// @param originalString
+// @return formatStr
+func GormDateStrToDateTimeStr(originalString string) (formatStr string) {
+	formatStr = originalString
+	if !strings.Contains(originalString, "T") {
+		return
+	}
+
+	// 解析原始字符串
+	t, err := time.Parse(FormatDateWallWithLoc, originalString)
+	if err != nil {
+		fmt.Println("Error parsing time:", err)
+		return
+	}
+
+	// 重新格式化时间
+	formatStr = t.Format(FormatDateTime)
+
+	return
+}