|
@@ -4,9 +4,10 @@ import (
|
|
|
"eta_gn/eta_api/global"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
)
|
|
|
|
|
|
type Classify struct {
|
|
@@ -56,6 +57,7 @@ type ClassifyAddReq struct {
|
|
|
ClassifyName string `description:"分类名称"`
|
|
|
ParentId int `description:"父级分类id,没有父级分类传0"`
|
|
|
ChartPermissionIdList []int `description:"权限id数组"`
|
|
|
+ VisibleUserIds []int `description:"可见用户id数组"`
|
|
|
ClassifyType int `description:"分类类型:1-研报;2-PPT"`
|
|
|
IsRemind int `description:"是否开启提醒:0-关闭;1-开启"`
|
|
|
RemindTime string `description:"提醒时间:可选00:00-23:59"`
|
|
@@ -74,7 +76,36 @@ func GetClassifyById(classifyId int) (item *Classify, err error) {
|
|
|
}
|
|
|
|
|
|
// 添加分类
|
|
|
-func AddClassify(item *Classify) (err error) {
|
|
|
+func AddClassify(item *Classify, visibleUserIds []int) (err error) {
|
|
|
+ tx := global.DmSQL["rddp"].Begin()
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ tx.Commit()
|
|
|
+ }()
|
|
|
+ err = tx.Create(item).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(visibleUserIds) > 0 {
|
|
|
+ addMappingList := make([]ClassifyVisible, 0)
|
|
|
+ now := time.Now()
|
|
|
+ for _, visibleUserId := range visibleUserIds {
|
|
|
+ addMapping := ClassifyVisible{
|
|
|
+ ClassifyId: item.Id,
|
|
|
+ AdminId: visibleUserId,
|
|
|
+ CreateTime: now,
|
|
|
+ }
|
|
|
+ addMappingList = append(addMappingList, addMapping)
|
|
|
+ }
|
|
|
+ err = tx.CreateInBatches(addMappingList, utils.MultiAddNum).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
err = global.DmSQL["rddp"].Create(item).Error
|
|
|
return
|
|
|
}
|