You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"pure-admin/global"
|
|
"pure-admin/model"
|
|
"pure-admin/model/request"
|
|
)
|
|
|
|
func GetSysDictDataLabel(typeCode, value string) string {
|
|
var res string
|
|
|
|
cacheKey := "bkb-admin_sys_dict_labels"
|
|
labelKey := fmt.Sprintf("%s_%s", typeCode, value)
|
|
res = RedisHashGet(cacheKey, labelKey)
|
|
if res == "" {
|
|
_ = global.MG_DB.Model(&model.SysDictData{}).Select("label").Where("type_code=? AND `value`=?", typeCode, value).Scan(&res).Error
|
|
go RedisHashSet(cacheKey, labelKey, res)
|
|
}
|
|
return res
|
|
}
|
|
|
|
func GetSysDictDataList(params request.SearchDictDataParams) (err error, list interface{}) {
|
|
var lists []model.SysDictDataView
|
|
err = global.MG_DB.Model(&model.SysDictData{}).Where("type_code=? AND `status`='1'", params.TypeCode).Order("sort asc").Find(&lists).Error
|
|
return err, lists
|
|
}
|
|
|
|
func GetSysDictDataListByTypeCode(typeCode string) (list []model.SysDictDataView, err error) {
|
|
var lists []model.SysDictDataView
|
|
err = global.MG_DB.Model(&model.SysDictData{}).Where("type_code=? AND `status`='1'", typeCode).Order("sort asc").Find(&lists).Error
|
|
return lists, err
|
|
}
|
|
|
|
func checkSysDictData(typeCode, value string) bool {
|
|
if GetSysDictDataLabel(typeCode, value) != "" {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|