Commit 0ec7867b 0ec7867b2481e3e2f806dee80da46e6be004d200 by xianghan

1.调整部分项目文件结构,删除不需要的文件

1 parent 33ef06bb
Showing 34 changed files with 202 additions and 542 deletions
package com.topdraw.business.module.coupon.service.impl;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.coupon.repository.CouponRepository;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
......
package com.topdraw.business.module.member.level.service.impl;
import com.topdraw.business.module.member.level.domain.MemberLevel;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.member.level.repository.MemberLevelRepository;
import com.topdraw.business.module.member.level.service.MemberLevelService;
......@@ -14,8 +14,6 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.topdraw.utils.StringUtils;
import java.util.List;
/**
* @author XiangHan
* @date 2021-10-22
......
......@@ -15,7 +15,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
import com.topdraw.business.module.member.service.mapper.MemberMapper;
import com.topdraw.business.module.member.service.mapper.MemberSimpleMapper;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.utils.RedisUtils;
......@@ -28,7 +28,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
import java.util.*;
import java.util.stream.Collectors;
......
package com.topdraw.business.module.rights.service.impl;
import com.topdraw.business.module.rights.domain.Rights;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.utils.*;
import com.topdraw.business.module.rights.repository.RightsRepository;
import com.topdraw.business.module.rights.service.RightsService;
......
package com.topdraw.business.module.task.progress.service.impl;
import cn.hutool.core.map.MapUtil;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -21,10 +17,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author XiangHan
......
package com.topdraw.business.module.task.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.repository.TaskRepository;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.service.dto.TaskDTO;
import com.topdraw.business.module.task.service.mapper.TaskMapper;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......
......@@ -10,7 +10,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTvSimple;
import com.topdraw.business.module.user.iptv.repository.UserTvSimpleRepository;
import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
import com.topdraw.business.module.user.iptv.service.mapper.UserTvSimpleMapper;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.utils.RedisUtils;
......@@ -22,9 +22,7 @@ import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -32,7 +30,6 @@ import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
......
......@@ -12,7 +12,7 @@ import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.business.process.service.dto.CustomPointsResult;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.LocalConstants;
import com.topdraw.business.LocalConstants;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.GlobeExceptionMsg;
import io.swagger.annotations.Api;
......
......@@ -17,6 +17,7 @@ import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportRequest;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
......@@ -25,7 +26,8 @@ import com.topdraw.business.process.domian.weixin.*;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.RedisKeyUtil;
import com.topdraw.util.RedisKeyUtil;
import com.topdraw.config.WechatConfig;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.exception.GlobeExceptionMsg;
......@@ -33,8 +35,7 @@ import com.topdraw.resttemplate.RestTemplateClient;
import com.topdraw.util.Base64Util;
import com.topdraw.util.JSONUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeixinUtil;
import com.topdraw.weixin.service.WeChatConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -46,6 +47,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.naming.ConfigurationException;
import java.io.IOException;
import java.net.URLDecoder;
import java.sql.Timestamp;
......@@ -64,9 +66,13 @@ public class UserOperationController {
private UserOperationService userOperationService;
@Autowired
private MemberOperationService memberOperationService;
@Autowired
private UserTvService userTvService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private WechatConfig weixinInfoConfig;
private static final String SUBSCRIBE = "subscribe";
private static final String UNSUBSCRIBE = "unsubscribe";
......@@ -265,12 +271,8 @@ public class UserOperationController {
log.error("小屏解绑失败,参数错误,memberId不存在");
return ResultInfo.failure("参数错误,会员id不存在");
}
boolean b = this.userOperationService.minaUnbind(weixinUnBindBean);
if (b) {
return ResultInfo.success("解绑成功");
} else {
return ResultInfo.failure("解绑失败");
}
return this.userOperationService.minaUnbind(weixinUnBindBean);
}
......@@ -378,7 +380,7 @@ public class UserOperationController {
@PostMapping("/subscribe")
@ApiOperation("微信公众号关注")
@AnonymousAccess
public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException {
public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws Exception {
log.info("UserOperationController ==> subscribe ==>> param ==> [{}]",data);
SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class);
......@@ -397,7 +399,7 @@ public class UserOperationController {
* @param subscribeBean
* @throws IOException
*/
private void parseSubscribe(SubscribeBean subscribeBean) throws IOException {
private void parseSubscribe(SubscribeBean subscribeBean) throws Exception {
// appId
String appId = subscribeBean.getAppid();
......@@ -410,7 +412,7 @@ public class UserOperationController {
Assert.notNull(openId, GlobeExceptionMsg.UNION_ID_IS_NULL);
// 匹配配置文件中的微信列表信息
Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId);
Map<String, String> wxInfoMap = this.getWeixinInfoByAppid(appId);
// 程序类型
String appType = wxInfoMap.get("appType");
......@@ -471,6 +473,24 @@ public class UserOperationController {
}
/**
* 获取配置的微信应用列表
* @param appid 应用Id
* @return
* @throws ConfigurationException
*/
private Map<String, String> getWeixinInfoByAppid(String appid) throws ConfigurationException {
if (com.topdraw.utils.StringUtils.isBlank(appid)) {
throw new RuntimeException("wxAppid can not be null");
}
List<Map<String, String>> list = weixinInfoConfig.getWechatAppList();
Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
if (!weixinInfoOptional.isPresent()) {
throw new RuntimeException("wxAppid error, appid is : " + appid);
}
return weixinInfoOptional.get();
}
@PostMapping("/unsubscribe")
@ApiOperation("微信公众号取关")
@AnonymousAccess
......@@ -516,19 +536,16 @@ public class UserOperationController {
@ApiOperation("小屏解绑")
@AnonymousAccess
public ResultInfo minaUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) {
log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean);
log.info("小屏解绑,参数 ==> [minaUnbind#{}]", weixinUnBindBean);
Long memberId = weixinUnBindBean.getMemberId();
if (Objects.isNull(memberId)) {
log.error("小屏解绑失败,参数错误,memberId不存在");
return ResultInfo.failure("参数错误,会员id不存在");
}
boolean b = this.userOperationService.minaUnbind(weixinUnBindBean);
if (b) {
return ResultInfo.success("解绑成功");
} else {
return ResultInfo.failure("解绑失败");
return ResultInfo.failure("参数错误,无会员id");
}
return this.userOperationService.minaUnbind(weixinUnBindBean);
}
/**
......
......@@ -14,6 +14,7 @@ import com.topdraw.business.process.domian.weixin.BindBean;
import com.topdraw.business.process.domian.weixin.SubscribeBean;
import com.topdraw.business.process.domian.weixin.TvUnBindBean;
import com.topdraw.business.process.domian.weixin.WeixinUnBindBean;
import com.topdraw.common.ResultInfo;
public interface UserOperationService {
......@@ -150,7 +151,7 @@ public interface UserOperationService {
* 小屏解绑
* @param weixinUnBindBean
*/
boolean minaUnbind(WeixinUnBindBean weixinUnBindBean);
ResultInfo minaUnbind(WeixinUnBindBean weixinUnBindBean);
/**
*
......
......@@ -4,7 +4,6 @@ import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
......@@ -12,7 +11,7 @@ import com.topdraw.business.process.service.CouponOperationService;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.business.process.domian.TempCoupon;
import com.topdraw.business.process.service.RightsOperationService;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -22,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
......
......@@ -11,7 +11,7 @@ import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
import com.topdraw.business.process.service.ExpOperationService;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.business.process.domian.TempExp;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.StringUtils;
......
......@@ -14,7 +14,7 @@ import com.topdraw.business.process.service.dto.CustomPointsResult;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.util.DateUtil;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
......
package com.topdraw.business.process.service.impl;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.aspect.AsyncMqSend;
......@@ -33,10 +32,10 @@ import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.business.process.domian.*;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.LocalConstants;
import com.topdraw.business.LocalConstants;
import com.topdraw.business.module.rights.constant.RightTypeConstants;
import com.topdraw.business.module.task.template.constant.TaskEventType;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.mq.module.mq.DataSyncMsg;
import com.topdraw.util.*;
import com.topdraw.utils.RedisUtils;
......
......@@ -46,9 +46,10 @@ import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.business.process.service.dto.MemberAndUserTvDTO;
import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO;
import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper;
import com.topdraw.config.LocalConstants;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.config.RedisKeyUtil;
import com.topdraw.business.LocalConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.common.ResultInfo;
import com.topdraw.util.RedisKeyUtil;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.exception.GlobeExceptionMsg;
......@@ -1508,24 +1509,25 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@Override
public boolean minaUnbind(WeixinUnBindBean weixinUnBindBean) {
public ResultInfo minaUnbind(WeixinUnBindBean weixinUnBindBean) {
Long memberId = weixinUnBindBean.getMemberId();
MemberDTO memberDTO = this.memberService.findById(memberId);
if (Objects.isNull(memberDTO.getId())) {
log.error("小屏解绑失败,会员信息不存在 memberId ==>> {}", memberId);
return false;
log.error("小屏解绑失败,会员信息不存在, minaUnbind# ==>> {}", memberId);
return ResultInfo.failure("小屏解绑失败,当前会员信息不存在");
}
if (Objects.isNull(memberDTO.getUserIptvId())) {
log.error("小屏解绑失败,未查询到大屏的大屏信息, memberId ==>> {}", memberId);
return false;
log.error("小屏解绑失败,无绑定的大屏, memberId ==>> {}", memberId);
return ResultInfo.failure("小屏解绑失败,无绑定的大屏");
}
UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId());
if (Objects.isNull(userTvDTO.getId())) {
log.info("小屏解绑失败,绑定的大屏账号不存在 userIptvId ==>> {}", memberDTO.getUserIptvId());
return false;
if (Objects.isNull(userTvDTO.getPlatformAccount())) {
log.info("小屏解绑失败,绑定的大屏账号不存在 minaUnbind# ==>> userIptvId ==>> {}", memberDTO.getUserIptvId());
return ResultInfo.failure("小屏解绑失败,大屏信息不存在请联系客服");
}
// 解绑(置空大屏信息)
......@@ -1585,7 +1587,7 @@ public class UserOperationServiceImpl implements UserOperationService {
this.updateUserTvSimplePriorityMemberCodeRedis(userTvDTO.getPlatformAccount(), "");
}
return true;
return ResultInfo.success("解绑成功");
}
......
......@@ -16,18 +16,15 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.process.domian.member.MemberOperationBean;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.config.RedisKeyConstants;
import com.topdraw.business.RedisKeyConstants;
import com.topdraw.util.TimestampUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;
......
package com.topdraw.mq.config;
package com.topdraw.config;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -12,35 +14,35 @@ public class RabbitMqConfig {
public static final String UCE_EXCHANGE = "uce.exchange";
public static final String UCE_QUEUE = "uce.queue";
@Value("${service.mq.exchange}")
private String exchange;
@Autowired
private RabbitTemplate rabbitTemplate;
@Value("${service.mq.queue}")
private String queue;
public String getExchange() {
public String getExchange(){
if (StringUtils.isEmpty(this.exchange)) {
this.exchange = UCE_EXCHANGE;
String exchange = this.rabbitTemplate.getExchange();
if (StringUtils.isNotBlank(exchange)) {
return exchange;
}
return this.exchange;
return UCE_EXCHANGE;
}
public String getQueue() {
if (StringUtils.isEmpty(this.queue)) {
this.queue = UCE_QUEUE;
String queue = this.rabbitTemplate.getRoutingKey();
if (StringUtils.isNotBlank(queue)) {
return queue;
}
return this.queue;
return UCE_QUEUE;
}
@Bean
DirectExchange directExchange(){
return ExchangeBuilder.directExchange(getExchange()).build();
return ExchangeBuilder.directExchange(this.getExchange()).build();
}
@Bean
Queue queue(){ return new Queue(getQueue()); }
Queue queue(){ return new Queue(this.getQueue()); }
@Bean
Binding binding(DirectExchange directExchange , Queue queue) {
......
package com.topdraw.config;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
@Component
public class ScheduledTaskConfig {
}
package com.topdraw.config;
import cn.hutool.core.map.MapUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;
import javax.naming.ConfigurationException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Configuration
@Data
@ConfigurationProperties(prefix = "wechat", ignoreInvalidFields = true)
public class WechatConfig {
private Map<String, String> miniprogram;
private Map<String, String> subscribe;
public List<Map<String, String>> getWechatAppList() throws ConfigurationException {
Map<String, String> miniprogram = this.miniprogram;
Map<String, String> subscribe = this.subscribe;
List<Map<String, String>> list = new ArrayList<>();
if (MapUtil.isNotEmpty(miniprogram)) {
list.add(miniprogram);
}
if (MapUtil.isNotEmpty(subscribe)) {
list.add(subscribe);
}
if (CollectionUtils.isEmpty(list)) {
throw new ConfigurationException("配置错误,未配置微信应用");
}
return list;
}
}
package com.topdraw.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.List;
import java.util.Map;
@Configuration
@Data
@ConfigurationProperties(prefix = "weixin")
public class WeixinInfoConfig {
private List<Map<String, String>> list;
}
package com.topdraw.security;
package com.topdraw.util;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.utils.StringUtils;
......
package com.topdraw.weixin.beans;
import lombok.Data;
@Data
public class ActionInfo {
private Scene scene;
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class QrCode {
@JSONField(name = "action_name")
private String actionName;
@JSONField(name = "expire_seconds")
private Integer expireSeconds;
@JSONField(name = "action_info")
private ActionInfo actionInfo;
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class Scene {
@JSONField(name = "scene_id")
private Long sceneId;
@JSONField(name = "scene_str")
private String sceneStr;
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Map;
@Data
public class WeiXinNotice {
@JSONField(serialize=false)
private String appid;
@JSONField(serialize=false)
private Long userId;
//目标用户
@JSONField(name = "touser")
private String toUser;
// 模板code
@JSONField(serialize=false)
private String code;
// 模板id
@JSONField(name = "template_id")
private String templateId;
// 点击通知跳转页面
private String page;
// 小程序版本
@JSONField(name = "miniprogram_state")
private String miniprogramState;
// 填充数据
private Map<String, Object> data;
}
package com.topdraw.weixin.service;
public class WeChatConstants {
// 订阅号
public static final String WX_SUBSCRIPTION = "subscription";
}
package com.topdraw.weixin.util;
public class WeChatConstants {
public static String HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
public static final String HTTPS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token";
public static final String HTTPS_TICKET_GETTICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
public static final String HTTPS_SNS_OAUTH2_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token";
public static final String HTTPS_SNS_USERINFO = "https://api.weixin.qq.com/sns/userinfo";
public static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
/**
* 把媒体文件上传到微信服务器。目前仅支持图片。用于发送客服消息或被动回复用户消息。
*/
public static String UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type=image";
/**
* 获取客服消息内的临时素材。即下载临时的多媒体文件。
*/
public static String GET_MEDIA = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}";
/**
* 用于向微信服务端申请二维码的url
*/
public static String URL_QR_CODE = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}";
/**
* 用于聊天时向用户发送消息的url
*/
public static String CUSTOM_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
/**
* 发送小程序订阅消息
*/
public static final String SUBSCRIBE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={0}";
/**
* 生成带参数二维码
*/
public static final String QR_CODE_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
/**
* 获取用户基本信息
*/
public static final String GET_USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";
// 批量获取关注者列表
public static final String GET_USER_LIST = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}";
/**
* 成功
*/
public static String SUCCESS = "SUCCESS";
/**
* 微信系统错误
*/
public static String SYSTEMERROR = "SYSTEMERROR";
/**
* 失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
*/
public static String FAIL = "FAIL";
/**
* 微信企业付款到个人失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
*/
public static String FAILED = "FAILED";
public static String ACCESS_TOKEN = "access_token";
public static String ERR_CODE = "errcode";
/**
* 微信请求时,返回ACCESS_TOKEN错误码
*/
public static final String ACCESS_TOKEN_INVALID_CODE = "40001";
/**
* 文本消息
*/
public static String MSG_TYPE_TEXT = "text";
public static String MSG_TYPE_MINIPROGRAMPAGE = "miniprogrampage";
public static String MSG_TYPE_LINK = "link";
public static String MSG_TYPE_IMAGE = "image";
/**
* 事件消息
*/
public static String MSG_TYPE_EVENT = "event";
/**
* 二维码类型,临时的整型参数值
*/
public static String QR_SCENE = "QR_SCENE";
/**
* 二维码类型,临时的字符串参数值
*/
public static String QR_STR_SCENE = "QR_STR_SCENE";
/**
* 二维码类型,永久的整型参数值
*/
public static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";
/**
* 二维码类型,永久的字符串参数值
*/
public static String QR_LIMIT_STR_SCENE = "QR_LIMIT_STR_SCENE";
/******** 事件推送事件类型BEGIN********/
/**
* 取消订阅
*/
public static final String EVENT_UNSUBSCRIBE = "unsubscribe";
/**
* 订阅
*/
public static final String EVENT_SUBSCRIBE = "subscribe";
/**
* 扫描带参数二维码事件,用户已关注时的事件推送
*/
public static final String EVENT_SCAN = "SCAN";
/**
* 上报地理位置事件
*/
public static final String EVENT_LOCATION = "LOCATION";
/**
* 自定义菜单事件
*/
public static final String EVENT_CLICK = "CLICK";
/******** 事件推送事件类型END********/
/**
* 微信ACCESS_TOKEN缓存KEY
*/
public static final String TOKEN_KEY = "GLOBAL_WX_ACCESS_TOKEN_";
/**
* 微信临时素材缓存KEY
*/
public static final String WEIXIN_MEDIA_KEY = "WEIXIN_MEDIA_KEY_";
// 微信应用类型 小程序 服务号 订阅号
// 小程序
public static final String WX_APPLET = "applet";
// 服务号
public static final String WX_SERVICE = "service";
// 订阅号
public static final String WX_SUBSCRIPTION = "subscription";
}
package com.topdraw.weixin.util;
import com.topdraw.config.WeixinInfoConfig;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Component
@Slf4j
public class WeixinUtil {
private static WeixinInfoConfig WEIXININFOCONFIG;
@Autowired
public void setWeixinInfoConfig(WeixinInfoConfig weixinInfoConfig) {
WEIXININFOCONFIG = weixinInfoConfig;
}
public static Map<String, String> getWeixinInfoByAppid(String appid) {
if (StringUtils.isBlank(appid)) {
throw new RuntimeException("wxAppid can not be null");
}
List<Map<String, String>> list = WEIXININFOCONFIG.getList();
Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
if (!weixinInfoOptional.isPresent()) {
throw new RuntimeException("wxAppid error, appid is : " + appid);
}
return weixinInfoOptional.get();
}
public static Map<String, String> getWeixinInfoByIndex(Integer index) {
List<Map<String, String>> list = WEIXININFOCONFIG.getList();
if (list.size() < index + 1) {
throw new RuntimeException("wxinfo error, index out of range : {}" + index);
}
return list.get(index);
}
/**
* 使用SHA1算法对字符串数组进行加密
*
* @param strList
* @return
*/
public static String encodeUsingSHA1(String... strList) {
//将strList的值进行字典排序
Arrays.sort(strList);
StringBuilder content = new StringBuilder();
for (int i = 0; i < strList.length; i++) {
content.append(strList[i]);
}
return doEncodeUsingSHA1(content.toString());
}
/**
* SHA1实现
*
* @return sha1加密后的字符串
*/
private static String doEncodeUsingSHA1(String inStr) {
byte[] byteArray ;
try {
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byteArray = sha.digest(inStr.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("no sha-1 algorithm");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported utf-8 encoding");
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < byteArray.length; i++) {
sb.append(Integer.toString((byteArray[i] & 0xff) + 0x100, 16).substring(1));
}
return sb.toString();
}
/**
* 公众号,小程序后台配置服务器,初次检验时使用
* @throws IOException
*/
public static void doGet(HttpServletRequest request, HttpServletResponse response, Map<String, String> weixinInfo) throws IOException {
log.info("doGet receive WeChat server request parameters:{}", request.getParameterMap());
String signature = request.getParameter("signature");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
String echoStr = request.getParameter("echostr");
String[] arr = new String[]{weixinInfo.get("token"), timestamp, nonce};
String encrypt = WeixinUtil.encodeUsingSHA1(arr);
if (encrypt.equals(signature)) {
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(echoStr.getBytes());
outputStream.flush();
}
}
}
......@@ -2,12 +2,12 @@
spring:
datasource:
# 测试/演示库url:
url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: root
password: root
# url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_admin_chongshu?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# username: root
# password: Tjlh@2021
# password: root
url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_admin_chongshu?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: root
password: Tjlh@2021
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
#Druid
......@@ -37,12 +37,15 @@ spring:
web-stat-filter:
url-pattern: /*
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
jackson:
time-zone: GMT+8
data:
redis:
repositories:
enabled: false
#配置 Jpa
jpa:
properties:
......@@ -51,11 +54,13 @@ spring:
ddl-auto: none
open-in-view: true
show-sql: false
servlet:
multipart:
file-size-threshold: 2KB
max-file-size: 100MB
max-request-size: 200MB
# redis
redis:
#数据库索引
......@@ -65,6 +70,7 @@ spring:
password: redis123
#连接超时时间
timeout: 5000
rabbitmq:
# host: 139.196.145.150 # rabbitmq的连接地址
# port: 5672 # rabbitmq的连接端口号
......@@ -78,26 +84,14 @@ spring:
username: guest # rabbitmq的用户名
password: guest # rabbitmq的密码
publisher-confirms: true #如果对异步消息需要回调必须设置为true
template:
exchange: uce.exchange
routing-key: uce.queue
#jwt。依赖的common中有需要jwt的部分属性。
jwt:
header: Authorization
secret: mySecret
# token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒
expiration: 7200000
# 在线用户key
online: online-token
# 验证码
codeKey: code-key
# token 续期检查时间范围(60分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
detect: 3600000
# 续期时间,2小时,单位毫秒
renew: 7200000
#是否允许生成代码,生产环境设置为false
#是否允许生成代码,生产环境设置为false
generator:
enabled: false
#是否开启 swagger-ui
#是否开启 swagger-ui
swagger:
enabled: false
\ No newline at end of file
......
......@@ -6,41 +6,55 @@ spring:
profiles:
active: dev
#mq
service:
mq:
exchange: uce.exchange
queue: uce.queue
#jwt。依赖的common中有需要jwt的部分属性。
jwt:
header: Authorization
secret: mySecret
# token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒
expiration: 7200000
# 在线用户key
online: online-token
# 验证码
codeKey: code-key
# token 续期检查时间范围(60分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
detect: 3600000
# 续期时间,2小时,单位毫秒
renew: 7200000
# 微信
wechat:
# 小程序
miniprogram:
appid: wxfaa765183a332521
secret: b5c1c39cb95b45b599a02fd68b5fcf17
token:
encodingAesKey:
imagePath:
content: 长按识别二维码,加入微信群。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 86400
env: dev
# 订阅号
subscribe:
appid: wx5d88c7fe99f89f32
secret: b213afe99a469d4be576f330dad643b8
token: topdraw
encodingAesKey: g3mYB6yx2ZiebxwKcI1H2iw3LlYNBHb7PqsVYFHUQzi
# 应用类型 小程序 服务号 订阅号, 当前基于订阅号有特殊逻辑
appType: subscription
imagePath: /topdraw/app/user_center_service_te/upload/customer/weChat.png
content: 长按识别二维码,关注订阅号。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 300
env: dev
weixin:
list:
- appid: wxfaa765183a332521
secret: b5c1c39cb95b45b599a02fd68b5fcf17
token:
encodingAesKey:
imagePath:
content: 长按识别二维码,加入微信群。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 86400
env: dev
# 订阅号
- appid: wx5d88c7fe99f89f32
secret: b213afe99a469d4be576f330dad643b8
token: topdraw
encodingAesKey: g3mYB6yx2ZiebxwKcI1H2iw3LlYNBHb7PqsVYFHUQzi
# 应用类型 小程序 服务号 订阅号, 当前基于订阅号有特殊逻辑
appType: subscription
imagePath: /topdraw/app/user_center_service_te/upload/customer/weChat.png
content: 长按识别二维码,关注订阅号。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 300
env: dev
#第三方接口
api:
......
......@@ -62,8 +62,7 @@ public class UserOperationControllerTest extends BaseTest {
try {
WeixinUnBindBean bindBean = new WeixinUnBindBean();
// 小屏会员
bindBean.setMemberId(4L);
bindBean.setAutoModel(true);
bindBean.setMemberId(21821L);
ResultInfo weixinUserAndMember = this.userOperationController.minaUnbind(bindBean);
System.out.println(weixinUserAndMember);
} catch (Exception e) {
......