From afcc1d49d4b5529292e88a11d501600987b15e2c Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Fri, 18 Oct 2024 14:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hfkj/controller/SysSettingController.java | 4 +++- .../com/hfkj/dao/SecDictionaryMapperExt.java | 21 +++++++++++++++++++ .../service/sec/SecDictionaryService.java | 10 +++++++-- .../sec/impl/SecDictionaryServiceImpl.java | 14 ++++++------- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/bweb/src/main/java/com/hfkj/controller/SysSettingController.java b/bweb/src/main/java/com/hfkj/controller/SysSettingController.java index af13e38..3b12dd3 100644 --- a/bweb/src/main/java/com/hfkj/controller/SysSettingController.java +++ b/bweb/src/main/java/com/hfkj/controller/SysSettingController.java @@ -51,10 +51,12 @@ public class SysSettingController { if (body == null || body.getBigDecimal("exchangeRate") == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + SecDictionary where = new SecDictionary(); + where.setCodeType("GOLD_COIN_EXCHANGE_RATE"); // 查询数据 SecDictionary dictionary = secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0); dictionary.setCodeValue(body.getBigDecimal("exchangeRate").toString()); - secDictionaryService.editData(dictionary); + secDictionaryService.update(where, dictionary); // 刷新缓存 secDictionaryService.refreshCache(); diff --git a/service/src/main/java/com/hfkj/dao/SecDictionaryMapperExt.java b/service/src/main/java/com/hfkj/dao/SecDictionaryMapperExt.java index 997fe10..9138bc6 100644 --- a/service/src/main/java/com/hfkj/dao/SecDictionaryMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/SecDictionaryMapperExt.java @@ -1,7 +1,28 @@ package com.hfkj.dao; +import com.hfkj.entity.SecDictionary; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + /** * mapper扩展类 */ public interface SecDictionaryMapperExt { + + @Update({ + "" + }) + void update(@Param("codeType") String codeType, @Param("codeValue") String codeValue, @Param("data") SecDictionary data); } diff --git a/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java b/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java index be240a3..d5798cf 100644 --- a/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java +++ b/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java @@ -12,10 +12,16 @@ import java.util.List; public interface SecDictionaryService { /** - * 编辑数据 + * 增加 * @param data */ - void editData(SecDictionary data); + void insert(SecDictionary data); + + /** + * 修改 + * @param data + */ + void update(SecDictionary where,SecDictionary data); /** * 获取数据字典 diff --git a/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java b/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java index db5433a..7a91dd1 100644 --- a/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/sec/impl/SecDictionaryServiceImpl.java @@ -27,13 +27,13 @@ public class SecDictionaryServiceImpl implements SecDictionaryService { private final String CACHE_KEY = "SEC_DICTIONARY"; @Override - public void editData(SecDictionary data) { - SecDictionary dictionary = getDictionary(data.getCodeType(), data.getCodeValue()); - if (dictionary == null) { - secDictionaryMapper.insert(data); - } else { - secDictionaryMapper.updateByPrimaryKey(data); - } + public void insert(SecDictionary data) { + secDictionaryMapper.insert(data); + } + + @Override + public void update(SecDictionary where,SecDictionary data) { + secDictionaryMapper.update(where.getCodeType(), where.getCodeValue(), data); } @Override