Browse Source

将selectByParams添加至BaseMapper中以便公共使用

NorthLan 7 years ago
parent
commit
f2a88a6155

+ 1 - 3
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/mapper/SysDicMapper.kt

@@ -13,6 +13,4 @@ import org.springframework.stereotype.Repository
  * @since 2018-02-06
  */
 @Repository
-interface SysDicMapper : BaseMapper<SysDic> {
-    fun selectByParams(params: MutableMap<String, Any>?): MutableList<SysDic>
-}
+interface SysDicMapper : BaseMapper<SysDic>

+ 1 - 1
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/service/ISysDicService.kt

@@ -37,5 +37,5 @@ interface ISysDicService : BaseService<SysDic> {
      * 更新缓存项
      * TODO 同时通知其他系统
      */
-    fun modifySysDic(sysDic: SysDic): SysDic
+    fun modifySysDic(data: SysDic): SysDic
 }

+ 5 - 5
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/service/impl/SysDicServiceImpl.kt

@@ -51,18 +51,18 @@ class SysDicServiceImpl : ServiceImpl<SysDicMapper, SysDic>(), ISysDicService {
 
     //    @CacheEvict(CACHEKEYS.SYS, key = "'dic_key_' + #sysDic.key")
     @Suppress("UNCHECKED_CAST")
-    override fun modifySysDic(sysDic: SysDic): SysDic {
-        baseMapper.updateById(sysDic)
+    override fun modifySysDic(data: SysDic): SysDic {
+        baseMapper.updateById(data)
         // 更新缓存
         val cache = cacheManager.getCache(CACHEKEYS.SYS)
         val cachedList: MutableList<SysDic>? = cache[CACHE_KEY_ALL].get() as MutableList<SysDic>
         cachedList?.let {
-            it.removeIf { it.id == sysDic.id }
-            it.add(sysDic)
+            it.removeIf { it.id == data.id }
+            it.add(data)
             cache.put(CACHE_KEY_ALL, cachedList)
         }
 
-        return sysDic
+        return data
     }
 
     override fun getOneByKey(key: String, value: String?, sort: Int?): SysDic? {

+ 1 - 1
zen-api/src/main/kotlin/com/gxzc/zen/api/util/SysDicUtil.kt

@@ -6,7 +6,7 @@ import com.gxzc.zen.common.util.SpringContextHolder
 
 /**
  * 系统字典工具类
- * 获取字典均是从缓存中获取
+ * 缓存中获取
  * @author NorthLan
  * @date 2018/3/17
  * @url https://noahlan.com

+ 3 - 1
zen-core/src/main/kotlin/com/gxzc/zen/common/base/BaseMapper.kt

@@ -10,4 +10,6 @@ import com.baomidou.mybatisplus.mapper.BaseMapper
  * @date 2018/1/24
  * @url https://noahlan.com
  */
-interface BaseMapper<T> : BaseMapper<T>
+interface BaseMapper<T> : BaseMapper<T> {
+    fun selectByParams(params: MutableMap<String, Any>?): MutableList<T>
+}