Procházet zdrojové kódy

add:表格管理规则添加接口

zqbao před 6 měsíci
rodič
revize
c8f43de8c3

+ 57 - 0
controllers/data_manage/excel/excel_info.go

@@ -3092,3 +3092,60 @@ func (c *ExcelInfoController) GetEdbSource() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// AddExcelRule
+// @Title 添加表格规则
+// @Description 添加表格规则
+// @Param	request	body excel3.BatchRefreshExcelReq true "type json string"
+// @Success Ret=200 刷新成功
+// @router /excel_info/rule/add [post]
+func (c *ExcelInfoController) AddExcelRule() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req request.AddExcelRuleReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.LeftValue == "" {
+		br.Msg = "条件值不能为空"
+		return
+	}
+	if req.Scope == "" {
+		br.Msg = "应用选区不能为空"
+		return
+	}
+	if req.FontColor == "" {
+		br.Msg = "字体颜色不能为空"
+		return
+	}
+	if req.BackGroundColor == "" {
+		br.Msg = "背景颜色不能为空"
+		return
+	}
+	if req.RuleType == 3 && req.RightValue == "" {
+		br.Msg = "条件值不能为空"
+		return
+	}
+	err = excel2.AddExcelRule(req.LeftValue, req.RightValue, req.LeftValueType, req.RightValueType, req.RuleType, req.Scope, req.FontColor, req.BackGroundColor, req.Remark)
+	if err != nil {
+		br.Msg = "规则添加失败"
+		br.ErrMsg = "规则添加失败,Err:" + err.Error()
+		return
+	}
+	br.Msg = "规则添加成功"
+	br.Ret = 200
+	br.Success = true
+}

+ 33 - 0
models/data_manage/excel/excel_info_rule_mapping.go

@@ -0,0 +1,33 @@
+package excel
+
+import (
+	"time"
+
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type ExcelInfoRuleMapping struct {
+	ExcelInfoRuleMappingId int       `orm:"pk" description:"主键"`
+	ExcelInfoId            int       `description:"Excel信息ID"`
+	RuleType               int       `description:"规则类型"`
+	LeftValue              string    `description:"左值"`
+	LeftValueShow          string    `description:"左值前端显示"`
+	LeftValueType          int       `description:"左值类型"`
+	RightValue             string    `description:"右值"`
+	RightValueShow         string    `description:"右值前端显示"`
+	RightValueType         int       `description:"右值类型"`
+	FontColor              string    `description:"字体颜色"`
+	BackgroundColor        string    `description:"背景颜色"`
+	Remark                 string    `description:"预设颜色说明"`
+	RemarkEn               string    `description:"预设颜色英文说明"`
+	Scope                  string    `description:"作用范围"`
+	ScopeCoord             string    `description:"作用范围坐标"`
+	ScopeShow              string    `description:"作用范围坐标前端显示"`
+	CreateTime             time.Time `description:"创建时间"`
+}
+
+func (e *ExcelInfoRuleMapping) Insert() (insertId int64, err error) {
+	o := orm.NewOrmUsingDB("data")
+	insertId, err = o.Insert(e)
+	return
+}

+ 13 - 0
models/data_manage/excel/request/excel_info.go

@@ -167,3 +167,16 @@ type ShareExcelInfoReq struct {
 	ViewUserIds []int `description:"查看权限用户IDs"`
 	EditUserIds []int `description:"编辑权限用户IDs"`
 }
+
+type AddExcelRuleReq struct {
+	ExcelInfoId     int    `description:"ETA表格ID"`
+	RuleType        int    `description:"规则类型:1-大于,2-小于,3-介于,4-等于,5-发生日期"`
+	LeftValue       string `description:"条件值"`
+	LeftValueType   int    `description:"条件值的类型,1:数值,2:单元格uid,3:坐标"`
+	RightValue      string `description:"条件值, 用于介于的条件"`
+	RightValueType  int    `description:"条件值的类型,1:数值,2:单元格uid,3:坐标"`
+	FontColor       string `description:"字体颜色"`
+	BackGroundColor string `description:"背景颜色"`
+	Remark          string `description:"预设的单元格样式名称"`
+	Scope           string `description:"应用选区"`
+}

+ 4 - 0
services/data/excel/excel_info.go

@@ -649,3 +649,7 @@ func GetCustomAnalysisOpButton(sysUser *system.Admin, belongUserId int, permissi
 	}
 	return
 }
+
+func AddExcelRule(leftValue, rightValue string, leftValueType, rightValueType, ruleType int, scope, fontColor, backGroundColor, remark string) (err error) {
+	return
+}