diff --git a/bweb/src/main/java/com/hfkj/controller/BsUserController.java b/bweb/src/main/java/com/hfkj/controller/BsUserController.java index af20546..b38266b 100644 --- a/bweb/src/main/java/com/hfkj/controller/BsUserController.java +++ b/bweb/src/main/java/com/hfkj/controller/BsUserController.java @@ -122,7 +122,6 @@ public class BsUserController { } - return ResponseMsgUtil.success(param); } catch (Exception e) { diff --git a/bweb/src/main/java/com/hfkj/controller/SysSettingController.java b/bweb/src/main/java/com/hfkj/controller/SysSettingController.java new file mode 100644 index 0000000..af13e38 --- /dev/null +++ b/bweb/src/main/java/com/hfkj/controller/SysSettingController.java @@ -0,0 +1,68 @@ + +package com.hfkj.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsUser; +import com.hfkj.entity.BsUserParentRel; +import com.hfkj.entity.SecDictionary; +import com.hfkj.model.ResponseData; +import com.hfkj.service.sec.SecDictionaryService; +import com.hfkj.service.user.BsUserGradeService; +import com.hfkj.service.user.BsUserParentRelService; +import com.hfkj.service.user.BsUserService; +import com.hfkj.sysenum.user.UserGradeEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @className: CmsController + * @author: HuRui + * @date: 2024/9/24 + **/ +@Controller +@RequestMapping(value = "/sysSetting") +@Api(value = "系统设置") +public class SysSettingController { + private static Logger log = LoggerFactory.getLogger(SysSettingController.class); + @Resource + private SecDictionaryService secDictionaryService; + + @RequestMapping(value="/goldCoinExchangeRate",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "元宝汇率") + public ResponseData goldCoinExchangeRate(@RequestBody JSONObject body) { + try { + if (body == null || body.getBigDecimal("exchangeRate") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 查询数据 + SecDictionary dictionary = secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0); + dictionary.setCodeValue(body.getBigDecimal("exchangeRate").toString()); + secDictionaryService.editData(dictionary); + + // 刷新缓存 + secDictionaryService.refreshCache(); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } +} 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 09e1df7..be240a3 100644 --- a/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java +++ b/service/src/main/java/com/hfkj/service/sec/SecDictionaryService.java @@ -11,6 +11,12 @@ import java.util.List; **/ public interface SecDictionaryService { + /** + * 编辑数据 + * @param data + */ + void editData(SecDictionary data); + /** * 获取数据字典 * @return 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 0c8492f..db5433a 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 @@ -26,6 +26,16 @@ public class SecDictionaryServiceImpl implements SecDictionaryService { // 缓存KEY 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); + } + } + @Override public List getDictionary() { Object cache = redisUtil.get(CACHE_KEY);