diff --git a/apis/dictType.go b/apis/dictType.go index 5b5ce66..b8c6858 100644 --- a/apis/dictType.go +++ b/apis/dictType.go @@ -72,6 +72,18 @@ func GetDictType(c *gin.Context) { c.JSON(http.StatusOK, res.ReturnOK()) } + +func GetDictTypeOptionSelect(c *gin.Context) { + var DictType models.DictType + DictType.DictName = c.Request.FormValue("dictName") + DictType.DictId, _ = strconv.ParseInt(c.Param("dictId"), 10, 64) + result, err := DictType.GetList() + pkg.AssertErr(err, "抱歉未找到相关信息", -1) + var res models.Response + res.Data = result + c.JSON(http.StatusOK, res.ReturnOK()) +} + // @Summary 添加字典类型 // @Description 获取JSON // @Tags 字典类型 diff --git a/models/dictType.go b/models/dictType.go index 583efa6..215815f 100644 --- a/models/dictType.go +++ b/models/dictType.go @@ -63,6 +63,26 @@ func (e *DictType) Get() (DictType, error) { return doc, nil } +func (e *DictType) GetList() ([]DictType, error) { + var doc []DictType + + table := orm.Eloquent.Table("sys_dict_type") + if e.DictId != 0 { + table = table.Where("dictId = ?", e.DictId) + } + if e.DictName != "" { + table = table.Where("dictName = ?", e.DictName) + } + if e.DictType != "" { + table = table.Where("dictType = ?", e.DictType) + } + + if err := table.Where("is_del = 0").Find(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} + func (e *DictType) GetPage(pageSize int, pageIndex int) ([]DictType, int32, error) { var doc []DictType