字典类型下拉列表接口

This commit is contained in:
zhangwenjian
2020-03-19 22:04:38 +08:00
parent 129ebc548d
commit 1c650ce539
2 changed files with 32 additions and 0 deletions
+12
View File
@@ -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 字典类型
+20
View File
@@ -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