Browse Source

Merge remote-tracking branch 'origin/dm'

# Conflicts:
#	services/ppt/ppt_group.go
Roc 1 week ago
parent
commit
7677480a81

+ 2 - 2
controllers/data_manage/cross_variety/tag.go

@@ -50,7 +50,7 @@ func (c *TagController) Add() {
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.ChartTagId > 0 {
 		br.Msg = "添加失败,标签名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -115,7 +115,7 @@ func (c *TagController) Edit() {
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.ChartTagId != req.ChartTagId {
+	if item != nil && item.ChartTagId != req.ChartTagId && item.ChartTagId > 0 {
 		br.Msg = "添加失败,标签名称不能重复"
 		br.IsSendEmail = false
 		return

+ 2 - 2
controllers/data_manage/cross_variety/variety.go

@@ -49,7 +49,7 @@ func (c *VarietyController) Add() {
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.ChartVarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -114,7 +114,7 @@ func (c *VarietyController) Edit() {
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.ChartVarietyId != req.ChartVarietyId {
+	if item != nil && item.ChartVarietyId != req.ChartVarietyId && item.ChartVarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return

+ 1 - 1
controllers/data_manage/supply_analysis/variety.go

@@ -224,7 +224,7 @@ func (this *VarietyController) Edit() {
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.VarietyId != req.VarietyId {
+	if item != nil && item.VarietyId != req.VarietyId && item.VarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return

+ 12 - 0
controllers/english_report/email.go

@@ -595,6 +595,18 @@ func (this *EnglishReportEmailController) Send() {
 			noCompanyIdsMap[v] = struct{}{}
 		}
 	}
+
+	// 加个缓存吧,避免重复点击
+	cacheKey := "CACHE_ENGLISH_REPORT_SEND_" + strconv.Itoa(req.ReportId)
+	if !utils.Rc.SetNX(cacheKey, 1, 300*time.Second) {
+		br.Msg = "系统处理中,请稍后重试!"
+		br.ErrMsg = "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody)
+		return
+	}
+	defer func() {
+		_ = utils.Rc.Delete(cacheKey)
+	}()
+
 	// 指定品种的客户
 	sendCompanyIds := make([]int, 0)
 	if len(req.EnPermissions) > 0 {

+ 9 - 9
models/ppt_v2_group.go

@@ -8,15 +8,15 @@ import (
 )
 
 type PptV2Group struct {
-	GroupId    int64     `gorm:"column:group_id;primaryKey" description:"ppt目录ID"`
-	GroupName  string    `description:"目录名称"`
-	AdminId    int       `description:"目录创建者账号ID"`
-	IsShare    int8      `description:"是否共享,0私有,1共享"`
-	GroupSort  int64     `description:"目录排序标识"`
-	IsShareAdd int8      `description:"是否是通过单个ppt共享生成的目录,0不是,1-是"`
-	CreateTime time.Time `orm:"auto_now_add;type(datetime)" description:"创建时间"`
-	ModifyTime time.Time `orm:"auto_now;type(datetime)" description:"修改时间"`
-	ShareTime  time.Time `description:"分享时间"`
+	GroupId    int64     `gorm:"column:group_id;type:int(11) UNSIGNED;comment:ppt目录ID;primaryKey;not null;" description:"ppt目录ID"`
+	GroupName  string    `gorm:"column:group_name;type:varchar(100);comment:目录名称;not null;" description:"目录名称"`
+	AdminId    int       `gorm:"column:admin_id;type:int(11);comment:目录创建者账号ID;not null;" description:"目录创建者账号ID"`
+	IsShare    int8      `gorm:"column:is_share;type:tinyint(2);comment:是否共享,0私有,1共享;not null;default:0;" description:"是否共享,0私有,1共享"`
+	GroupSort  int64     `gorm:"column:group_sort;type:int(11);comment:目录排序标识;not null;" description:"目录排序标识"`
+	IsShareAdd int8      `gorm:"column:is_share_add;type:tinyint(2);comment:是否是通过单个ppt共享生成的目录,0不是,1-是;not null;default:0;"  description:"是否是通过单个ppt共享生成的目录,0不是,1-是"`
+	CreateTime time.Time `gorm:"column:create_time;type:datetime;comment:创建时间;not null;default:CURRENT_TIMESTAMP;" description:"创建时间"`
+	ModifyTime time.Time `gorm:"column:modify_time;type:datetime;comment:修改时间;not null;default:CURRENT_TIMESTAMP;" description:"修改时间"`
+	ShareTime  time.Time `gorm:"column:share_time;type:datetime;comment:共享时间;default:NULL;" description:"分享时间"`
 }
 
 // GetPrivatePptGroups 获取私有目录

+ 3 - 3
models/ppt_v2_group_mapping.go

@@ -13,8 +13,8 @@ type PptV2GroupMapping struct {
 	GroupId         int64     `description:"ppt目录ID"`
 	PptSort         int64     `description:"Ppt的排序"`
 	PptId           int64     `description:"ppt ID"`
-	CreateTime      time.Time `orm:"auto_now_add;type(datetime)" description:"创建时间"`
-	ModifyTime      time.Time `orm:"auto_now;type(datetime)" description:"修改时间"`
+	CreateTime      time.Time `gorm:"column:create_time;type:datetime;comment:创建时间;not null;default:CURRENT_TIMESTAMP;"  description:"创建时间"`
+	ModifyTime      time.Time `gorm:"column:modify_time;type:datetime;comment:修改时间;not null;default:CURRENT_TIMESTAMP;" description:"修改时间"`
 	AdminId         int       `description:"移动ppt到该目录的系统用户id"`
 	AdminRealName   string    `description:"系统用户名称"`
 	ChildGroupPptId int64     `description:"设置共享后的新映射ID"`
@@ -171,7 +171,7 @@ func GetPublicGroupPptByPptIds(pptIds []string) (list []*PptV2GroupMapping, err
 	// // 导出 SQL 语句
 	// sql := qb.String()
 	sql := `select p.* from ppt_v2_group as g inner join ppt_v2_group_mapping as p on g.group_id = p.group_id where g.is_share = 1 and p.ppt_id in (?) order by g.share_time asc, p.ppt_sort asc`
-	
+
 	// 执行 SQL 语句
 	o := global.DbMap[utils.DbNameReport]
 	err = o.Raw(sql, pptIds).Find(&list).Error

+ 21 - 19
models/sandbox/sandbox_classify.go

@@ -129,25 +129,27 @@ func GetSandboxInfoCountByClassifyId(classifyId int) (count int, err error) {
 	var sql string
 	var pars []interface{}
 	if utils.DbDriverName == utils.DbDriverByDm {
-		sql = `WITH RECURSIVE sandbox_classify_cte (sandbox_classify_id, parent_id) AS (
-			SELECT sandbox_classify_id, parent_id
-			FROM sandbox_classify
-			WHERE parent_id = ?
-			UNION ALL
-			SELECT c.sandbox_classify_id, c.parent_id
-			FROM sandbox_classify c
-			INNER JOIN sandbox_classify_cte ct ON c.parent_id = ct.sandbox_classify_id
-		)
-		SELECT COUNT(1) AS count
-		FROM sandbox a
-		WHERE a.sandbox_classify_id IN (
-			SELECT sandbox_classify_id
-			FROM sandbox_classify_cte
-			UNION
-			SELECT sandbox_classify_id
-			FROM sandbox_classify
-			WHERE sandbox_classify_id = ?
-		)`
+		sql = `WITH RECURSIVE classify_tree AS (
+    -- 基础查询:获取起始节点
+    SELECT sandbox_classify_id, parent_id, 1 as level
+    FROM sandbox_classify
+    WHERE sandbox_classify_id = ?
+    
+    UNION ALL
+    
+    -- 递归查询:获取所有子节点
+    SELECT c.sandbox_classify_id, c.parent_id, t.level + 1
+    FROM sandbox_classify c
+    INNER JOIN classify_tree t ON c.parent_id = t.sandbox_classify_id
+    WHERE c.parent_id IS NOT NULL
+)
+SELECT COUNT(1) AS count 
+FROM sandbox a
+WHERE a.sandbox_classify_id IN (
+    SELECT sandbox_classify_id 
+    FROM classify_tree
+) 
+AND a.is_delete = 0`
 		pars = append(pars, classifyId, classifyId)
 	}else{
 		sql = ` SELECT COUNT(1) AS count FROM sandbox AS a

+ 4 - 0
services/ppt/ppt_group.go

@@ -194,6 +194,8 @@ func AddGroup(groupName string, adminId int, isShare int8, isSharedAdd int8) (ne
 		AdminId:    adminId,
 		IsShare:    isShare,
 		IsShareAdd: isSharedAdd,
+		CreateTime: time.Now(),
+		ModifyTime: time.Now(),
 	}
 	if isShare == 1 {
 		groupInfo.ShareTime = time.Now()
@@ -230,6 +232,8 @@ func AddGroupPptMapping(pptId int64, groupId int64, adminId int, adminRealName s
 		PptId:         pptId,
 		AdminId:       adminId,
 		AdminRealName: adminRealName,
+		CreateTime:    time.Now(),
+		ModifyTime:    time.Now(),
 		PptSort:       0,
 	}