mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
字典类型下拉列表接口
This commit is contained in:
@@ -72,6 +72,18 @@ func GetDictType(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, res.ReturnOK())
|
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 添加字典类型
|
// @Summary 添加字典类型
|
||||||
// @Description 获取JSON
|
// @Description 获取JSON
|
||||||
// @Tags 字典类型
|
// @Tags 字典类型
|
||||||
|
|||||||
@@ -63,6 +63,26 @@ func (e *DictType) Get() (DictType, error) {
|
|||||||
return doc, nil
|
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) {
|
func (e *DictType) GetPage(pageSize int, pageIndex int) ([]DictType, int32, error) {
|
||||||
var doc []DictType
|
var doc []DictType
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user