package com.gxzc.zen.api.util import com.gxzc.zen.api.sys.model.SysDictValue import com.gxzc.zen.common.util.SpringContextHolder import com.gxzc.zen.rpc.api.sys.RDictService /** * 字典工具类 * @author NorthLan * @date 2018/5/7 * @url https://noahlan.com */ object SysDictUtil { // private var dictValueService: RDictService? = null // get() { // if (field == null) { // field = RpcUtil.getReference(RDictService::class.java, "1.0") // } // return field // } private var dictValueService: RDictService? = null get() { if (field == null) { field = SpringContextHolder.getBean(RDictService::class.java) } return field } /** * 获取所有字典值列表 */ fun getAll(): MutableList { return dictValueService!!.getListCacheable() } /** * 根据code前缀获取字典值列表 */ fun getListByPrefix(prefix: String): MutableList { return dictValueService!!.getDictValueListByTypeCode(prefix) } /** * 根据code和value直接获取字典值 */ fun getValueByCV(code: String, value: String): SysDictValue? { return dictValueService!!.getDictValueByCodeAndValue(code, value) } /** * 根据prefix和value直接获取字典值 */ fun getValueByPV(prefix: String, value: String): SysDictValue? { return dictValueService!!.getDictValueByPrefixAndValue(prefix, value) } }