| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.timer; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.biz.zbom.ZbomIAMService; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.doumee.service.system.SystemDictService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Method; |
| | | |
| | | /** |
| | | * @author å
¬ä¼å·:ç¥äºä¸ç¬ |
| | | * @since 2023-07-26 11:44 |
| | | */ |
| | | @Component("weixinTokenJob") |
| | | public class WeixinTokenJobBiz implements JobService { |
| | | private static final Logger log = LoggerFactory.getLogger(WeixinTokenJobBiz.class); |
| | | |
| | | @Autowired |
| | | SystemDictDataBiz systemDictService; |
| | | @Override |
| | | public void run(String params,String module) { |
| | | Method method = null; |
| | | try { |
| | | systemDictService.updWxMiniToken(); |
| | | log.info("\n ======== 宿¶ä»»å¡å·²æ§è¡ï¼weixinTokenJob.========"+module); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | String getPreFixPath(String resourceCode, String targetCode); |
| | | |
| | | |
| | | void updWxMiniToken(); |
| | | } |
| | |
| | | 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; |
| | |
| | | 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 appID,String appKey,String token) { |
| | | String appId = queryByCode(Constants.WX_MINI_CONFIG,appID).getCode(); |
| | | String appSecret = queryByCode(Constants.WX_MINI_CONFIG,appKey).getCode(); |
| | | //çæå¾®ä¿¡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 systemDictData = queryByCode(Constants.WX_MINI_CONFIG,token); |
| | | systemDictData.setCode(json.getString("access_token")); |
| | | systemDictData.setUpdateTime(new Date()); |
| | | updateByIdNew(systemDictData); |
| | | |
| | | appId = queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_APPID_PERSONNEL).getCode(); |
| | | appSecret = queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_APPID_PERSONNEL).getCode(); |
| | | //çæå¾®ä¿¡token |
| | | url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+appSecret; |
| | | response = HttpsUtil.sendGet(url); |
| | | json = JSONObject.parseObject(response); |
| | | systemDictData = queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_TOKEN_PERSONNEL); |
| | | systemDictData.setCode(json.getString("access_token")); |
| | | systemDictData.setUpdateTime(new Date()); |
| | | updateByIdNew(systemDictData); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åégetè¯·æ± |
| | | * @param url 请æ±URL |
| | | * @param param 请æ±åæ° key:value urlæºå¸¦åæ° æè
æ åå¯ä¸å¡« |
| | | * @return |
| | | */ |
| | | public static String doGet(String url, Map<String, String> param) { |
| | | // å建Httpclient对象 |
| | | CloseableHttpClient httpclient = HttpClients.createDefault(); |
| | | String resultString = ""; |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | // å建uri |
| | | URIBuilder builder = new URIBuilder(url); |
| | | if (param != null) { |
| | | for (String key : param.keySet()) { |
| | | builder.addParameter(key, param.get(key)); |
| | | } |
| | | } |
| | | URI uri = builder.build(); |
| | | // å建http GETè¯·æ± |
| | | HttpGet httpGet = new HttpGet(uri); |
| | | // æ§è¡è¯·æ± |
| | | response = httpclient.execute(httpGet); |
| | | // 夿è¿åç¶ææ¯å¦ä¸º200 |
| | | if (response.getStatusLine().getStatusCode() == 200) { |
| | | resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (response != null) { |
| | | response.close(); |
| | | } |
| | | httpclient.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return resultString; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.web.reqeust; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2024/7/11 17:19 |
| | | */ |
| | | @Data |
| | | @ApiModel("è·åå
容海æ¥å享ç ") |
| | | public class ContentShareImgDto { |
| | | @ApiModelProperty(value = "å¾çå°åï¼å®æ´è·¯å¾") |
| | | private String imgurl; |
| | | @ApiModelProperty(value = "å享类å 0æµ·æ¥å享 1ä¸è½½å¸¦å°ç¨åºç ") |
| | | private int type; |
| | | |
| | | } |
| | |
| | | */ |
| | | void logOff(Long memberId); |
| | | |
| | | |
| | | /** |
| | | * æ´æ°å®¢æ·ç«¯å°ç¨åºToken |
| | | */ |
| | | void updWxMiniToken(); |
| | | } |
| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.Users; |
| | | import com.doumee.dao.web.reqeust.ContentShareImgDto; |
| | | import com.doumee.dao.web.reqeust.EditUsersRequest; |
| | | import com.doumee.dao.web.response.AccountResponse; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | void editUserInfo(EditUsersRequest editUsersRequest); |
| | | |
| | | /** |
| | | * æ´æ°å工端å°ç¨åºToken |
| | | */ |
| | | void updWxMiniToken(); |
| | | |
| | | String getContentShareImg(Users loginUserInfo, ContentShareImgDto param); |
| | | } |
| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.oss.FileModel; |
| | | import com.doumee.core.utils.CodeVerifyUtils; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.utils.*; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.dao.business.CustomerUserMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.hikvision.artemis.sdk.util.HttpUtils; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import okhttp3.OkHttpClient; |
| | | import okhttp3.Request; |
| | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void updWxMiniToken(){ |
| | | DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); |
| | | ThreadContext.bind(manager); |
| | | String appId = systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_APPID_CUSTOMER).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_SECRET_CUSTOMER).getCode(); |
| | | //çæå¾®ä¿¡token |
| | | String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+appSecret; |
| | | String response = Constants.doGet(url,null); |
| | | JSONObject json = JSONObject.parseObject(response); |
| | | SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_TOKEN_CUSTOMER); |
| | | systemDictData.setCode(json.getString("access_token")); |
| | | systemDictData.setUpdateTime(new Date()); |
| | | systemDictDataBiz.updateByIdNew(systemDictData); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.reqeust.EditUsersRequest; |
| | | import com.doumee.dao.web.reqeust.ContentShareImgDto; |
| | | import com.doumee.dao.web.response.AccountResponse; |
| | | import com.doumee.service.business.UsersService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public String getContentShareImg(Users loginUserInfo, ContentShareImgDto param){ |
| | | if(StringUtils.isBlank(param.getImgurl())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | String url = null; |
| | | if(param.getType() == 1){ |
| | | //å¤å¾å¸¦äºç»´ç ä¸è½½ |
| | | String path = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.RESOURCE_PATH).getCode(); |
| | | String folder = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.USERS_FILE).getCode(); |
| | | }else{ |
| | | //å
容å享海æ¥å¾ç |
| | | |
| | | |
| | | } |
| | | return url; |
| | | } |
| | | @Override |
| | | public String getUserCard(Users users){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE, Constants.RESOURCE_PATH).getCode(); |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void updWxMiniToken(){ |
| | | DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); |
| | | ThreadContext.bind(manager); |
| | | String appId = systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_APPID_PERSONNEL).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_SECRET_PERSONNEL).getCode(); |
| | | //çæå¾®ä¿¡token |
| | | String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+appSecret; |
| | | String response = Constants.doGet(url,null); |
| | | JSONObject json = JSONObject.parseObject(response); |
| | | SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_TOKEN_PERSONNEL); |
| | | systemDictData.setCode(json.getString("access_token")); |
| | | systemDictData.setUpdateTime(new Date()); |
| | | systemDictDataBiz.updateByIdNew(systemDictData); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | * @date 2023/03/21 14:49 |
| | | */ |
| | | long count(SystemDict systemDict); |
| | | |
| | | } |
| | |
| | | package com.doumee.service.system.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.doumee.core.model.PageData; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | Wrapper<SystemDict> wrapper = new QueryWrapper<>(systemDict); |
| | | return systemDictMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | @Autowired |
| | | private CustomerUserService customerUserService; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @ApiOperation(value = "客æ·ç«¯å°ç¨åºç»é", notes = "客æ·ç«¯å°ç¨åº") |
| | | @GetMapping("/wxLoginCustomer") |
| | |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true) |
| | | }) |
| | | public ApiResponse testToken () { |
| | | memberService.updWxMiniToken(); |
| | | systemDictDataBiz.updWxMiniToken(); |
| | | return ApiResponse.success("æ´æ°æå"); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "è·åå享å°ç¨åºäºç»´ç ï¼å¾çæµï¼imgæ ç¾srcæå®ï¼", notes = "客æ·ç«¯å°ç¨åº") |
| | |
| | | import com.doumee.dao.web.reqeust.EditMemberRequest; |
| | | import com.doumee.dao.web.reqeust.EditShopDTO; |
| | | import com.doumee.dao.web.reqeust.EditUsersRequest; |
| | | import com.doumee.dao.web.reqeust.ContentShareImgDto; |
| | | import com.doumee.dao.web.response.AccountResponse; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.doumee.service.business.ShopService; |
| | |
| | | public ApiResponse<String> getUserCard() { |
| | | return ApiResponse.success(usersService.getUserCard(this.getLoginUserInfo())); |
| | | } |
| | | @ApiOperation(value = "è·åå
容å享海æ¥", notes = "è·åå
容å享海æ¥ï¼å å°ç¨åºç ") |
| | | @PostMapping("/getContentShareImg") |
| | | public ApiResponse<String> getContentShareImg(@RequestBody ContentShareImgDto param) { |
| | | return ApiResponse.success(usersService.getContentShareImg(this.getLoginUserInfo(),param)); |
| | | } |
| | | |
| | | |
| | | } |