Browse Source

fix:新增批量删除接口

Roc 7 months ago
parent
commit
065640a85b
4 changed files with 642 additions and 468 deletions
  1. 122 5
      controllers/manual_edb.go
  2. 5 5
      models/manual_edb.go
  3. 10 1
      routers/commentsRouter.go
  4. 505 457
      services/data/manual.go

+ 122 - 5
controllers/manual_edb.go

@@ -662,7 +662,7 @@ func (this *TargetController) EditExcelData() {
 // @Description 获取研究员指标
 // @Param	request	body models.BatchAddEdbReq true "type json string"
 // @Success 200 {object} models.TargetItemListResp
-// @router /target/edb/batch/list [get]
+// @router /target/edb/batch/list [post]
 func (this *TargetController) BatchEdbList() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
@@ -698,7 +698,7 @@ func (this *TargetController) BatchEdbList() {
 
 	// 是否加到指标库
 	condition += ` AND a.is_join_edb = ? `
-	pars = append(pars, req.IsJoinEdb)
+	pars = append(pars, 0)
 
 	//超管账号可以查看分类下的所有频度数据
 	if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
@@ -744,7 +744,7 @@ func (this *TargetController) BatchEdbList() {
 	// 所属用户
 	lenUser := len(req.UserIdList)
 	if lenUser > 0 {
-		condition += ` AND a.user_id in (` + utils.GetOrmInReplace(lenClassify) + `) `
+		condition += ` AND a.user_id in (` + utils.GetOrmInReplace(lenUser) + `) `
 		pars = append(pars, req.UserIdList)
 	}
 
@@ -775,7 +775,7 @@ func (this *TargetController) BatchEdbList() {
 // BatchAddEdbCheck
 // @Title 新增校验
 // @Description 新增校验
-// @Param	request	body data_manage.BloombergSourceBatchAddCheckReq true "type json string"
+// @Param	request	body data_manage.BatchManualEdbReq true "type json string"
 // @Success 200 string "操作成功"
 // @router /target/edb/batch/add/check [post]
 func (this *TargetController) BatchAddEdbCheck() {
@@ -854,7 +854,7 @@ func (this *TargetController) BatchAddEdbCheck() {
 		// 所属用户
 		lenUser := len(req.UserIdList)
 		if lenUser > 0 {
-			condition += ` AND a.user_id in (` + utils.GetOrmInReplace(lenClassify) + `) `
+			condition += ` AND a.user_id in (` + utils.GetOrmInReplace(lenUser) + `) `
 			pars = append(pars, req.UserIdList)
 		}
 
@@ -1126,6 +1126,123 @@ func (this *TargetController) BatchAdd() {
 	br.IsAddLog = true
 }
 
+// BatchDelEdbCheck
+// @Title 新增校验
+// @Description 新增校验
+// @Param	request	body data_manage.BatchManualEdbReq true "type json string"
+// @Success 200 string "操作成功"
+// @router /target/edb/batch/del/check [post]
+func (this *TargetController) BatchDelEdbCheck() {
+	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
+	}
+
+	var req models.BatchManualEdbReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+
+	req.Keyword = strings.TrimSpace(req.Keyword)
+
+	var condition string
+	var pars []interface{}
+
+	// 就是为了找出已经加入指标库的指标
+	condition += ` AND a.is_join_edb = ? `
+	pars = append(pars, 1)
+
+	//超管账号可以查看分类下的所有频度数据
+	if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
+		classifyList, err := models.GetEdbdataClassify(int64(sysUser.AdminId))
+		if err != nil {
+			br.Msg = "获取分类数据失败"
+			br.Msg = "获取拥有的分类数据失败,Err:" + err.Error()
+			return
+		}
+
+		num := len(classifyList)
+		if num > 0 {
+			classifyIdList := make([]int, 0)
+			for _, v := range classifyList {
+				classifyIdList = append(classifyIdList, v.ClassifyId)
+			}
+			condition += ` AND a.classify_id in (` + utils.GetOrmInReplace(num) + `) `
+			pars = append(pars, classifyIdList)
+		}
+
+	}
+
+	if req.ListAll {
+		// 关键词
+		if req.Keyword != "" {
+			condition += ` AND (a.SEC_NAME like ?  or a.TRADE_CODE like ? )`
+			pars = utils.GetLikeKeywordPars(pars, req.Keyword, 2)
+		}
+
+		// 所属分类
+		lenFrequency := len(req.FrequencyList)
+		if lenFrequency > 0 {
+			condition += ` AND a.frequency in (` + utils.GetOrmInReplace(lenFrequency) + `) `
+			pars = append(pars, req.FrequencyList)
+		}
+
+		// 所属分类
+		lenClassify := len(req.ClassifyIdList)
+		if lenClassify > 0 {
+			condition += ` AND a.classify_id in (` + utils.GetOrmInReplace(lenClassify) + `) `
+			pars = append(pars, req.ClassifyIdList)
+		}
+
+		// 所属用户
+		lenUser := len(req.UserIdList)
+		if lenUser > 0 {
+			condition += ` AND a.user_id in (` + utils.GetOrmInReplace(lenUser) + `) `
+			pars = append(pars, req.UserIdList)
+		}
+
+		lenTradeList := len(req.TradeCodeList)
+		// 指标
+		if lenTradeList > 0 {
+			condition += ` AND a.TRADE_CODE not in (` + utils.GetOrmInReplace(lenTradeList) + `) `
+			pars = append(pars, req.TradeCodeList)
+		}
+	} else {
+		lenTradeList := len(req.TradeCodeList)
+		if lenTradeList <= 0 {
+			br.Msg = "请选择指标"
+			br.ErrMsg = "请选择指标"
+			return
+		}
+		// 指标
+		if lenTradeList > 0 {
+			condition += ` AND a.TRADE_CODE in (` + utils.GetOrmInReplace(lenTradeList) + `) `
+			pars = append(pars, req.TradeCodeList)
+		}
+	}
+
+	list, err := models.GetEdbInfoList(condition, pars, 0, 0)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	br.Data = list
+	br.Msg = "校验成功"
+	br.Ret = 200
+	br.Success = true
+}
+
 // BatchDel
 // @Title 批量删除
 // @Description 批量新增

+ 5 - 5
models/manual_edb.go

@@ -184,13 +184,13 @@ func UpdateManualIsJoinEdbStatus(edbCode string, isJoinEdb int8) (err error) {
 
 // BatchManualEdbReq 指标数据结构体
 type BatchManualEdbReq struct {
-	IsJoinEdb      int      `form:"IsJoinEdb" description:"是否加到指标库,0:未加到指标库"`
+	//IsJoinEdb      int      `form:"IsJoinEdb" description:"是否加到指标库,0:未加到指标库"`
 	FrequencyList  []string `description:"频度;枚举值:日度、周度、月度、季度、半年度、年度"`
 	Keyword        string   `description:"关键字"`
 	ClassifyIdList []int    `description:"所选品种id列表"`
 	UserIdList     []int    `description:"所选用户id列表"`
-	ListAll        bool     `form:"ListAll" description:"列表全选"`
-	TradeCodeList  []string `form:"IndexCodes" description:"全选为false时, 该数组为选中; 全选为true时, 该数组为不选的指标"`
-	PageSize       int      `form:"PageSize"`
-	CurrentIndex   int      `form:"CurrentIndex"`
+	ListAll        bool     `form:"ListAll" json:"ListAll" description:"列表全选"`
+	TradeCodeList  []string `form:"TradeCodeList" json:"TradeCodeList" description:"全选为false时, 该数组为选中; 全选为true时, 该数组为不选的指标"`
+	PageSize       int      `form:"PageSize" json:"PageSize"`
+	CurrentIndex   int      `form:"CurrentIndex" form:"CurrentIndex"`
 }

+ 10 - 1
routers/commentsRouter.go

@@ -9268,11 +9268,20 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers:TargetController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:TargetController"],
+        beego.ControllerComments{
+            Method: "BatchDelEdbCheck",
+            Router: `/target/edb/batch/del/check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers:TargetController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:TargetController"],
         beego.ControllerComments{
             Method: "BatchEdbList",
             Router: `/target/edb/batch/list`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})

File diff suppressed because it is too large
+ 505 - 457
services/data/manual.go


Some files were not shown because too many files changed in this diff