From 2becb889a090f6602fdc76452120dfaf8185d1ac Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 17:39:45 +0800
Subject: [PATCH] 代码提交
---
server/service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java b/server/service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
index 3ae82f8..5238700 100644
--- a/server/service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
+++ b/server/service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
@@ -7,6 +7,7 @@
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.HttpsUtil;
import com.doumee.dao.business.vo.UnitCodeVo;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.dao.system.model.SystemDictData;
@@ -14,6 +15,7 @@
import com.doumee.service.system.SystemDictService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.mgt.DefaultSecurityManager;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,11 +35,11 @@
public Integer create(SystemDictData systemDictData) {
SystemDictData queryDto = new SystemDictData();
queryDto.setDictId(systemDictData.getDictId());
- queryDto.setCode(systemDictData.getCode());
+ queryDto.setLabel(systemDictData.getLabel());
queryDto.setDeleted(Boolean.FALSE);
SystemDictData dictData = systemDictDataService.findOne(queryDto);
if (dictData != null) {
- throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鍊煎凡瀛樺湪");
+ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鏍囩宸插瓨鍦�");
}
return systemDictDataService.create(systemDictData);
}
@@ -46,11 +48,11 @@
public void updateById(SystemDictData systemDictData) {
SystemDictData queryDto = new SystemDictData();
queryDto.setDictId(systemDictData.getDictId());
- queryDto.setCode(systemDictData.getLabel());
+ queryDto.setLabel(systemDictData.getLabel());
queryDto.setDeleted(Boolean.FALSE);
SystemDictData dictData = systemDictDataService.findOne(queryDto);
if (dictData != null && !dictData.getId().equals(systemDictData.getId())) {
- throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鍊煎凡瀛樺湪");
+ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鏍囩宸插瓨鍦�");
}
systemDictDataService.updateById(systemDictData);
}
@@ -182,6 +184,27 @@
String targetPath = list.stream().filter(s -> s.getLabel().equals(targetCode)).findFirst().map(s -> s.getCode()).orElse("");
return resourcePath+targetPath;
}
+ @Override
+ public void updWxMiniToken() {
+ updWxMiniTokenDo(Constants.WX_APPID_CUSTOMER,Constants.WX_SECRET_CUSTOMER,Constants.WX_TOKEN_CUSTOMER);
+ updWxMiniTokenDo(Constants.WX_APPID_PERSONNEL,Constants.WX_SECRET_PERSONNEL,Constants.WX_TOKEN_PERSONNEL);
+
+ }
+ public void updWxMiniTokenDo(String appIdKey,String secretKey,String tokenKey) {
+ DefaultSecurityManager securityManager = new DefaultSecurityManager();
+ SecurityUtils.setSecurityManager(securityManager);
+
+ String appId = queryByCode(Constants.WX_MINI_CONFIG,appIdKey).getCode();
+ String appSecret = queryByCode(Constants.WX_MINI_CONFIG,secretKey).getCode();
+ SystemDictData systemDictData = this.queryByCode(Constants.WX_MINI_CONFIG,tokenKey);
+ //鐢熸垚寰俊token
+ String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+appSecret;
+ String response = HttpsUtil.sendGet(url);
+ JSONObject json = JSONObject.parseObject(response);
+ systemDictData.setCode(json.getString("access_token"));
+ systemDictData.setUpdateTime(new Date());
+ systemDictDataService.updateById(systemDictData);
+ }
}
--
Gitblit v1.9.3