Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
# Conflicts: # framework/src/main/java/cn/lili/common/security/context/UserContext.java # framework/src/main/java/cn/lili/common/security/context/UserContextInit.java
This commit is contained in:
commit
a599fb9d01
@ -4,8 +4,7 @@
|
||||

|
||||
|
||||
[](https://gitee.com/beijing_hongye_huicheng/lilishop/stargazers)
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
### 介绍
|
||||
|
||||
@ -36,11 +36,16 @@ public class MemberCollectionController {
|
||||
@Autowired
|
||||
private StoreCollectionService storeCollectionService;
|
||||
|
||||
/**
|
||||
* 商品收藏关键字
|
||||
*/
|
||||
private String goods="GOODS";
|
||||
|
||||
@ApiOperation(value = "查询会员收藏列表")
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺")
|
||||
@GetMapping("/{type}")
|
||||
public ResultMessage<Object> goodsList(@PathVariable String type, PageVO page) {
|
||||
if (type.equals("GOODS")) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(goodsCollectionService.goodsCollection(page));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.storeCollection(page));
|
||||
@ -54,7 +59,7 @@ public class MemberCollectionController {
|
||||
@PostMapping("/add/{type}/{id}")
|
||||
public ResultMessage<Object> addGoodsCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (type.equals("GOODS")) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(goodsCollectionService.addGoodsCollection(id));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.addStoreCollection(id));
|
||||
@ -69,7 +74,7 @@ public class MemberCollectionController {
|
||||
@DeleteMapping(value = "/delete/{type}/{id}")
|
||||
public ResultMessage<Object> deleteGoodsCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (type.equals("GOODS")) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(goodsCollectionService.deleteGoodsCollection(id));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.deleteStoreCollection(id));
|
||||
@ -83,7 +88,7 @@ public class MemberCollectionController {
|
||||
@GetMapping(value = "/isCollection/{type}/{id}")
|
||||
public ResultMessage<Boolean> isCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (type.equals("GOODS")) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(this.goodsCollectionService.isCollection(id));
|
||||
}
|
||||
return ResultUtil.data(this.storeCollectionService.isCollection(id));
|
||||
|
||||
@ -38,8 +38,8 @@ public class MemberWithdrawApplyBuyerController {
|
||||
public ResultMessage<IPage<MemberWithdrawApply>> getByPage(PageVO page, MemberWithdrawApplyQueryVO memberWithdrawApplyQueryVO) {
|
||||
memberWithdrawApplyQueryVO.setMemberId(UserContext.getCurrentUser().getId());
|
||||
//构建查询 返回数据
|
||||
IPage<MemberWithdrawApply> memberWithdrawApplyIPage = memberWithdrawApplyService.getMemberWithdrawPage(page, memberWithdrawApplyQueryVO);
|
||||
return ResultUtil.data(memberWithdrawApplyIPage);
|
||||
IPage<MemberWithdrawApply> memberWithdrawApplyPage = memberWithdrawApplyService.getMemberWithdrawPage(page, memberWithdrawApplyQueryVO);
|
||||
return ResultUtil.data(memberWithdrawApplyPage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,7 +40,6 @@ public class DistributionBuyerController {
|
||||
@Autowired
|
||||
private DistributionOrderService distributionOrderService;
|
||||
|
||||
//申请分销员
|
||||
@ApiOperation(value = "申请分销员")
|
||||
@PostMapping
|
||||
public ResultMessage<Object> applyDistribution(DistributionApplyDTO distributionApplyDTO) {
|
||||
@ -63,7 +62,6 @@ public class DistributionBuyerController {
|
||||
return ResultUtil.data(distributionService.getDistribution());
|
||||
}
|
||||
|
||||
//申请分销员
|
||||
@ApiOperation(value = "绑定分销员")
|
||||
@ApiImplicitParam(name = "distributionId", value = "分销员ID", required = true, paramType = "path")
|
||||
@GetMapping("/bindingDistribution/{distributionId}")
|
||||
|
||||
@ -34,6 +34,7 @@ public class MiniProgramBuyerController {
|
||||
public ConnectService connectService;
|
||||
@Autowired
|
||||
public WechatMpCodeUtil wechatMpCodeUtil;
|
||||
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
|
||||
@Autowired
|
||||
public WechatMPMessageService wechatMPMessageService;
|
||||
@Autowired
|
||||
|
||||
@ -81,6 +81,7 @@ public class FileController {
|
||||
if (file.getUserEnums().equals(authUser.getRole().name())) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
fileService.updateById(file);
|
||||
|
||||
@ -28,10 +28,9 @@ public class SliderImageController {
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
//一分钟同一个ip请求10次
|
||||
@LimitPoint(name = "slider_image", key = "verification")
|
||||
@GetMapping("/{verificationEnums}")
|
||||
@ApiOperation(value = "获取校验接口")
|
||||
@ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次")
|
||||
public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) {
|
||||
try {
|
||||
return ResultUtil.data(verificationService.createVerification(verificationEnums, uuid));
|
||||
|
||||
@ -31,14 +31,13 @@ public class SmsController {
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
//一分钟同一个ip请求1次
|
||||
@LimitPoint(name = "sms_send", key = "sms")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "path", dataType = "String", name = "mobile", value = "手机号"),
|
||||
@ApiImplicitParam(paramType = "header", dataType = "String", name = "uuid", value = "uuid"),
|
||||
})
|
||||
@GetMapping("/{verificationEnums}/{mobile}")
|
||||
@ApiOperation(value = "发送短信验证码")
|
||||
@ApiOperation(value = "发送短信验证码,一分钟同一个ip请求1次")
|
||||
public ResultMessage getSmsCode(
|
||||
@RequestHeader String uuid,
|
||||
@PathVariable String mobile,
|
||||
|
||||
@ -121,7 +121,7 @@ spring:
|
||||
props:
|
||||
#是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭
|
||||
sql:
|
||||
show: false
|
||||
show: true
|
||||
|
||||
# 忽略鉴权url
|
||||
ignored:
|
||||
@ -144,6 +144,7 @@ ignored:
|
||||
- /buyer/promotion/pintuan/**
|
||||
- /buyer/promotion/seckill/**
|
||||
- /buyer/promotion/pointsGoods/**
|
||||
- /buyer/promotion/coupon
|
||||
- /buyer/memberEvaluation/**/goodsEvaluation
|
||||
- /buyer/memberEvaluation/**/evaluationNumber
|
||||
- /buyer/appVersion/**
|
||||
@ -163,6 +164,7 @@ ignored:
|
||||
- /v2/api-docs
|
||||
- /configuration/ui
|
||||
- /boot-admin
|
||||
- /manager/promotion/seckill/init
|
||||
statics:
|
||||
- /**/*.js
|
||||
- /**/*.css
|
||||
@ -194,9 +196,9 @@ logging:
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: info
|
||||
org.hibernate: debug
|
||||
org.springframework: debug
|
||||
org.springframework.data.mongodb.core: debug
|
||||
# org.hibernate: debug
|
||||
# org.springframework: debug
|
||||
# org.springframework.data.mongodb.core: debug
|
||||
file:
|
||||
# 指定路径
|
||||
path: lili-logs
|
||||
@ -295,6 +297,8 @@ lili:
|
||||
notice-send-group: lili_send_notice_group
|
||||
rocketmq:
|
||||
name-server: 192.168.0.116:9876
|
||||
namesrvAddr: 192.168.0.116:9876
|
||||
isVIPChannel: false
|
||||
producer:
|
||||
group: lili_group
|
||||
send-message-timeout: 30000
|
||||
|
||||
@ -12,6 +12,7 @@ import cn.lili.modules.order.order.entity.dto.OrderMessage;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -23,13 +24,18 @@ import javax.annotation.Resource;
|
||||
* @author Chopper
|
||||
* @date 2020-07-03 11:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDayExecute, AfterSaleStatusChangeEvent {
|
||||
|
||||
//分销订单
|
||||
/**
|
||||
* 分销订单
|
||||
*/
|
||||
@Autowired
|
||||
private DistributionOrderService distributionOrderService;
|
||||
//分销订单持久层
|
||||
/**
|
||||
* 分销订单持久层
|
||||
*/
|
||||
@Resource
|
||||
private DistributionOrderMapper distributionOrderMapper;
|
||||
|
||||
@ -48,6 +54,9 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa
|
||||
distributionOrderService.cancelOrder(orderMessage.getOrderSn());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
log.error("分销订单执行异常:", orderMessage.getOrderSn());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,9 +14,11 @@ import org.springframework.stereotype.Service;
|
||||
* @date 2020-07-03 11:20
|
||||
*/
|
||||
@Service
|
||||
public class GoodsSkuExecute implements GoodsCommentCompleteEvent {
|
||||
public class GoodsSkuExecute implements GoodsCommentCompleteEvent {
|
||||
|
||||
//商品
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
|
||||
|
||||
@ -29,18 +29,25 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class MemberExperienceExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent, OrderStatusChangeEvent {
|
||||
|
||||
//配置
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
//会员
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 会员注册赠送经验值
|
||||
*
|
||||
* @param member 会员
|
||||
*/
|
||||
@Override
|
||||
@ -53,6 +60,7 @@ public class MemberExperienceExecute implements MemberRegisterEvent, GoodsCommen
|
||||
|
||||
/**
|
||||
* 商品评价赠送经验值
|
||||
*
|
||||
* @param memberEvaluation 会员评价
|
||||
*/
|
||||
@Override
|
||||
@ -65,17 +73,18 @@ public class MemberExperienceExecute implements MemberRegisterEvent, GoodsCommen
|
||||
|
||||
/**
|
||||
* 完成订单赠送经验值
|
||||
*
|
||||
* @param orderMessage 订单消息
|
||||
*/
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
if(orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)){
|
||||
if (orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)) {
|
||||
//获取经验值设置
|
||||
ExperienceSetting experienceSetting = getExperienceSetting();
|
||||
//获取订单信息
|
||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||
//计算赠送经验值数量
|
||||
Double point= CurrencyUtil.mul(experienceSetting.getMoney(),order.getFlowPrice(),0);
|
||||
Double point = CurrencyUtil.mul(experienceSetting.getMoney(), order.getFlowPrice(), 0);
|
||||
//赠送会员经验值
|
||||
memberService.updateMemberExperience(point.longValue(), true, order.getMemberId(), "会员下单,赠送经验值" + point + "分");
|
||||
}
|
||||
@ -83,9 +92,10 @@ public class MemberExperienceExecute implements MemberRegisterEvent, GoodsCommen
|
||||
|
||||
/**
|
||||
* 获取经验值设置
|
||||
*
|
||||
* @return 经验值设置
|
||||
*/
|
||||
private ExperienceSetting getExperienceSetting(){
|
||||
private ExperienceSetting getExperienceSetting() {
|
||||
Setting setting = settingService.get(SettingEnum.EXPERIENCE_SETTING.name());
|
||||
return new Gson().fromJson(setting.getSettingValue(), ExperienceSetting.class);
|
||||
}
|
||||
|
||||
@ -33,57 +33,66 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent, OrderStatusChangeEvent, AfterSaleStatusChangeEvent {
|
||||
|
||||
//配置
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
//会员
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 会员注册赠送积分
|
||||
*
|
||||
* @param member 会员
|
||||
*/
|
||||
@Override
|
||||
public void memberRegister(Member member) {
|
||||
//获取积分设置
|
||||
PointSetting pointSetting=getPointSetting();
|
||||
PointSetting pointSetting = getPointSetting();
|
||||
//赠送会员积分
|
||||
memberService.updateMemberPoint(Long.valueOf(pointSetting.getRegister().longValue()), true, member.getId(), "会员注册,赠送积分" + pointSetting.getRegister() + "分");
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员评价赠送积分
|
||||
*
|
||||
* @param memberEvaluation 会员评价
|
||||
*/
|
||||
@Override
|
||||
public void goodsComment(MemberEvaluation memberEvaluation) {
|
||||
//获取积分设置
|
||||
PointSetting pointSetting=getPointSetting();
|
||||
PointSetting pointSetting = getPointSetting();
|
||||
//赠送会员积分
|
||||
memberService.updateMemberPoint(Long.valueOf(pointSetting.getComment().longValue()), true, memberEvaluation.getMemberId(), "会员评价,赠送积分" + pointSetting.getComment() + "分");
|
||||
}
|
||||
|
||||
/**
|
||||
* 非积分订单订单完成后赠送积分
|
||||
*
|
||||
* @param orderMessage 订单消息
|
||||
*/
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
|
||||
if(orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)){
|
||||
if (orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)) {
|
||||
//根据订单编号获取订单数据,如果为积分订单则跳回
|
||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||
if(order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINT.name())){
|
||||
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINT.name())) {
|
||||
return;
|
||||
}
|
||||
//获取积分设置
|
||||
PointSetting pointSetting=getPointSetting();
|
||||
PointSetting pointSetting = getPointSetting();
|
||||
//计算赠送积分数量
|
||||
Double point=CurrencyUtil.mul(pointSetting.getMoney(),order.getFlowPrice(),0);
|
||||
Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0);
|
||||
//赠送会员积分
|
||||
memberService.updateMemberPoint(point.longValue(), true, order.getMemberId(), "会员下单,赠送积分" + point + "分");
|
||||
|
||||
@ -92,15 +101,16 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
|
||||
/**
|
||||
* 提交售后后扣除积分
|
||||
*
|
||||
* @param afterSale 售后
|
||||
*/
|
||||
@Override
|
||||
public void afterSaleStatusChange(AfterSale afterSale) {
|
||||
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.COMPLETE.name())) {
|
||||
//获取积分设置
|
||||
PointSetting pointSetting=getPointSetting();
|
||||
PointSetting pointSetting = getPointSetting();
|
||||
//计算扣除积分数量
|
||||
Double point=CurrencyUtil.mul(pointSetting.getMoney(), afterSale.getActualRefundPrice(),0);
|
||||
Double point = CurrencyUtil.mul(pointSetting.getMoney(), afterSale.getActualRefundPrice(), 0);
|
||||
//扣除会员积分
|
||||
memberService.updateMemberPoint(point.longValue(), false, afterSale.getMemberId(), "会员退款,扣除积分" + point + "分");
|
||||
|
||||
@ -109,9 +119,10 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
|
||||
/**
|
||||
* 获取积分设置
|
||||
*
|
||||
* @return 积分设置
|
||||
*/
|
||||
private PointSetting getPointSetting(){
|
||||
private PointSetting getPointSetting() {
|
||||
Setting setting = settingService.get(SettingEnum.POINT_SETTING.name());
|
||||
return new Gson().fromJson(setting.getSettingValue(), PointSetting.class);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||
noticeMessageDTO.setMemberId(tradeDTO.getMemberId());
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.ORDER_CREATE_SUCCESS);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("goods", tradeDTO.getSkuList().get(0).getGoodsSku().getGoodsName());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
//保存站内信
|
||||
@ -58,7 +58,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||
//如果订单状态不为空
|
||||
if (orderDetailVO != null) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
switch (orderMessage.getNewStatus()) {
|
||||
//如果订单新的状态为已取消 则发送取消订单站内信
|
||||
case CANCELLED:
|
||||
@ -103,7 +103,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
public void afterSaleStatusChange(AfterSale afterSale) {
|
||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||
noticeMessageDTO.setMemberId(afterSale.getMemberId());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("goods", afterSale.getGoodsName());
|
||||
params.put("refuse", afterSale.getAuditRemark());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
@ -154,7 +154,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
//组织站内信参数
|
||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||
noticeMessageDTO.setMemberId(memberPointMessage.getMemberId());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
if (memberPointMessage.getType()) {
|
||||
params.put("expenditure_points", "0");
|
||||
params.put("income_points", memberPointMessage.getPoint().toString());
|
||||
@ -178,7 +178,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
//组织参数
|
||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||
noticeMessageDTO.setMemberId(memberWithdrawalMessage.getMemberId());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_SUCCESS);
|
||||
|
||||
@ -10,6 +10,7 @@ import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.payment.entity.RefundLog;
|
||||
import cn.lili.modules.payment.kit.Payment;
|
||||
import cn.lili.modules.payment.kit.enums.PaymentMethodEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -19,10 +20,13 @@ import org.springframework.stereotype.Service;
|
||||
* @author Chopper
|
||||
* @date 2021-03-13 16:58
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@ -64,6 +68,9 @@ public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
break;
|
||||
case BANK_TRANSFER:
|
||||
break;
|
||||
default:
|
||||
log.error("订单支付执行异常,订单编号:", orderMessage.getOrderSn());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -32,23 +32,35 @@ import java.util.List;
|
||||
@Service
|
||||
public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
|
||||
//出库失败消息
|
||||
/**
|
||||
* 出库失败消息
|
||||
*/
|
||||
static String outOfStockMessage = "库存不足,出库失败";
|
||||
//Redis
|
||||
/**
|
||||
* Redis
|
||||
*/
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private DefaultRedisScript<Boolean> quantityScript;
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
//规格商品
|
||||
/**
|
||||
* 规格商品
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
//促销商品
|
||||
/**
|
||||
* 促销商品
|
||||
*/
|
||||
@Autowired
|
||||
private PromotionGoodsService promotionGoodsService;
|
||||
//缓存
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
|
||||
@ -24,7 +24,9 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.after-sale-topic}", consumerGroup = "${lili.data.rocketmq.after-sale-group}")
|
||||
public class AfterSaleMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
//售后订单状态
|
||||
/**
|
||||
* 售后订单状态
|
||||
*/
|
||||
@Autowired
|
||||
private List<AfterSaleStatusChangeEvent> afterSaleStatusChangeEvents;
|
||||
|
||||
@ -43,6 +45,8 @@ public class AfterSaleMessageListener implements RocketMQListener<MessageExt> {
|
||||
e);
|
||||
}
|
||||
}
|
||||
default:
|
||||
log.error("售后状态修改事件执行异常:", new String(messageExt.getBody()));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
@ -42,31 +41,49 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.goods-topic}", consumerGroup = "${lili.data.rocketmq.goods-group}")
|
||||
public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
//ES商品
|
||||
/**
|
||||
* ES商品
|
||||
*/
|
||||
@Autowired
|
||||
private EsGoodsIndexService goodsIndexService;
|
||||
//店铺
|
||||
/**
|
||||
* 店铺
|
||||
*/
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
//商品
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
//商品
|
||||
/**
|
||||
* 商品Sku
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
//用户足迹
|
||||
/**
|
||||
* 用户足迹
|
||||
*/
|
||||
@Autowired
|
||||
private FootprintService footprintService;
|
||||
//商品收藏
|
||||
/**
|
||||
* 商品收藏
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsCollectionService goodsCollectionService;
|
||||
//商品评价
|
||||
/**
|
||||
* 商品评价
|
||||
*/
|
||||
@Autowired
|
||||
private List<GoodsCommentCompleteEvent> goodsCommentCompleteEvents;
|
||||
//分销商品
|
||||
/**
|
||||
* 分销商品
|
||||
*/
|
||||
@Autowired
|
||||
private DistributionGoodsService distributionGoodsService;
|
||||
//分销员-商品关联表
|
||||
/**
|
||||
* 分销员-商品关联表
|
||||
*/
|
||||
@Autowired
|
||||
private DistributionSelectedGoodsService distributionSelectedGoodsService;
|
||||
|
||||
@ -123,6 +140,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
case BUY_GOODS_COMPLETE:
|
||||
this.goodsBuyComplete(messageExt);
|
||||
break;
|
||||
default:
|
||||
log.error("商品执行异常:", new String(messageExt.getBody()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,20 +151,21 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
* 1.更新店铺的商品数量
|
||||
* 2.删除分销员-分销商品绑定关系
|
||||
* 3.删除分销商品
|
||||
*
|
||||
* @param messageExt 消息
|
||||
*/
|
||||
private void deleteGoods(MessageExt messageExt){
|
||||
Goods goods=JSONUtil.toBean(new String(messageExt.getBody()),Goods.class);
|
||||
private void deleteGoods(MessageExt messageExt) {
|
||||
Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class);
|
||||
//更新店铺商品数量
|
||||
storeService.updateStoreGoodsNum(goods.getStoreId());
|
||||
|
||||
//删除获取分销商品
|
||||
DistributionGoods distributionGoods=distributionGoodsService.getOne(new LambdaQueryWrapper<DistributionGoods>()
|
||||
.eq(DistributionGoods::getGoodsId,goods.getId()));
|
||||
DistributionGoods distributionGoods = distributionGoodsService.getOne(new LambdaQueryWrapper<DistributionGoods>()
|
||||
.eq(DistributionGoods::getGoodsId, goods.getId()));
|
||||
|
||||
//删除分销商品绑定关系
|
||||
distributionSelectedGoodsService.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId,distributionGoods.getId()));
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoods.getId()));
|
||||
|
||||
//删除分销商品
|
||||
distributionGoodsService.removeById(distributionGoods.getId());
|
||||
@ -155,9 +176,10 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
* 1.更新商品购买数量
|
||||
* 2.更新SKU购买数量
|
||||
* 3.更新索引购买数量
|
||||
*
|
||||
* @param messageExt
|
||||
*/
|
||||
private void goodsBuyComplete(MessageExt messageExt){
|
||||
private void goodsBuyComplete(MessageExt messageExt) {
|
||||
String goodsCompleteMessageStr = new String(messageExt.getBody());
|
||||
List<GoodsCompleteMessage> goodsCompleteMessageList = JSONUtil.toList(JSONUtil.parseArray(goodsCompleteMessageStr), GoodsCompleteMessage.class);
|
||||
for (GoodsCompleteMessage goodsCompleteMessage : goodsCompleteMessageList) {
|
||||
|
||||
@ -30,16 +30,24 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.member-topic}", consumerGroup = "${lili.data.rocketmq.member-group}")
|
||||
public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
//会员签到
|
||||
/**
|
||||
* 会员签到
|
||||
*/
|
||||
@Autowired
|
||||
private MemberSignService memberSignService;
|
||||
//会员积分变化
|
||||
/**
|
||||
* 会员积分变化
|
||||
*/
|
||||
@Autowired
|
||||
private List<MemberPointChangeEvent> memberPointChangeEvents;
|
||||
//会员提现
|
||||
/**
|
||||
* 会员提现
|
||||
*/
|
||||
@Autowired
|
||||
private List<MemberWithdrawalEvent> memberWithdrawalEvents;
|
||||
//会员注册
|
||||
/**
|
||||
* 会员注册
|
||||
*/
|
||||
@Autowired
|
||||
private List<MemberRegisterEvent> memberSignEvents;
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ package cn.lili.listener;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.modules.message.entity.dto.NoticeMessageDTO;
|
||||
import cn.lili.modules.message.service.NoticeMessageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
@ -20,7 +19,9 @@ import org.springframework.stereotype.Component;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.notice-topic}", consumerGroup = "${lili.data.rocketmq.notice-group}")
|
||||
public class NoticeMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
//站内信
|
||||
/**
|
||||
* 站内信
|
||||
*/
|
||||
@Autowired
|
||||
private NoticeMessageService noticeMessageService;
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -41,22 +42,34 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.notice-send-topic}", consumerGroup = "${lili.data.rocketmq.notice-send-group}")
|
||||
public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
//会员
|
||||
@Autowired
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
@Resource
|
||||
private MemberMapper memberMapper;
|
||||
//短信
|
||||
/**
|
||||
* 短信
|
||||
*/
|
||||
@Autowired
|
||||
private SmsUtil smsUtil;
|
||||
//店铺消息
|
||||
/**
|
||||
* 店铺消息
|
||||
*/
|
||||
@Autowired
|
||||
private StoreMessageService storeMessageService;
|
||||
//会员消息
|
||||
/**
|
||||
* 会员消息
|
||||
*/
|
||||
@Autowired
|
||||
private MemberMessageService memberMessageService;
|
||||
//店铺
|
||||
/**
|
||||
* 店铺
|
||||
*/
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
//会员
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@ -100,7 +113,7 @@ public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
private void saveStoreMessage(Message message) {
|
||||
List<StoreMessage> list = new ArrayList<>();
|
||||
//发送全部商家情况
|
||||
if (message.getMessageRange().equals("ALL")) {
|
||||
if ("ALL".equals(message.getMessageRange())) {
|
||||
List<Store> storeList = storeService.list(new QueryWrapper<Store>().eq("store_disable", "OPEN"));
|
||||
storeList.forEach(item -> {
|
||||
StoreMessage storeMessage = new StoreMessage();
|
||||
@ -141,7 +154,7 @@ public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
private void saveMemberMessage(Message message) {
|
||||
List<MemberMessage> list = new ArrayList<>();
|
||||
//如果是给所有会员发送消息
|
||||
if (message.getMessageRange().equals("ALL")) {
|
||||
if ("ALL".equals(message.getMessageRange())) {
|
||||
//查询所有会员总数,因为会员总数比较大 如果一次性查出来会占用数据库资源,所以要分页查询
|
||||
MemberSearchVO memberSearchVO = new MemberSearchVO();
|
||||
memberSearchVO.setDisabled(SwitchEnum.OPEN.name());
|
||||
|
||||
@ -27,13 +27,19 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.order-topic}", consumerGroup = "${lili.data.rocketmq.order-group}")
|
||||
public class OrderMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
//交易
|
||||
/**
|
||||
* 交易
|
||||
*/
|
||||
@Autowired
|
||||
private List<TradeEvent> tradeEvent;
|
||||
//订单状态
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Autowired
|
||||
private List<OrderStatusChangeEvent> orderStatusChangeEvents;
|
||||
//缓存
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache<Object> cache;
|
||||
|
||||
|
||||
@ -21,10 +21,14 @@ import java.util.List;
|
||||
@Component
|
||||
public class BillExecute implements EveryDayExecute {
|
||||
|
||||
//结算单
|
||||
/**
|
||||
* 结算单
|
||||
*/
|
||||
@Autowired
|
||||
private BillService billService;
|
||||
//店铺详情
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
@Resource
|
||||
private StoreDetailMapper storeDetailMapper;
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@ import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.mapper.MemberEvaluationMapper;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -22,11 +22,15 @@ import java.util.Map;
|
||||
*/
|
||||
@Component
|
||||
public class GoodsExecute implements EveryDayExecute {
|
||||
//会员评价
|
||||
@Autowired
|
||||
/**
|
||||
* 会员评价
|
||||
*/
|
||||
@Resource
|
||||
private MemberEvaluationMapper memberEvaluationMapper;
|
||||
//商品
|
||||
@Autowired
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@Resource
|
||||
private GoodsMapper goodsMapper;
|
||||
|
||||
/**
|
||||
|
||||
@ -12,7 +12,6 @@ import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.timetask.handler.EveryMinuteExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -28,12 +27,15 @@ import java.util.stream.Collectors;
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
|
||||
public class CancelOrderTaskExecute implements EveryMinuteExecute {
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
//设置
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
|
||||
@ -37,16 +37,24 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
//订单货物
|
||||
/**
|
||||
* 订单货物
|
||||
*/
|
||||
@Autowired
|
||||
private OrderItemService orderItemService;
|
||||
//设置
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
//会员评价
|
||||
/**
|
||||
* 会员评价
|
||||
*/
|
||||
@Autowired
|
||||
private MemberEvaluationService memberEvaluationService;
|
||||
|
||||
|
||||
@ -39,33 +39,49 @@ import java.util.List;
|
||||
@Component
|
||||
public class PromotionEverydayExecute implements EveryDayExecute {
|
||||
|
||||
//Mongo
|
||||
/**
|
||||
* Mongo
|
||||
*/
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
//es
|
||||
/**
|
||||
* ES商品索引
|
||||
*/
|
||||
@Autowired
|
||||
private EsGoodsIndexService esGoodsIndexService;
|
||||
//满额活动
|
||||
/**
|
||||
* 满额活动
|
||||
*/
|
||||
@Autowired
|
||||
private FullDiscountService fullDiscountService;
|
||||
//拼团
|
||||
/**
|
||||
* 拼团
|
||||
*/
|
||||
@Autowired
|
||||
private PintuanService pintuanService;
|
||||
//优惠券
|
||||
/**
|
||||
* 优惠券
|
||||
*/
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
//会员优惠券
|
||||
/**
|
||||
* 会员优惠券
|
||||
*/
|
||||
@Autowired
|
||||
private MemberCouponService memberCouponService;
|
||||
//促销商品
|
||||
/**
|
||||
* 促销商品
|
||||
*/
|
||||
@Autowired
|
||||
private PromotionGoodsService promotionGoodsService;
|
||||
|
||||
//系统设置
|
||||
/**
|
||||
* 系统设置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
//秒杀活动
|
||||
/**
|
||||
* 秒杀活动
|
||||
*/
|
||||
@Autowired
|
||||
private SeckillService seckillService;
|
||||
|
||||
|
||||
@ -20,7 +20,9 @@ import java.util.Date;
|
||||
@Component
|
||||
public class MemberStatisticsExecute implements EveryDayExecute {
|
||||
|
||||
//会员统计
|
||||
/**
|
||||
* 会员统计
|
||||
*/
|
||||
@Autowired
|
||||
private MemberStatisticsDataService memberStatisticsDataService;
|
||||
|
||||
|
||||
@ -24,10 +24,14 @@ import java.util.stream.Collectors;
|
||||
@Component
|
||||
public class OnlineMemberStatistics implements EveryHourExecute {
|
||||
|
||||
//缓存
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
//统计小时
|
||||
/**
|
||||
* 统计小时
|
||||
*/
|
||||
@Autowired
|
||||
private StatisticsProperties statisticsProperties;
|
||||
|
||||
|
||||
@ -11,10 +11,10 @@ import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -25,11 +25,15 @@ import java.util.List;
|
||||
*/
|
||||
@Component
|
||||
public class StoreRatingExecute implements EveryDayExecute {
|
||||
//店铺
|
||||
/**
|
||||
* 店铺
|
||||
*/
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
//会员评价
|
||||
@Autowired
|
||||
/**
|
||||
* 会员评价
|
||||
*/
|
||||
@Resource
|
||||
private MemberEvaluationMapper memberEvaluationMapper;
|
||||
|
||||
|
||||
@ -39,10 +43,10 @@ public class StoreRatingExecute implements EveryDayExecute {
|
||||
List<Store> storeList = storeService.list(new LambdaQueryWrapper<Store>().eq(Store::getStoreDisable, StoreStatusEnum.OPEN.name()));
|
||||
for (Store store : storeList) {
|
||||
//店铺所有开启的评价
|
||||
LambdaQueryWrapper<MemberEvaluation> QueryWrapper = Wrappers.lambdaQuery();
|
||||
QueryWrapper.eq(MemberEvaluation::getStoreId, store.getId());
|
||||
QueryWrapper.eq(MemberEvaluation::getStatus, SwitchEnum.OPEN.name());
|
||||
StoreRatingVO storeRatingVO = memberEvaluationMapper.getStoreRatingVO(QueryWrapper);
|
||||
LambdaQueryWrapper<MemberEvaluation> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(MemberEvaluation::getStoreId, store.getId());
|
||||
lambdaQueryWrapper.eq(MemberEvaluation::getStatus, SwitchEnum.OPEN.name());
|
||||
StoreRatingVO storeRatingVO = memberEvaluationMapper.getStoreRatingVO(lambdaQueryWrapper);
|
||||
|
||||
if (storeRatingVO != null) {
|
||||
//保存评分
|
||||
|
||||
@ -4,7 +4,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.modules.statistics.model.dos.PlatformViewData;
|
||||
import cn.lili.modules.statistics.service.PlatformViewDataService;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
@ -29,10 +28,14 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PageViewStatisticsExecute implements EveryDayExecute {
|
||||
//缓存
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
//平台PV统计
|
||||
/**
|
||||
* 平台PV统计
|
||||
*/
|
||||
@Autowired
|
||||
private PlatformViewDataService platformViewDataService;
|
||||
|
||||
|
||||
@ -79,6 +79,7 @@ public abstract class AbstractDelayQueueListen {
|
||||
|
||||
/**
|
||||
* 要实现延时队列的名字
|
||||
* @return 促销延时队列名称
|
||||
*/
|
||||
public abstract String setDelayQueueName();
|
||||
|
||||
@ -88,7 +89,7 @@ public abstract class AbstractDelayQueueListen {
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
new Thread(this::startDelayQueueMachine).start();
|
||||
ThreadPoolUtil.getPool().execute(this::startDelayQueueMachine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,16 +25,24 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component(TimeExecuteConstant.PROMOTION_EXECUTOR)
|
||||
public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor {
|
||||
//促销
|
||||
/**
|
||||
* 促销
|
||||
*/
|
||||
@Autowired
|
||||
private PromotionService promotionService;
|
||||
//Rocketmq
|
||||
/**
|
||||
* RocketMQ
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
//延时任务
|
||||
/**
|
||||
* 延时任务
|
||||
*/
|
||||
@Autowired
|
||||
private TimeTrigger timeTrigger;
|
||||
//订单
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
|
||||
@ -75,10 +75,15 @@ public class LimitInterceptor {
|
||||
}
|
||||
|
||||
|
||||
//默认unknown常量值
|
||||
/**
|
||||
* 默认unknown常量值
|
||||
*/
|
||||
private static final String UNKNOWN = "unknown";
|
||||
|
||||
//获取ip
|
||||
/**
|
||||
* 获取ip
|
||||
* @return ip
|
||||
*/
|
||||
public String getIpAddress() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
|
||||
@ -39,7 +39,7 @@ public class SystemLogAspect {
|
||||
/**
|
||||
* 启动线程异步记录日志
|
||||
*/
|
||||
private static final ThreadLocal<Date> beginTimeThreadLocal = new NamedThreadLocal<>("SYSTEM-LOG");
|
||||
private static final ThreadLocal<Date> BEGIN_TIME_THREAD_LOCAL = new NamedThreadLocal<>("SYSTEM-LOG");
|
||||
|
||||
@Autowired
|
||||
private SystemLogService systemLogService;
|
||||
@ -61,7 +61,7 @@ public class SystemLogAspect {
|
||||
*/
|
||||
@Before("controllerAspect()")
|
||||
public void doBefore() {
|
||||
beginTimeThreadLocal.set(new Date());
|
||||
BEGIN_TIME_THREAD_LOCAL.set(new Date());
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ public class SystemLogAspect {
|
||||
//写入自定义日志内容
|
||||
systemLogVO.setCustomerLog(customerLog);
|
||||
//请求开始时间
|
||||
long beginTime = beginTimeThreadLocal.get().getTime();
|
||||
long beginTime = BEGIN_TIME_THREAD_LOCAL.get().getTime();
|
||||
long endTime = System.currentTimeMillis();
|
||||
//请求耗时
|
||||
Long usedTime = endTime - beginTime;
|
||||
@ -157,7 +157,7 @@ public class SystemLogAspect {
|
||||
*/
|
||||
private static Map<String, String> spelFormat(JoinPoint joinPoint, Object rvt) {
|
||||
|
||||
Map<String, String> result = new HashMap<>();
|
||||
Map<String, String> result = new HashMap<>(2);
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
SystemLogPoint systemLogPoint = signature.getMethod().getAnnotation(SystemLogPoint.class);
|
||||
String description = systemLogPoint.description();
|
||||
|
||||
@ -164,6 +164,7 @@ public interface Cache<T> {
|
||||
* 如需清零,按照普通key 移除即可
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
Long cumulative(Object key, Object value);
|
||||
|
||||
@ -454,25 +454,39 @@ public enum CachePrefix {
|
||||
/**
|
||||
* 店铺分类
|
||||
*/
|
||||
STORE_CATEGORY
|
||||
;
|
||||
STORE_CATEGORY;
|
||||
|
||||
|
||||
public static String removePrefix(String str) {
|
||||
return str.substring(str.lastIndexOf("}_") + 2);
|
||||
}
|
||||
|
||||
//通用获取缓存key值
|
||||
/**
|
||||
* 通用获取缓存key值
|
||||
*
|
||||
* @return 缓存key值
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return "{" + this.name() + "}_";
|
||||
}
|
||||
|
||||
//通用获取缓存key值
|
||||
/**
|
||||
* 通用获取缓存key值
|
||||
*
|
||||
* @param typeEnum 促销枚举
|
||||
* @return 缓存key值
|
||||
*/
|
||||
public String getPrefix(PromotionTypeEnum typeEnum) {
|
||||
return "{" + this.name() + "_" + typeEnum.name() + "}_";
|
||||
}
|
||||
|
||||
//获取缓存key值 + 用户端,例如:三端都有用户体系,需要分别登录,如果用户名一致,则redis中的权限可能会冲突出错
|
||||
/**
|
||||
* 获取缓存key值 + 用户端
|
||||
* 例如:三端都有用户体系,需要分别登录,如果用户名一致,则redis中的权限可能会冲突出错
|
||||
*
|
||||
* @param user 角色
|
||||
* @return 缓存key值 + 用户端
|
||||
*/
|
||||
public String getPrefix(UserEnums user) {
|
||||
return "{" + this.name() + "_" + user.name() + "}_";
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ public class RedisCache implements Cache {
|
||||
return null;
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("scan错误",e);
|
||||
log.error("scan错误", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
@ -206,8 +206,8 @@ public class RedisCache implements Cache {
|
||||
public Long incr(String key, long liveTime) {
|
||||
RedisAtomicLong entityIdCounter = new RedisAtomicLong(key, redisTemplate.getConnectionFactory());
|
||||
Long increment = entityIdCounter.getAndIncrement();
|
||||
|
||||
if ((null == increment || increment.longValue() == 0) && liveTime > 0) {//初始设置过期时间
|
||||
//初始设置过期时间
|
||||
if ((null == increment || increment.longValue() == 0) && liveTime > 0) {
|
||||
entityIdCounter.expire(liveTime, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@ -254,8 +254,7 @@ public class RedisCache implements Cache {
|
||||
*/
|
||||
@Override
|
||||
public boolean zAdd(String key, long score, String value) {
|
||||
Boolean result = redisTemplate.opsForZSet().add(key, value, score);
|
||||
return result;
|
||||
return redisTemplate.opsForZSet().add(key, value, score);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -308,13 +308,6 @@ public abstract class BaseElasticsearchService {
|
||||
|
||||
PutMappingRequest request = new PutMappingRequest(index)
|
||||
.source(source, XContentType.JSON);
|
||||
// AcknowledgedResponse putMappingResponse = client.indices().putMapping(request,
|
||||
// RequestOptions.DEFAULT);
|
||||
//
|
||||
// boolean acknowledged = putMappingResponse.isAcknowledged();
|
||||
// if (acknowledged) {
|
||||
// log.error("Succeed to put mapping");
|
||||
// }
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
AtomicReference response = new AtomicReference<AcknowledgedResponse>();
|
||||
client.indices().putMappingAsync(
|
||||
|
||||
@ -36,6 +36,7 @@ public enum ResultCode {
|
||||
VERIFICATION_EXIST(1002, "验证码服务异常"),
|
||||
LIMIT_ERROR(1003,"访问过于频繁,请稍后再试"),
|
||||
ILLEGAL_REQUEST_ERROR(1004, "非法请求,请重新刷新页面操作"),
|
||||
IMAGE_FILE_EXT_ERROR(1005, "不支持图片格式"),
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
|
||||
@ -56,7 +56,12 @@ public class ResultUtil<T> {
|
||||
|
||||
}
|
||||
|
||||
//抽象静态方法,返回结果集
|
||||
/**
|
||||
* 抽象静态方法,返回结果集
|
||||
* @param t
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> ResultMessage<T> data(T t) {
|
||||
return new ResultUtil<T>().setData(t);
|
||||
}
|
||||
|
||||
@ -13,10 +13,14 @@ public class ServiceException extends RuntimeException {
|
||||
|
||||
public static String DEFAULT_MESSAGE = "网络错误,请稍后重试!";
|
||||
|
||||
//异常消息
|
||||
/**
|
||||
* 异常消息
|
||||
*/
|
||||
private String msg = DEFAULT_MESSAGE;
|
||||
|
||||
//错误码
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private ResultCode resultCode;
|
||||
|
||||
public ServiceException(String msg) {
|
||||
|
||||
@ -1,12 +1,20 @@
|
||||
package cn.lili.common.rocketmq.tags;
|
||||
|
||||
/**
|
||||
* 售后标签枚举
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/12/9
|
||||
**/
|
||||
public enum AfterSaleTagsEnum {
|
||||
|
||||
/**
|
||||
* "售后退款"
|
||||
*/
|
||||
REFUND("售后退款"),
|
||||
/**
|
||||
* "售后单状态改变"
|
||||
*/
|
||||
AFTER_SALE_STATUS_CHANGE("售后单状态改变");
|
||||
|
||||
private final String description;
|
||||
|
||||
@ -6,13 +6,37 @@ package cn.lili.common.rocketmq.tags;
|
||||
**/
|
||||
public enum GoodsTagsEnum {
|
||||
|
||||
/**
|
||||
* "生成商品索引"
|
||||
*/
|
||||
GENERATOR_GOODS_INDEX("生成商品索引"),
|
||||
/**
|
||||
* "删除商品"
|
||||
*/
|
||||
GOODS_DELETE("删除商品"),
|
||||
/**
|
||||
* "审核商品"
|
||||
*/
|
||||
GOODS_AUDIT("审核商品"),
|
||||
/**
|
||||
* "收藏商品"
|
||||
*/
|
||||
GOODS_COLLECTION("收藏商品"),
|
||||
/**
|
||||
* "购买商品完成"
|
||||
*/
|
||||
BUY_GOODS_COMPLETE("购买商品完成"),
|
||||
/**
|
||||
* "删除商品SKU"
|
||||
*/
|
||||
SKU_DELETE("删除商品SKU"),
|
||||
/**
|
||||
* "查看商品"
|
||||
*/
|
||||
VIEW_GOODS("查看商品"),
|
||||
/**
|
||||
* "商品评价"
|
||||
*/
|
||||
GOODS_COMMENT_COMPLETE("商品评价");
|
||||
|
||||
private final String description;
|
||||
|
||||
@ -1,14 +1,27 @@
|
||||
package cn.lili.common.rocketmq.tags;
|
||||
|
||||
/**
|
||||
* 会员操作枚举
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/12/9
|
||||
**/
|
||||
public enum MemberTagsEnum {
|
||||
|
||||
/**
|
||||
* 会员注册
|
||||
*/
|
||||
MEMBER_REGISTER("会员注册"),
|
||||
/**
|
||||
* 会员签到
|
||||
*/
|
||||
MEMBER_SING("会员签到"),
|
||||
/**
|
||||
* 会员提现
|
||||
*/
|
||||
MEMBER_WITHDRAWAL("会员提现"),
|
||||
/**
|
||||
* 会员积分变动
|
||||
*/
|
||||
MEMBER_POINT_CHANGE("会员积分变动");
|
||||
|
||||
private final String description;
|
||||
|
||||
@ -1,18 +1,23 @@
|
||||
package cn.lili.common.rocketmq.tags;
|
||||
|
||||
/**
|
||||
* 订单操作枚举
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/12/9
|
||||
**/
|
||||
public enum MqOrderTagsEnum {
|
||||
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*/
|
||||
ORDER_CREATE("订单创建"),
|
||||
/**
|
||||
* 订单状态改变
|
||||
*/
|
||||
STATUS_CHANGE("订单状态改变");
|
||||
|
||||
|
||||
|
||||
|
||||
private final String description;
|
||||
|
||||
MqOrderTagsEnum(String description) {
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
package cn.lili.common.rocketmq.tags;
|
||||
|
||||
/**
|
||||
* 其他操作枚举
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/12/9
|
||||
**/
|
||||
public enum OtherTagsEnum {
|
||||
|
||||
/**
|
||||
* 站内消息提醒
|
||||
*/
|
||||
MESSAGE("站内消息提醒"),
|
||||
/**
|
||||
* 短信消息提醒
|
||||
*/
|
||||
SMS("短信消息提醒");
|
||||
|
||||
private final String description;
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.lili.common.security.context;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 给予用户上下文,初始化参数
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/14 20:30
|
||||
*/
|
||||
@Component
|
||||
public class UserContextInit implements ApplicationRunner {
|
||||
|
||||
/**
|
||||
* 用户信息holder,认证信息的获取者
|
||||
*/
|
||||
@Autowired
|
||||
private AuthenticationHandler authenticationHandler;
|
||||
|
||||
/**
|
||||
* 在项目加载时指定认证信息获取者
|
||||
* 默认是由spring 安全上下文中获取
|
||||
*
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
//UserContext.setHolder(authenticationHandler);
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,10 @@ import java.util.regex.Pattern;
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
this.request = request;
|
||||
@ -90,46 +94,38 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
private static final Pattern SCRIPT_PATTERN1 = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern SCRIPT_PATTERN2 = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern SCRIPT_PATTERN3 = Pattern.compile("<script(.*?)>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
private static final Pattern SCRIPT_PATTERN4 = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern SRC_PATTERN = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
private static final Pattern EVAL_PATTERN = Pattern.compile("eval\\((.*?)\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
private static final Pattern E__XPRESSION_PATTERN = Pattern.compile("expression\\((.*?)\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
private static final Pattern VB_SCRIPT_PATTERN = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern ONLOAD_PATTERN = Pattern.compile("onload(.*?)=", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
|
||||
private String cleanXSS(String value) {
|
||||
if (value != null) {
|
||||
//推荐使用ESAPI库来避免脚本攻击,value = ESAPI.encoder().canonicalize(value);
|
||||
// //避免空字符串
|
||||
// value = value.replaceAll(" ", "");
|
||||
//避免script 标签
|
||||
Pattern scriptPattern = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
//避免src形式的表达式
|
||||
scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
value = SCRIPT_PATTERN1.matcher(value).replaceAll("");
|
||||
//删除单个的 </script> 标签
|
||||
scriptPattern = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
value = SCRIPT_PATTERN2.matcher(value).replaceAll("");
|
||||
//删除单个的<script ...> 标签
|
||||
scriptPattern = Pattern.compile("<script(.*?)>",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
//避免 eval(...) 形式表达式
|
||||
scriptPattern = Pattern.compile("eval\\((.*?)\\)",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
//避免 expression(...) 表达式
|
||||
scriptPattern = Pattern.compile("expression\\((.*?)\\)",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
value = SCRIPT_PATTERN3.matcher(value).replaceAll("");
|
||||
//避免 javascript: 表达式
|
||||
scriptPattern = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
value = SCRIPT_PATTERN4.matcher(value).replaceAll("");
|
||||
//避免src形式的表达式
|
||||
value = SRC_PATTERN.matcher(value).replaceAll("");
|
||||
//避免 eval(...) 形式表达式
|
||||
value = EVAL_PATTERN.matcher(value).replaceAll("");
|
||||
//避免 expression(...) 表达式
|
||||
value = E__XPRESSION_PATTERN.matcher(value).replaceAll("");
|
||||
//避免 vbscript:表达式
|
||||
scriptPattern = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
value = VB_SCRIPT_PATTERN.matcher(value).replaceAll("");
|
||||
//避免 onload= 表达式
|
||||
scriptPattern = Pattern.compile("onload(.*?)=",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
value = ONLOAD_PATTERN.matcher(value).replaceAll("");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ public interface AliSmsUtil {
|
||||
* 申请短信签名
|
||||
*
|
||||
* @param smsSign 短信签名
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
void addSmsSign(SmsSign smsSign) throws Exception;
|
||||
|
||||
@ -24,6 +25,7 @@ public interface AliSmsUtil {
|
||||
* 删除短信签名
|
||||
*
|
||||
* @param signName 签名名称
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
void deleteSmsSign(String signName) throws Exception;
|
||||
|
||||
@ -31,6 +33,8 @@ public interface AliSmsUtil {
|
||||
* 查询短信签名申请状态
|
||||
*
|
||||
* @param signName 签名名称
|
||||
* @return 短信签名申请状态
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
Map<String, Object> querySmsSign(String signName) throws Exception;
|
||||
|
||||
@ -38,6 +42,7 @@ public interface AliSmsUtil {
|
||||
* 修改未审核通过的短信签名,并重新提交审核。
|
||||
*
|
||||
* @param smsSign 短信签名
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
void modifySmsSign(SmsSign smsSign) throws Exception;
|
||||
|
||||
@ -45,7 +50,7 @@ public interface AliSmsUtil {
|
||||
* 修改未审核通过的短信模板,并重新提交审核。
|
||||
*
|
||||
* @param smsTemplate 短信模板
|
||||
* @throws Exception
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
void modifySmsTemplate(SmsTemplate smsTemplate) throws Exception;
|
||||
|
||||
@ -53,7 +58,8 @@ public interface AliSmsUtil {
|
||||
* 查看短信模板
|
||||
*
|
||||
* @param templateCode 短信模板CODE
|
||||
* @throws Exception
|
||||
* @return 短信模板
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
Map<String, Object> querySmsTemplate(String templateCode) throws Exception;
|
||||
|
||||
@ -61,8 +67,8 @@ public interface AliSmsUtil {
|
||||
* 申请短信模板
|
||||
*
|
||||
* @param smsTemplate 短信模板
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @return 短信模板
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
String addSmsTemplate(SmsTemplate smsTemplate) throws Exception;
|
||||
|
||||
@ -70,7 +76,7 @@ public interface AliSmsUtil {
|
||||
* 删除短信模板
|
||||
*
|
||||
* @param templateCode 短信模板CODE
|
||||
* @throws Exception
|
||||
* @throws Exception 阿里短信签名错误
|
||||
*/
|
||||
void deleteSmsTemplate(String templateCode) throws Exception;
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ public interface SmsUtil {
|
||||
* @param verificationEnums 验证码场景
|
||||
* @param uuid 用户标识uuid
|
||||
* @param code 待验证code
|
||||
* @return 操作状态
|
||||
*/
|
||||
boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code);
|
||||
|
||||
@ -41,6 +42,7 @@ public interface SmsUtil {
|
||||
* @param mobile 接收手机号
|
||||
* @param param 参数
|
||||
* @param templateCode 模版code
|
||||
* @param signName 签名名称
|
||||
*/
|
||||
void sendSmsCode(String signName, String mobile, Map<String, String> param, String templateCode);
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
String code = CommonUtil.getRandomNum();
|
||||
|
||||
//准备发送短信参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
//验证码内容
|
||||
params.put("code", code);
|
||||
|
||||
@ -221,7 +221,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
signFileList1
|
||||
));
|
||||
AddSmsSignResponse response = client.addSmsSign(addSmsSignRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
.setSignName(signName);
|
||||
|
||||
DeleteSmsSignResponse response = client.deleteSmsSign(deleteSmsSignRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
|
||||
@ -246,10 +246,10 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
QuerySmsSignRequest querySmsSignRequest = new QuerySmsSignRequest().setSignName(signName);
|
||||
|
||||
QuerySmsSignResponse response = client.querySmsSign(querySmsSignRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("SignStatus", response.getBody().getSignStatus());
|
||||
map.put("Reason", response.getBody().getReason());
|
||||
return map;
|
||||
@ -275,7 +275,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
signFileList1
|
||||
));
|
||||
ModifySmsSignResponse response = client.modifySmsSign(modifySmsSign);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
.setTemplateCode(smsTemplate.getTemplateCode());
|
||||
|
||||
ModifySmsTemplateResponse response = client.modifySmsTemplate(modifySmsTemplateRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
}
|
||||
@ -303,10 +303,10 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
.setTemplateCode(templateCode);
|
||||
QuerySmsTemplateResponse response = client.querySmsTemplate(querySmsTemplateRequest);
|
||||
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("TemplateStatus", response.getBody().getTemplateStatus());
|
||||
map.put("Reason", response.getBody().getReason());
|
||||
map.put("TemplateCode", response.getBody().getTemplateCode());
|
||||
@ -323,7 +323,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
.setRemark(smsTemplate.getRemark());
|
||||
|
||||
AddSmsTemplateResponse response = client.addSmsTemplate(addSmsTemplateRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
return response.getBody().getTemplateCode();
|
||||
@ -336,7 +336,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
.setTemplateCode(templateCode);
|
||||
|
||||
DeleteSmsTemplateResponse response = client.deleteSmsTemplate(deleteSmsTemplateRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
if (!("OK").equals(response.getBody().getCode())) {
|
||||
throw new ServiceException(response.getBody().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,8 @@ import javax.crypto.SecretKey;
|
||||
*/
|
||||
public class SecretKeyUtil {
|
||||
public static SecretKey generalKey() {
|
||||
byte[] encodedKey = Base64.decodeBase64("cuAihCz53DZRjZwbsGcZJ2Ai6At+T142uphtJMsk7iQ=");//自定义
|
||||
//自定义
|
||||
byte[] encodedKey = Base64.decodeBase64("cuAihCz53DZRjZwbsGcZJ2Ai6At+T142uphtJMsk7iQ=");
|
||||
javax.crypto.SecretKey key = Keys.hmacShaKeyFor(encodedKey);
|
||||
return key;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate {
|
||||
* @return
|
||||
*/
|
||||
private Map<String, List<String>> permissionList(List<UserMenuVO> userMenuVOList) {
|
||||
Map<String, List<String>> permission = new HashMap<>();
|
||||
Map<String, List<String>> permission = new HashMap<>(2);
|
||||
if (userMenuVOList == null || userMenuVOList.size() == 0) {
|
||||
return permission;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ public abstract class AbstractDelayQueueMachineFactory {
|
||||
|
||||
/**
|
||||
* 要实现延时队列的名字
|
||||
* @return 延时队列的名字
|
||||
*/
|
||||
public abstract String setDelayQueueName();
|
||||
|
||||
|
||||
@ -2,6 +2,9 @@ package cn.lili.common.trigger.enums;
|
||||
|
||||
/**
|
||||
* 队列枚举
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:40 上午
|
||||
*/
|
||||
public enum DelayQueueEnums {
|
||||
|
||||
|
||||
@ -7,16 +7,18 @@ import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 对象属性复制
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 复制属性
|
||||
*
|
||||
* @param objectFrom
|
||||
* @param objectTo
|
||||
*/
|
||||
public static void copyProperties(Object objectFrom,Object objectTo){
|
||||
public static void copyProperties(Object objectFrom, Object objectTo) {
|
||||
BeanUtils.copyProperties(objectFrom, objectTo);
|
||||
}
|
||||
|
||||
@ -34,7 +36,7 @@ public class BeanUtil {
|
||||
index++;
|
||||
}
|
||||
for (int i = 0; i < superFields.length; i++) {
|
||||
if (superFields[i].getName().equals("id")) {
|
||||
if ("id".equals(superFields[i].getName())) {
|
||||
continue;
|
||||
}
|
||||
fieldNames[index] = superFields[i].getName();
|
||||
@ -43,8 +45,12 @@ public class BeanUtil {
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
/* 根据属性名获取属性值
|
||||
* */
|
||||
/**
|
||||
* 根据属性名获取属性值
|
||||
* @param fieldName 属性名
|
||||
* @param o 对象
|
||||
* @return 属性值
|
||||
*/
|
||||
public static Object getFieldValueByName(String fieldName, Object o) {
|
||||
try {
|
||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* CheckMobileUtil
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-02-04 14:56
|
||||
*/
|
||||
public class CheckMobileUtil {
|
||||
|
||||
|
||||
//\b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
|
||||
//字符串在编译时会被转码一次,所以是 "\\b"
|
||||
//\B 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
|
||||
static String phoneReg = "\\b(ip(hone|od)|android|opera m(ob|in)i"
|
||||
+ "|windows (phone|ce)|blackberry"
|
||||
+ "|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp"
|
||||
+ "|laystation portable)|nokia|fennec|htc[-_]"
|
||||
+ "|mobile|up.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
|
||||
static String tableReg = "\\b(ipad|tablet|(Nexus 7)|up.browser"
|
||||
+ "|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
|
||||
|
||||
//移动设备正则匹配:手机端、平板
|
||||
static Pattern phonePat = Pattern.compile(phoneReg, Pattern.CASE_INSENSITIVE);
|
||||
static Pattern tablePat = Pattern.compile(tableReg, Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* 检测是否是移动设备访问
|
||||
*
|
||||
* @param request 浏览器标识 获取方式:
|
||||
* @return true:移动设备接入,false:pc端接入
|
||||
* @Title: check
|
||||
*/
|
||||
public static boolean check(HttpServletRequest request) {
|
||||
String userAgent = request.getHeader("USER-AGENT").toLowerCase();
|
||||
if (null == userAgent) {
|
||||
userAgent = "";
|
||||
}
|
||||
//匹配
|
||||
Matcher matcherPhone = phonePat.matcher(userAgent);
|
||||
Matcher matcherTable = tablePat.matcher(userAgent);
|
||||
if (matcherPhone.find() || matcherTable.find()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,9 @@ import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 金额计算工具
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:40 上午
|
||||
*/
|
||||
public final class CurrencyUtil {
|
||||
/**
|
||||
@ -25,8 +28,8 @@ public final class CurrencyUtil {
|
||||
* @return 两个参数的和
|
||||
*/
|
||||
public static Double add(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.add(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
@ -38,8 +41,8 @@ public final class CurrencyUtil {
|
||||
* @return 两个参数的差
|
||||
*/
|
||||
public static double sub(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.subtract(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
@ -51,16 +54,16 @@ public final class CurrencyUtil {
|
||||
* @return 两个参数的积
|
||||
*/
|
||||
public static Double mul(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.multiply(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的乘法运算。
|
||||
*
|
||||
* @param v1 被乘数
|
||||
* @param v2 乘数
|
||||
* @param v1 被乘数
|
||||
* @param v2 乘数
|
||||
* @param scale 表示表示需要精确到小数点以后几位。
|
||||
* @return 两个参数的积
|
||||
*/
|
||||
@ -69,8 +72,8 @@ public final class CurrencyUtil {
|
||||
throw new IllegalArgumentException(
|
||||
"The scale must be a positive integer or zero");
|
||||
}
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.multiply(b2).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
@ -102,8 +105,8 @@ public final class CurrencyUtil {
|
||||
if (v2 == 0) {
|
||||
return 0;
|
||||
}
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
@ -119,7 +122,7 @@ public final class CurrencyUtil {
|
||||
throw new IllegalArgumentException(
|
||||
"The scale must be a positive integer or zero");
|
||||
}
|
||||
BigDecimal b = new BigDecimal(Double.toString(v));
|
||||
BigDecimal b = new BigDecimal(v);
|
||||
BigDecimal one = new BigDecimal("1");
|
||||
return b.divide(one, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
@ -174,12 +174,12 @@ public class DateUtil {
|
||||
year--;
|
||||
month = 12;
|
||||
}
|
||||
if (!(String.valueOf(month).length() > 1)) {
|
||||
if (String.valueOf(month).length() <= 1) {
|
||||
months = "0" + month;
|
||||
} else {
|
||||
months = String.valueOf(month);
|
||||
}
|
||||
if (!(String.valueOf(day).length() > 1)) {
|
||||
if (String.valueOf(day).length() <= 1) {
|
||||
days = "0" + day;
|
||||
} else {
|
||||
days = String.valueOf(day);
|
||||
|
||||
@ -9,7 +9,6 @@ import org.apache.http.client.HttpRequestRetryHandler;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.config.Registry;
|
||||
@ -19,8 +18,6 @@ import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
@ -34,29 +31,60 @@ import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* HttpClientUtils
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:40 上午
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpClientUtils {
|
||||
|
||||
//org.apache.http.impl.client.CloseableHttpClient
|
||||
/**
|
||||
* org.apache.http.impl.client.CloseableHttpClient
|
||||
*/
|
||||
private static CloseableHttpClient httpClient = null;
|
||||
|
||||
//这里就直接默认固定了,因为以下三个参数在新建的method中仍然可以重新配置并被覆盖.
|
||||
static final int connectionRequestTimeout = 30000;//ms毫秒,从池中获取链接超时时间
|
||||
static final int connectTimeout = 60000;//ms毫秒,建立链接超时时间
|
||||
static final int socketTimeout = 60000;//ms毫秒,读取超时时间
|
||||
/**
|
||||
* ms毫秒,从池中获取链接超时时间
|
||||
*/
|
||||
static final int CONNECTION_REQUEST_TIMEOUT = 30000;
|
||||
/**
|
||||
* ms毫秒,建立链接超时时间
|
||||
*/
|
||||
static final int CONNECT_TIMEOUT = 60000;
|
||||
/**
|
||||
* ms毫秒,读取超时时间
|
||||
*/
|
||||
static final int SOCKET_TIMEOUT = 60000;
|
||||
|
||||
//总配置,主要涉及是以下两个参数,如果要作调整没有用到properties会比较后麻烦,但鉴于一经粘贴,随处可用的特点,就不再做依赖性配置化处理了.
|
||||
//而且这个参数同一家公司基本不会变动.
|
||||
static final int maxTotal = 500;//最大总并发,很重要的参数
|
||||
static final int maxPerRoute = 100;//每路并发,很重要的参数
|
||||
/**
|
||||
* 总配置,主要涉及是以下两个参数,如果要作调整没有用到properties会比较后麻烦,但鉴于一经粘贴,随处可用的特点,就不再做依赖性配置化处理了.
|
||||
* 而且这个参数同一家公司基本不会变动.
|
||||
* 最大总并发,很重要的参数
|
||||
*/
|
||||
static final int MAX_TOTAL = 500;
|
||||
/**
|
||||
* 每路并发,很重要的参数
|
||||
*/
|
||||
static final int MAX_PER_ROUTE = 100;
|
||||
|
||||
//正常情况这里应该配成MAP或LIST
|
||||
//细化配置参数,用来对每路参数做精细化处理,可以管控各ip的流量,比如默认配置请求baidu:80端口最大100个并发链接,
|
||||
static final String detailHostName = "http://www.baidu.com";//每个细化配置之ip(不重要,在特殊场景很有用)
|
||||
//每个细化配置之port(不重要,在特殊场景很有用)
|
||||
static final int detailPort = 80;
|
||||
//每个细化配置之最大并发数(不重要,在特殊场景很有用)
|
||||
static final int detailMaxPerRoute = 100;
|
||||
/**
|
||||
* 正常情况这里应该配成MAP或LIST
|
||||
* 细化配置参数,用来对每路参数做精细化处理,可以管控各ip的流量,比如默认配置请求baidu:80端口最大100个并发链接,
|
||||
* 每个细化配置之ip(不重要,在特殊场景很有用)
|
||||
*/
|
||||
static final String DETAIL_HOST_NAME = "http://www.baidu.com";
|
||||
|
||||
/**
|
||||
* 每个细化配置之port(不重要,在特殊场景很有用)
|
||||
*/
|
||||
static final int DETAIL_PORT = 80;
|
||||
/**
|
||||
* 每个细化配置之最大并发数(不重要,在特殊场景很有用)
|
||||
*/
|
||||
static final int DETAIL_MAX_PER_ROUTE = 100;
|
||||
|
||||
private synchronized static CloseableHttpClient getHttpClient() {
|
||||
if (null == httpClient) {
|
||||
@ -78,15 +106,15 @@ public class HttpClientUtils {
|
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("http", plainsf).register("https", sslsf).build();
|
||||
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
|
||||
//将最大连接数增加
|
||||
cm.setMaxTotal(maxTotal);
|
||||
cm.setMaxTotal(MAX_TOTAL);
|
||||
//将每个路由基础的连接增加
|
||||
cm.setDefaultMaxPerRoute(maxPerRoute);
|
||||
cm.setDefaultMaxPerRoute(MAX_PER_ROUTE);
|
||||
|
||||
//细化配置开始,其实这里用Map或List的for循环来配置每个链接,在特殊场景很有用.
|
||||
//将每个路由基础的连接做特殊化配置,一般用不着
|
||||
HttpHost httpHost = new HttpHost(detailHostName, detailPort);
|
||||
HttpHost httpHost = new HttpHost(DETAIL_HOST_NAME, DETAIL_PORT);
|
||||
//将目标主机的最大连接数增加
|
||||
cm.setMaxPerRoute(new HttpRoute(httpHost), detailMaxPerRoute);
|
||||
cm.setMaxPerRoute(new HttpRoute(httpHost), DETAIL_MAX_PER_ROUTE);
|
||||
//细化配置结束
|
||||
|
||||
//请求重试处理
|
||||
@ -117,7 +145,7 @@ public class HttpClientUtils {
|
||||
};
|
||||
|
||||
//配置请求的超时设置
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(connectionRequestTimeout).setConnectTimeout(connectTimeout).setSocketTimeout(socketTimeout).build();
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT).setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
|
||||
newHotpoint = HttpClients.custom().setConnectionManager(cm).setDefaultRequestConfig(requestConfig).setRetryHandler(httpRequestRetryHandler).build();
|
||||
return newHotpoint;
|
||||
}
|
||||
@ -149,7 +177,7 @@ public class HttpClientUtils {
|
||||
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("get请求错误",e);
|
||||
log.error("get请求错误", e);
|
||||
} finally {
|
||||
try {
|
||||
if (response != null) {
|
||||
@ -157,7 +185,7 @@ public class HttpClientUtils {
|
||||
}
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
log.error("Get错误",e);
|
||||
log.error("Get错误", e);
|
||||
}
|
||||
}
|
||||
return resultString;
|
||||
|
||||
@ -23,14 +23,18 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@Component
|
||||
public class IpHelper {
|
||||
|
||||
//qq lbs 地区查询key
|
||||
/**
|
||||
* qq lbs 地区查询key
|
||||
*/
|
||||
@Value("${lili.lbs.key}")
|
||||
private String key;
|
||||
//qq lbs 地区查询key
|
||||
/**
|
||||
* qq lbs 地区查询key
|
||||
*/
|
||||
@Value("${lili.lbs.sk}")
|
||||
private String sk;
|
||||
|
||||
private static final String api = "https://apis.map.qq.com";
|
||||
private static final String API = "https://apis.map.qq.com";
|
||||
|
||||
|
||||
/**
|
||||
@ -43,7 +47,7 @@ public class IpHelper {
|
||||
|
||||
String url = "/ws/location/v1/ip?key=" + key + "&ip=" + IpUtils.getIpAddress(request);
|
||||
String sign = SecureUtil.md5(url + sk);
|
||||
url = api + url + "&sign=" + sign;
|
||||
url = API + url + "&sign=" + sign;
|
||||
String result = "未知";
|
||||
try {
|
||||
String json = HttpUtil.get(url, 3000);
|
||||
|
||||
@ -51,7 +51,8 @@ public class OperationalJudgment<t> {
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
default:
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,157 +0,0 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
|
||||
public class PasswordUtil {
|
||||
|
||||
/**
|
||||
* JAVA6支持以下任意一种算法
|
||||
* PBEWITHMD5ANDDES
|
||||
* PBEWITHMD5ANDTRIPLEDES
|
||||
* PBEWITHSHAANDDESEDE
|
||||
* PBEWITHSHA1ANDRC2_40
|
||||
* PBKDF2WITHHMACSHA1
|
||||
* */
|
||||
|
||||
/**
|
||||
* 定义使用的算法为:PBEWITHMD5andDES算法
|
||||
*/
|
||||
public static final String ALGORITHM = "PBEWithMD5AndDES";
|
||||
|
||||
/**
|
||||
* 定义迭代次数为1000次
|
||||
*/
|
||||
private static final int ITERATIONCOUNT = 1000;
|
||||
|
||||
/**
|
||||
* 获取加密算法中使用的盐值,解密中使用的盐值必须与加密中使用的相同才能完成操作.
|
||||
* 盐长度必须为8字节
|
||||
*
|
||||
* @return byte[] 盐值
|
||||
*/
|
||||
public static byte[] getSalt() throws Exception {
|
||||
//实例化安全随机数
|
||||
SecureRandom random = new SecureRandom();
|
||||
//产出盐
|
||||
return random.generateSeed(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据PBE密码生成一把密钥
|
||||
*
|
||||
* @param password 生成密钥时所使用的密码
|
||||
* @return Key PBE算法密钥
|
||||
*/
|
||||
private static Key getPBEKey(String password) throws Exception {
|
||||
//实例化使用的算法
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
|
||||
//设置PBE密钥参数
|
||||
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
|
||||
//生成密钥
|
||||
SecretKey secretKey = keyFactory.generateSecret(keySpec);
|
||||
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密明文字符串
|
||||
*
|
||||
* @param plaintext 待加密的明文字符串
|
||||
* @param password 生成密钥时所使用的密码
|
||||
* @param salt 盐值
|
||||
* @return 加密后的密文字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encrypt(String plaintext, String password, byte[] salt) throws Exception {
|
||||
|
||||
Key key = getPBEKey(password);
|
||||
|
||||
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt, ITERATIONCOUNT);
|
||||
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHM);
|
||||
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key, parameterSpec);
|
||||
|
||||
byte encipheredData[] = cipher.doFinal(plaintext.getBytes());
|
||||
|
||||
return bytesToHexString(encipheredData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密密文字符串
|
||||
*
|
||||
* @param ciphertext 待解密的密文字符串
|
||||
* @param password 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
|
||||
* @param salt 盐值(如需解密,该参数需要与加密时使用的一致)
|
||||
* @return 解密后的明文字符串
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String decrypt(String ciphertext, String password, byte[] salt) throws Exception {
|
||||
|
||||
Key key = getPBEKey(password);
|
||||
|
||||
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt, ITERATIONCOUNT);
|
||||
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHM);
|
||||
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, parameterSpec);
|
||||
|
||||
byte[] passDec = cipher.doFinal(hexStringToBytes(ciphertext));
|
||||
|
||||
return new String(passDec);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节数组转换为十六进制字符串
|
||||
*
|
||||
* @param src 字节数组
|
||||
* @return
|
||||
*/
|
||||
public static String bytesToHexString(byte[] src) {
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将十六进制字符串转换为字节数组
|
||||
*
|
||||
* @param hexString 十六进制字符串
|
||||
* @return
|
||||
*/
|
||||
public static byte[] hexStringToBytes(String hexString) {
|
||||
if (hexString == null || hexString.equals("")) {
|
||||
return null;
|
||||
}
|
||||
hexString = hexString.toUpperCase();
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] d = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2;
|
||||
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
private static byte charToByte(char c) {
|
||||
return (byte) "0123456789ABCDEF".indexOf(c);
|
||||
}
|
||||
}
|
||||
@ -217,8 +217,7 @@ public class RedisUtil {
|
||||
* @return
|
||||
*/
|
||||
public boolean zadd(String key, long score, String value) {
|
||||
Boolean result = redisTemplate.opsForZSet().add(key, value, score);
|
||||
return result;
|
||||
return redisTemplate.opsForZSet().add(key, value, score);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -15,25 +13,25 @@ public class RegularUtil {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private static final Pattern mobile = Pattern.compile("^1[3|4|5|8][0-9]\\d{8}$");
|
||||
private static final Pattern MOBILE = Pattern.compile("^1[3|4|5|8][0-9]\\d{8}$");
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private static final Pattern email = Pattern.compile("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$");
|
||||
private static final Pattern EMAIL = Pattern.compile("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$");
|
||||
|
||||
public static boolean Mobile(String v){
|
||||
public static boolean mobile(String v){
|
||||
|
||||
Matcher m = mobile.matcher(v);
|
||||
Matcher m = MOBILE.matcher(v);
|
||||
if(m.matches()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean Email(String v){
|
||||
public static boolean email(String v){
|
||||
|
||||
Matcher m = email.matcher(v);
|
||||
Matcher m = EMAIL.matcher(v);
|
||||
if(m.matches()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -17,10 +17,13 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
public class SpelUtil {
|
||||
|
||||
|
||||
//spel表达式解析器
|
||||
/**
|
||||
* spel表达式解析器
|
||||
*/
|
||||
private static SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
|
||||
|
||||
//参数名发现器
|
||||
/**
|
||||
* 参数名发现器
|
||||
*/
|
||||
private static DefaultParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
|
||||
|
||||
/**
|
||||
@ -41,7 +44,8 @@ public class SpelUtil {
|
||||
//获取方法参数值
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
context.setVariable(parameterNames[i], args[i]); //替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
//替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
context.setVariable(parameterNames[i], args[i]);
|
||||
}
|
||||
return spelExpressionParser.parseExpression(spel).getValue(context).toString();
|
||||
}
|
||||
@ -66,7 +70,8 @@ public class SpelUtil {
|
||||
//获取方法参数值
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
context.setVariable(parameterNames[i], args[i]); //替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
//替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
context.setVariable(parameterNames[i], args[i]);
|
||||
}
|
||||
context.setVariable("rvt", rvt);
|
||||
return spelExpressionParser.parseExpression(spel).getValue(context).toString();
|
||||
|
||||
@ -195,7 +195,7 @@ public class StringUtils extends StrUtil {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<String, Object>(16);
|
||||
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
|
||||
@ -22,12 +22,12 @@ public class ThreadPoolUtil {
|
||||
/**
|
||||
* 线程缓冲队列
|
||||
*/
|
||||
private static final BlockingQueue<Runnable> bqueue = new ArrayBlockingQueue<Runnable>(100);
|
||||
private static final ThreadPoolExecutor pool = new ThreadPoolExecutor(SIZE_CORE_POOL, SIZE_MAX_POOL, ALIVE_TIME, TimeUnit.MILLISECONDS, bqueue, new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
private static final BlockingQueue<Runnable> BQUEUE = new ArrayBlockingQueue<Runnable>(100);
|
||||
private static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(SIZE_CORE_POOL, SIZE_MAX_POOL, ALIVE_TIME, TimeUnit.MILLISECONDS, BQUEUE, new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
public static ThreadPoolExecutor threadPool;
|
||||
|
||||
static {
|
||||
pool.prestartAllCoreThreads();
|
||||
POOL.prestartAllCoreThreads();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,10 +68,10 @@ public class ThreadPoolUtil {
|
||||
}
|
||||
|
||||
public static ThreadPoolExecutor getPool() {
|
||||
return pool;
|
||||
return POOL;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(pool.getPoolSize());
|
||||
System.out.println(POOL.getPoolSize());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package cn.lili.common.validation.impl;
|
||||
|
||||
import cn.lili.common.validation.Mobile;
|
||||
import cn.lili.common.validation.Phone;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
@ -11,22 +10,29 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* 电话校验
|
||||
* 支持手机号+电话同时校验
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:41 上午
|
||||
*/
|
||||
public class MobileValidator implements ConstraintValidator<Mobile, String> {
|
||||
|
||||
private static final Pattern PHONE = Pattern.compile("^0?(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$");
|
||||
private static final Pattern AREA_MOBILE = Pattern.compile("0\\d{2,3}[-]?\\d{7,8}|0\\d{2,3}\\s?\\d{7,8}|13[0-9]\\d{8}|15[1089]\\d{8}");
|
||||
private static final Pattern MOBILE = Pattern.compile("^[1-9]{1}[0-9]{5,8}$");
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
Pattern p1 = null, p2 = null, p3 = null;
|
||||
Matcher m = null;
|
||||
p1 = Pattern.compile("0\\d{2,3}[-]?\\d{7,8}|0\\d{2,3}\\s?\\d{7,8}|13[0-9]\\d{8}|15[1089]\\d{8}"); // 验证带区号的
|
||||
p2 = Pattern.compile("^[1-9]{1}[0-9]{5,8}$"); // 验证没有区号的
|
||||
p3 = Pattern.compile("^0?(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$");// 验证手机号
|
||||
Pattern pattern = null;
|
||||
// 验证手机号
|
||||
if (value.length() == 11) {
|
||||
m = p3.matcher(value);
|
||||
m = PHONE.matcher(value);
|
||||
// 验证带区号的电话
|
||||
} else if (value.length() > 9) {
|
||||
m = p1.matcher(value);
|
||||
m = AREA_MOBILE.matcher(value);
|
||||
//验证没有区号的电话
|
||||
} else {
|
||||
m = p2.matcher(value);
|
||||
m = MOBILE.matcher(value);
|
||||
}
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
@ -7,7 +7,12 @@ import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* 手机号校验
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:42 上午
|
||||
*/
|
||||
public class PhoneValidator implements ConstraintValidator<Phone, String> {
|
||||
|
||||
private static Pattern pattern = Pattern.compile("^0?(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$");
|
||||
|
||||
@ -72,12 +72,13 @@ public class ImageUtil {
|
||||
int rightRgb = templateImage.getRGB(i + 1, j);
|
||||
int downRgb = templateImage.getRGB(i, j + 1);
|
||||
//描边处理,,取带像素和无像素的界点,判断该点是不是临界轮廓点,如果是设置该坐标像素是白色
|
||||
if ((rgb >= 0 && rightRgb < 0) || (rgb < 0 && rightRgb >= 0) || (rgb >= 0 && downRgb < 0)
|
||||
|| (rgb < 0 && downRgb >= 0)) {
|
||||
boolean rgbImage = ((rgb >= 0 && rightRgb < 0)
|
||||
|| (rgb < 0 && rightRgb >= 0)
|
||||
|| (rgb >= 0 && downRgb < 0)
|
||||
|| (rgb < 0 && downRgb >= 0));
|
||||
|
||||
if (rgbImage) {
|
||||
newImage.setRGB(i, j, Color.GRAY.getRGB());
|
||||
|
||||
// oriImage.setRGB(x + i, y + j, Color.white.getRGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,7 +88,7 @@ public class ImageUtil {
|
||||
int xStart = x - 1;
|
||||
int yStart = y - 1;
|
||||
int current = 0;
|
||||
for (int i = xStart; i < 3 + xStart; i++)
|
||||
for (int i = xStart; i < 3 + xStart; i++) {
|
||||
for (int j = yStart; j < 3 + yStart; j++) {
|
||||
int tx = i;
|
||||
if (tx < 0) {
|
||||
@ -105,6 +106,7 @@ public class ImageUtil {
|
||||
pixels[current++] = img.getRGB(tx, ty);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void fillMatrix(int[][] matrix, int[] values) {
|
||||
|
||||
@ -43,7 +43,7 @@ public class SliderImageUtil {
|
||||
public static Map<String, Object> pictureTemplatesCut(SerializableStream sliderFile, SerializableStream originalFile) throws Exception {
|
||||
|
||||
Random random = new Random();
|
||||
Map<String, Object> pictureMap = new HashMap<>();
|
||||
Map<String, Object> pictureMap = new HashMap<>(16);
|
||||
//拼图
|
||||
BufferedImage sliderImage = ImageIO.read(Base64DecodeMultipartFile.base64ToInputStream(sliderFile.getBase64()));
|
||||
int sliderWidth = sliderImage.getWidth();
|
||||
@ -79,12 +79,15 @@ public class SliderImageUtil {
|
||||
|
||||
//添加水印
|
||||
ImageUtil.addWatermark(originalImage, "LILI-SHOP");
|
||||
ByteArrayOutputStream newImageOs = new ByteArrayOutputStream();//新建流。
|
||||
ImageIO.write(newImage, TEMP_IMG_FILE_TYPE, newImageOs);//利用ImageIO类提供的write方法,将bi以png图片的数据模式写入流。
|
||||
//新建流
|
||||
ByteArrayOutputStream newImageOs = new ByteArrayOutputStream();
|
||||
//利用ImageIO类提供的write方法,将bi以png图片的数据模式写入流。
|
||||
ImageIO.write(newImage, TEMP_IMG_FILE_TYPE, newImageOs);
|
||||
byte[] newImagery = newImageOs.toByteArray();
|
||||
|
||||
ByteArrayOutputStream oriImagesOs = new ByteArrayOutputStream();//新建流。
|
||||
ImageIO.write(originalImage, IMG_FILE_TYPE, oriImagesOs);//利用ImageIO类提供的write方法,将bi以jpg图片的数据模式写入流。
|
||||
//新建流
|
||||
ByteArrayOutputStream oriImagesOs = new ByteArrayOutputStream();
|
||||
//利用ImageIO类提供的write方法,将bi以jpg图片的数据模式写入流
|
||||
ImageIO.write(originalImage, IMG_FILE_TYPE, oriImagesOs);
|
||||
byte[] oriImageByte = oriImagesOs.toByteArray();
|
||||
|
||||
pictureMap.put("slidingImage", "data:image/png;base64," + Base64Utils.encodeToString(newImagery));
|
||||
|
||||
@ -7,6 +7,9 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 验证码模块
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:42 上午
|
||||
*/
|
||||
public interface VerificationService {
|
||||
/**
|
||||
@ -15,6 +18,7 @@ public interface VerificationService {
|
||||
* @param verificationEnums 校验枚举
|
||||
* @param uuid uuid
|
||||
* @return 校验对象
|
||||
* @throws IOException 校验错误
|
||||
*/
|
||||
Map<String, Object> createVerification(VerificationEnums verificationEnums, String uuid) throws IOException;
|
||||
|
||||
@ -29,9 +33,11 @@ public interface VerificationService {
|
||||
boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums);
|
||||
|
||||
/**
|
||||
* 验证码校验
|
||||
*
|
||||
* @param uuid 用户唯一表示
|
||||
* @param verificationEnums 校验枚举
|
||||
* @return
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean check(String uuid, VerificationEnums verificationEnums);
|
||||
}
|
||||
|
||||
@ -7,8 +7,11 @@ import org.springframework.data.redis.serializer.SerializationException;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/*
|
||||
*要实现对象的缓存,定义自己的序列化和反序列化器。使用阿里的fastjson来实现的比较多。
|
||||
/**
|
||||
* 要实现对象的缓存,定义自己的序列化和反序列化器。使用阿里的fastjson来实现的比较多
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 12:25 上午
|
||||
*/
|
||||
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
@ -51,8 +51,14 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
private Integer timeout;
|
||||
|
||||
|
||||
/**
|
||||
* 当有多个管理器的时候,必须使用该注解在一个管理器上注释:表示该管理器为默认的管理器
|
||||
*
|
||||
* @param connectionFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@Primary//当有多个管理器的时候,必须使用该注解在一个管理器上注释:表示该管理器为默认的管理器
|
||||
@Primary
|
||||
public CacheManager cacheManager(RedisConnectionFactory connectionFactory) {
|
||||
//初始化一个RedisCacheWriter
|
||||
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory);
|
||||
|
||||
@ -85,11 +85,9 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
|
||||
return (response, context) -> 2 * 60 * 1000;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* it gets called when bean instance is getting removed from the context if
|
||||
* scope is not a prototype
|
||||
*/
|
||||
/*
|
||||
* If there is a method named shutdown or close then spring container will try
|
||||
* to automatically configure them as callback methods when bean is being
|
||||
* destroyed
|
||||
@ -99,7 +97,7 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
|
||||
try {
|
||||
this.client.close();
|
||||
} catch (IOException e) {
|
||||
log.error("es clientClose错误",e);
|
||||
log.error("es clientClose错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package cn.lili.config.interceptor;
|
||||
|
||||
import cn.lili.config.properties.IgnoredUrlsProperties;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
||||
@ -31,7 +30,10 @@ public class UrlConfiguration implements WebMvcConfigurer {
|
||||
ir.excludePathPatterns(ignoredUrlsProperties.getUrls());
|
||||
}
|
||||
|
||||
//开放资源 这里配置swagger可以在前端访问
|
||||
/**
|
||||
* 开放资源 这里配置swagger可以在前端访问
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
|
||||
|
||||
@ -13,14 +13,24 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "lili.sms")
|
||||
public class SmsTemplateSetting {
|
||||
//登录
|
||||
private String LOGIN = "SMS_205755300";
|
||||
//注册
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
private String lOGIN = "SMS_205755300";
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
private String REGISTER = "SMS_205755298";
|
||||
//找回密码
|
||||
/**
|
||||
* 找回密码
|
||||
*/
|
||||
private String FIND_USER = "SMS_205755301";
|
||||
//设置密码
|
||||
/**
|
||||
* 设置密码
|
||||
*/
|
||||
private String UPDATE_PASSWORD = "SMS_205755297";
|
||||
//设置支付密码
|
||||
/**
|
||||
* 设置支付密码
|
||||
*/
|
||||
private String WALLET_PASSWORD = "SMS_205755297";
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public class ThreadProperties {
|
||||
/**
|
||||
* 保持存活时间
|
||||
*/
|
||||
private Integer KeepAliveSeconds = 60;
|
||||
private Integer keepAliveSeconds = 60;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@ public class CreateTimeShardingDatabaseAlgorithm implements PreciseShardingAlgor
|
||||
|
||||
@Override
|
||||
public String doSharding(Collection<String> collection, PreciseShardingValue<Long> preciseShardingValue) {
|
||||
Long create_time = preciseShardingValue.getValue();
|
||||
String value = DateUtil.toString(create_time, "yyyy");
|
||||
Long createTime = preciseShardingValue.getValue();
|
||||
String value = DateUtil.toString(createTime, "yyyy");
|
||||
//data2019,data2020
|
||||
return "data" + value;
|
||||
}
|
||||
|
||||
@ -21,9 +21,9 @@ public class CreateTimeShardingTableAlgorithm implements PreciseShardingAlgorith
|
||||
|
||||
@Override
|
||||
public String doSharding(Collection<String> collection, PreciseShardingValue<Long> preciseShardingValue) {
|
||||
Long create_time = preciseShardingValue.getValue();
|
||||
String monthValue = DateUtil.toString(create_time, "MM");
|
||||
String yearValue = DateUtil.toString(create_time, "yyyy");
|
||||
Long createTime = preciseShardingValue.getValue();
|
||||
String monthValue = DateUtil.toString(createTime, "MM");
|
||||
String yearValue = DateUtil.toString(createTime, "yyyy");
|
||||
Integer month = Integer.valueOf(monthValue);
|
||||
Integer year = Integer.valueOf(yearValue);
|
||||
//li_order_1,li_order_2~
|
||||
|
||||
@ -19,8 +19,8 @@ public class CreateTimeShardingTableAlgorithmBak implements PreciseShardingAlgor
|
||||
|
||||
@Override
|
||||
public String doSharding(Collection<String> collection, PreciseShardingValue<Long> preciseShardingValue) {
|
||||
Long create_time = preciseShardingValue.getValue();
|
||||
String value = DateUtil.toString(create_time, "MM");
|
||||
Long createTime = preciseShardingValue.getValue();
|
||||
String value = DateUtil.toString(createTime, "MM");
|
||||
Integer month = Integer.valueOf(value);
|
||||
//li_order_1,li_order_2~
|
||||
return "li_order_" + month;
|
||||
@ -30,17 +30,9 @@ public class CreateTimeShardingTableAlgorithmBak implements PreciseShardingAlgor
|
||||
@Override
|
||||
public Collection<String> doSharding(Collection collection, RangeShardingValue rangeShardingValue) {
|
||||
Collection<String> collect = new ArrayList<>();
|
||||
//Range<Integer> valueRange = rangeShardingValue.getValueRange();
|
||||
//开始年份结束年份
|
||||
//String start = DateUtil.toString(valueRange.lowerEndpoint().longValue(), "MM");
|
||||
//String end = DateUtil.toString(valueRange.upperEndpoint().longValue(), "MM");
|
||||
//循环增加区间的查询条件
|
||||
|
||||
|
||||
//因为考虑到 假设2019-05~2020-05
|
||||
//这快是没办法处理的,因为分库分表之后,每个库都要进行查询,如果操作为,1-4月,那么2020年数据查询正确了,可是2019年到5-12月数据就查询不到了
|
||||
//这里需要做一些性能的浪费,现在看来是没办法处理到
|
||||
|
||||
for (Integer i = 1; i <= 12; i++) {
|
||||
collect.add("li_order_" + i);
|
||||
}
|
||||
|
||||
@ -25,73 +25,73 @@ public class CodeGenerator {
|
||||
/**
|
||||
* 代码生成在哪个项目
|
||||
*/
|
||||
private static final String project = "framework";
|
||||
private static final String PROJECT = "framework";
|
||||
|
||||
/**
|
||||
* 代码生成在哪个包下边
|
||||
*/
|
||||
private static final String packages = "cn.lili.modules.";
|
||||
private static final String PACKAGES = "cn.lili.modules.";
|
||||
|
||||
/**
|
||||
* modules
|
||||
*/
|
||||
private static final String modules = "message";
|
||||
private static final String MODULES = "message";
|
||||
|
||||
|
||||
/**
|
||||
* 实体类名
|
||||
* 建议仅需修改
|
||||
*/
|
||||
private static final String className = "ShortLink";
|
||||
private static final String CLASS_NAME = "ShortLink";
|
||||
|
||||
/**
|
||||
* 类说明描述
|
||||
* 建议仅需修改
|
||||
*/
|
||||
private static final String description = "短链接";
|
||||
private static final String DESCRIPTION = "短链接";
|
||||
|
||||
/**
|
||||
* 作者名
|
||||
* 建议仅需修改
|
||||
*/
|
||||
private static final String author = "Chopper";
|
||||
private static final String AUTHOR = "Chopper";
|
||||
|
||||
/**
|
||||
* 数据库表名前缀
|
||||
* 下方请根据需要修改
|
||||
*/
|
||||
private static final String tablePre = "li_";
|
||||
private static final String TABLE_PRE = "li_";
|
||||
|
||||
/**
|
||||
* 主键类型
|
||||
*/
|
||||
private static final String primaryKeyType = "String";
|
||||
private static final String PRIMARY_KEY_TYPE = "String";
|
||||
|
||||
|
||||
/**
|
||||
* endity
|
||||
*/
|
||||
private static final String entityPackage = packages + modules + ".entity";
|
||||
private static final String ENTITY_PACKAGE = PACKAGES + MODULES + ".entity";
|
||||
|
||||
/**
|
||||
* dao
|
||||
*/
|
||||
private static final String daoPackage = packages + modules + ".mapper";
|
||||
private static final String DAO_PACKAGE = PACKAGES + MODULES + ".mapper";
|
||||
|
||||
/**
|
||||
* service
|
||||
*/
|
||||
private static final String servicePackage = packages + modules + ".service";
|
||||
private static final String SERVICE_PACKAGE = PACKAGES + MODULES + ".service";
|
||||
|
||||
/**
|
||||
* serviceImpl
|
||||
*/
|
||||
private static final String serviceImplPackage = packages + modules + ".serviceimpl";
|
||||
private static final String SERVICE_IMPL_PACKAGE = PACKAGES + MODULES + ".serviceimpl";
|
||||
|
||||
/**
|
||||
* controller
|
||||
*/
|
||||
private static final String controllerPackage = packages + modules + ".controller";
|
||||
private static final String CONTROLLER_PACKAGE = PACKAGES + MODULES + ".controller";
|
||||
|
||||
/**
|
||||
* 运行该主函数即可生成代码
|
||||
@ -126,17 +126,17 @@ public class CodeGenerator {
|
||||
Template mapperXmlTemplate = gt.getTemplate("mapperXml.btl");
|
||||
|
||||
Entity entity = new Entity();
|
||||
entity.setEntityPackage(entityPackage);
|
||||
entity.setDaoPackage(daoPackage);
|
||||
entity.setServicePackage(servicePackage);
|
||||
entity.setServiceImplPackage(serviceImplPackage);
|
||||
entity.setControllerPackage(controllerPackage);
|
||||
entity.setAuthor(author);
|
||||
entity.setClassName(className);
|
||||
entity.setTableName(tablePre + StringUtils.camel2Underline(className));
|
||||
entity.setClassNameLowerCase(name(className, false));
|
||||
entity.setDescription(description);
|
||||
entity.setPrimaryKeyType(primaryKeyType);
|
||||
entity.setEntityPackage(ENTITY_PACKAGE);
|
||||
entity.setDaoPackage(DAO_PACKAGE);
|
||||
entity.setServicePackage(SERVICE_PACKAGE);
|
||||
entity.setServiceImplPackage(SERVICE_IMPL_PACKAGE);
|
||||
entity.setControllerPackage(CONTROLLER_PACKAGE);
|
||||
entity.setAuthor(AUTHOR);
|
||||
entity.setClassName(CLASS_NAME);
|
||||
entity.setTableName(TABLE_PRE + StringUtils.camel2Underline(CLASS_NAME));
|
||||
entity.setClassNameLowerCase(name(CLASS_NAME, false));
|
||||
entity.setDescription(DESCRIPTION);
|
||||
entity.setPrimaryKeyType(PRIMARY_KEY_TYPE);
|
||||
|
||||
OutputStream out = null;
|
||||
|
||||
@ -145,7 +145,7 @@ public class CodeGenerator {
|
||||
String entityResult = entityTemplate.render();
|
||||
System.out.println(entityResult);
|
||||
//创建文件
|
||||
String entityFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(entityPackage) + "/" + className + ".java";
|
||||
String entityFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(ENTITY_PACKAGE) + "/" + CLASS_NAME + ".java";
|
||||
File entityFile = new File(entityFileUrl);
|
||||
File entityDir = entityFile.getParentFile();
|
||||
if (!entityDir.exists()) {
|
||||
@ -163,7 +163,7 @@ public class CodeGenerator {
|
||||
String daoResult = daoTemplate.render();
|
||||
System.out.println(daoResult);
|
||||
//创建文件
|
||||
String daoFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(daoPackage) + "/" + className + "Mapper.java";
|
||||
String daoFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(DAO_PACKAGE) + "/" + CLASS_NAME + "Mapper.java";
|
||||
File daoFile = new File(daoFileUrl);
|
||||
File daoDir = daoFile.getParentFile();
|
||||
if (!daoDir.exists()) {
|
||||
@ -181,7 +181,7 @@ public class CodeGenerator {
|
||||
String serviceResult = serviceTemplate.render();
|
||||
System.out.println(serviceResult);
|
||||
//创建文件
|
||||
String serviceFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(servicePackage) + "/" + className + "Service.java";
|
||||
String serviceFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(SERVICE_PACKAGE) + "/" + CLASS_NAME + "Service.java";
|
||||
File serviceFile = new File(serviceFileUrl);
|
||||
File serviceDir = serviceFile.getParentFile();
|
||||
if (!serviceDir.exists()) {
|
||||
@ -200,7 +200,7 @@ public class CodeGenerator {
|
||||
System.out.println(serviceImplResult);
|
||||
//创建文件
|
||||
System.out.println(System.getProperty("user.dir"));
|
||||
String serviceImplFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(serviceImplPackage) + "/" + className + "ServiceImpl.java";
|
||||
String serviceImplFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(SERVICE_IMPL_PACKAGE) + "/" + CLASS_NAME + "ServiceImpl.java";
|
||||
File serviceImplFile = new File(serviceImplFileUrl);
|
||||
File serviceImplDir = serviceImplFile.getParentFile();
|
||||
if (!serviceImplDir.exists()) {
|
||||
@ -218,7 +218,7 @@ public class CodeGenerator {
|
||||
String controllerResult = controllerTemplate.render();
|
||||
System.out.println(controllerResult);
|
||||
//创建文件
|
||||
String controllerFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(controllerPackage) + "/" + className + "Controller.java";
|
||||
String controllerFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(CONTROLLER_PACKAGE) + "/" + CLASS_NAME + "Controller.java";
|
||||
File controllerFile = new File(controllerFileUrl);
|
||||
File controllerDir = controllerFile.getParentFile();
|
||||
if (!controllerDir.exists()) {
|
||||
@ -236,7 +236,7 @@ public class CodeGenerator {
|
||||
String mapperXmlResult = mapperXmlTemplate.render();
|
||||
System.out.println(mapperXmlResult);
|
||||
//创建文件
|
||||
String mapperXmlFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/resources/mapper/" + className + "Mapper.xml";
|
||||
String mapperXmlFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/resources/mapper/" + CLASS_NAME + "Mapper.xml";
|
||||
File mapperXmlFile = new File(mapperXmlFileUrl);
|
||||
File mapperXmlDir = mapperXmlFile.getParentFile();
|
||||
if (!mapperXmlDir.exists()) {
|
||||
@ -263,36 +263,36 @@ public class CodeGenerator {
|
||||
*/
|
||||
private static void deleteCode(String className) throws IOException {
|
||||
|
||||
String entityFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(entityPackage) + "/" + className + ".java";
|
||||
String entityFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(ENTITY_PACKAGE) + "/" + className + ".java";
|
||||
File entityFile = new File(entityFileUrl);
|
||||
if (entityFile.exists()) {
|
||||
entityFile.delete();
|
||||
}
|
||||
String daoFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(daoPackage) + "/" + className + "Mapper.java";
|
||||
String daoFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(DAO_PACKAGE) + "/" + className + "Mapper.java";
|
||||
File daoFile = new File(daoFileUrl);
|
||||
if (daoFile.exists()) {
|
||||
daoFile.delete();
|
||||
}
|
||||
|
||||
String serviceFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(servicePackage) + "/" + className + "Service.java";
|
||||
String serviceFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(SERVICE_PACKAGE) + "/" + className + "Service.java";
|
||||
File serviceFile = new File(serviceFileUrl);
|
||||
if (serviceFile.exists()) {
|
||||
serviceFile.delete();
|
||||
}
|
||||
|
||||
String serviceImplFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(serviceImplPackage) + "/" + className + "ServiceImpl.java";
|
||||
String serviceImplFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(SERVICE_IMPL_PACKAGE) + "/" + className + "ServiceImpl.java";
|
||||
File serviceImplFile = new File(serviceImplFileUrl);
|
||||
if (serviceImplFile.exists()) {
|
||||
serviceImplFile.delete();
|
||||
}
|
||||
|
||||
String controllerFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/java/" + dotToLine(controllerPackage) + "/" + className + "Controller.java";
|
||||
String controllerFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/java/" + dotToLine(CONTROLLER_PACKAGE) + "/" + className + "Controller.java";
|
||||
File controllerFile = new File(controllerFileUrl);
|
||||
if (controllerFile.exists()) {
|
||||
controllerFile.delete();
|
||||
}
|
||||
|
||||
String mapperXmlFileUrl = System.getProperty("user.dir") + "/" + project + "/src/main/resources/mapper/" + className + "Mapper.xml";
|
||||
String mapperXmlFileUrl = System.getProperty("user.dir") + "/" + PROJECT + "/src/main/resources/mapper/" + className + "Mapper.xml";
|
||||
File mapperXmlFile = new File(mapperXmlFileUrl);
|
||||
if (mapperXmlFile.exists()) {
|
||||
mapperXmlFile.delete();
|
||||
|
||||
@ -4,6 +4,9 @@ import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 演示站点注解
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:40 上午
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@ -10,10 +10,25 @@ package cn.lili.modules.base.entity.enums;
|
||||
|
||||
public enum ClientTypeEnum {
|
||||
|
||||
/**
|
||||
* "移动端"
|
||||
*/
|
||||
H5("移动端"),
|
||||
/**
|
||||
* "PC端"
|
||||
*/
|
||||
PC("PC端"),
|
||||
/**
|
||||
* "小程序端"
|
||||
*/
|
||||
WECHAT_MP("小程序端"),
|
||||
/**
|
||||
* "移动应用端"
|
||||
*/
|
||||
APP("移动应用端"),
|
||||
/**
|
||||
* "未知"
|
||||
*/
|
||||
UNKNOWN("未知");
|
||||
|
||||
private final String clientName;
|
||||
|
||||
@ -8,8 +8,13 @@ package cn.lili.modules.base.entity.enums;
|
||||
* @date 2021/1/26 15:55
|
||||
*/
|
||||
public enum VerificationSourceEnum {
|
||||
|
||||
/**
|
||||
* 滑块
|
||||
*/
|
||||
SLIDER("滑块"),
|
||||
/**
|
||||
* 验证码源
|
||||
*/
|
||||
RESOURCE("验证码源");
|
||||
|
||||
private final String description;
|
||||
|
||||
@ -27,7 +27,12 @@ public interface RegionService extends IService<Region> {
|
||||
@CacheEvict
|
||||
void synchronizationData(String url);
|
||||
|
||||
|
||||
/**
|
||||
* 获取地区列表
|
||||
*
|
||||
* @param id 地区ID
|
||||
* @return 地区列表
|
||||
*/
|
||||
@Cacheable(key = "#id")
|
||||
List<Region> getItem(String id);
|
||||
|
||||
|
||||
@ -13,7 +13,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface VerificationSourceService extends IService<VerificationSource> {
|
||||
|
||||
//缓存
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
String VERIFICATION_CACHE = CachePrefix.VERIFICATION.getPrefix();
|
||||
|
||||
|
||||
@ -26,6 +28,8 @@ public interface VerificationSourceService extends IService<VerificationSource>
|
||||
|
||||
/**
|
||||
* 获取验证缓存
|
||||
*
|
||||
* @return 验证码
|
||||
*/
|
||||
VerificationVO getVerificationCache();
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
package cn.lili.modules.base.serviceimpl;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.HttpClientUtils;
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.base.mapper.RegionMapper;
|
||||
import cn.lili.modules.base.service.RegionService;
|
||||
import cn.lili.modules.system.entity.dos.Region;
|
||||
@ -27,7 +27,7 @@ import java.util.*;
|
||||
* @date 2020/12/2 11:11
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {
|
||||
|
||||
/**
|
||||
@ -37,6 +37,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Override
|
||||
public void synchronizationData(String url) {
|
||||
try {
|
||||
@ -58,7 +59,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
//删除缓存
|
||||
cache.vagueDel("{regions}");
|
||||
} catch (Exception e) {
|
||||
log.error("同步行政数据错误",e);
|
||||
log.error("同步行政数据错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,8 +90,10 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
//因为有无用数据 所以先删除前两个
|
||||
result = ArrayUtils.remove(result, 0);
|
||||
result = ArrayUtils.remove(result, 0);
|
||||
String regionIds = ""; //地址id
|
||||
String regionNames = "";//地址名称
|
||||
//地址id
|
||||
String regionIds = "";
|
||||
//地址名称
|
||||
String regionNames = "";
|
||||
//循环构建新的数据
|
||||
for (String regionId : result) {
|
||||
Region reg = this.baseMapper.selectById(regionId);
|
||||
@ -102,7 +105,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
regionIds += region.getId();
|
||||
regionNames += region.getName();
|
||||
//构建返回数据
|
||||
Map<String, Object> obj = new HashMap<>();
|
||||
Map<String, Object> obj = new HashMap<>(2);
|
||||
obj.put("id", regionIds);
|
||||
obj.put("name", regionNames);
|
||||
return obj;
|
||||
@ -120,10 +123,10 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
|
||||
private List<RegionVO> regionTree(List<Region> regions) {
|
||||
List<RegionVO> regionVOS = new ArrayList<>();
|
||||
regions.stream().filter(region -> region.getLevel().equals("province")).forEach(item -> {
|
||||
regions.stream().filter(region -> ("province").equals(region.getLevel())).forEach(item -> {
|
||||
regionVOS.add(new RegionVO(item));
|
||||
});
|
||||
regions.stream().filter(region -> region.getLevel().equals("city")).forEach(item -> {
|
||||
regions.stream().filter(region -> ("city").equals(region.getLevel())).forEach(item -> {
|
||||
for (RegionVO region : regionVOS) {
|
||||
if (region.getId().equals(item.getParentId())) {
|
||||
region.getChildren().add(new RegionVO(item));
|
||||
@ -148,18 +151,6 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
JSONArray countryAll = jsonObject.getJSONArray("districts");
|
||||
for (int i = 0; i < countryAll.size(); i++) {
|
||||
JSONObject contry = countryAll.getJSONObject(i);
|
||||
// String citycode0 = contry.getString("citycode");
|
||||
// String adcode0 = contry.getString("adcode");
|
||||
// String name0 = contry.getString("name");
|
||||
// String center0 = contry.getString("center");
|
||||
// String country = contry.getString("level");
|
||||
// int level = 0;
|
||||
// if (country.equals("country")) {
|
||||
// level = 0;
|
||||
// }
|
||||
// 插入国家
|
||||
// Integer id1 = insert(0, adcode0, citycode0, name0, center0, level, name0);
|
||||
// Integer id1 = insert(0, adcode0, citycode0, name0, center0, level);
|
||||
String id1 = "0";
|
||||
JSONArray provinceAll = contry.getJSONArray("districts");
|
||||
for (int j = 0; j < provinceAll.size(); j++) {
|
||||
@ -192,7 +183,6 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
String level3 = district.getString("level");
|
||||
//插入区县
|
||||
String id4 = insert(regions, id3, citycode3, adcode3, name3, center3, level3, w, id1, id2, id3);
|
||||
// JSONArray street = street3.getJSONArray("districts");
|
||||
//有需要可以继续向下遍历
|
||||
JSONArray streetAll = district.getJSONArray("districts");
|
||||
for (int r = 0; r < streetAll.size(); r++) {
|
||||
@ -238,10 +228,10 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
// " \"center\": \"116.3683244,39.915085\",\n" +
|
||||
// " \"level\": \"country\",\n" +
|
||||
Region record = new Region();
|
||||
if (!adCode.equals("[]")) {
|
||||
if (!("[]").equals(adCode)) {
|
||||
record.setAdCode(adCode);
|
||||
}
|
||||
if (!cityCode.equals("[]")) {
|
||||
if (!("[]").equals(cityCode)) {
|
||||
record.setCityCode(cityCode);
|
||||
}
|
||||
record.setCenter(center);
|
||||
@ -250,14 +240,14 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
record.setParentId(parentId);
|
||||
record.setOrderNum(order);
|
||||
record.setId(String.valueOf(SnowFlake.getId()));
|
||||
String megName = ",";
|
||||
StringBuffer megName = new StringBuffer(",");
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
megName = megName + ids[i];
|
||||
megName = megName.append(ids[i]) ;
|
||||
if (i < ids.length - 1) {
|
||||
megName = megName + ",";
|
||||
megName.append(",");
|
||||
}
|
||||
}
|
||||
record.setPath(megName);
|
||||
record.setPath(megName.toString());
|
||||
regions.add(record);
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
@ -28,9 +28,11 @@ public class Commodity extends BaseEntity {
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String name;
|
||||
|
||||
//1:一口价(只需要传入price,price2不传)
|
||||
//2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
//3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
/**
|
||||
* 1:一口价(只需要传入price,price2不传)
|
||||
* 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
* 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
*/
|
||||
@ApiModelProperty(value = "价格类型")
|
||||
private Integer priceType;
|
||||
|
||||
|
||||
@ -11,12 +11,20 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class CommodityDTO {
|
||||
//商品ID
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private Integer goods_id;
|
||||
//商品名称
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
//地址
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String url;
|
||||
//审核状态
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private Integer audit_status;
|
||||
}
|
||||
|
||||
@ -8,9 +8,9 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 微信小程序直播商品DTO
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/17 11:03 上午
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ -22,9 +22,11 @@ public class GoodsInfo {
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String name;
|
||||
|
||||
//1:一口价(只需要传入price,price2不传)
|
||||
//2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
//3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
/**
|
||||
* 1:一口价(只需要传入price,price2不传)
|
||||
* 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)
|
||||
* 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传
|
||||
*/
|
||||
@ApiModelProperty(value = "价格类型")
|
||||
private Integer priceType;
|
||||
|
||||
@ -37,7 +39,7 @@ public class GoodsInfo {
|
||||
@ApiModelProperty(value = "商品详情页的小程序路径")
|
||||
private String url;
|
||||
|
||||
public GoodsInfo(Commodity commodity){
|
||||
public GoodsInfo(Commodity commodity) {
|
||||
BeanUtil.copyProperties(commodity, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,13 +3,24 @@ package cn.lili.modules.broadcast.entity.enums;
|
||||
|
||||
/**
|
||||
* 直播间状态
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/31 10:32 上午
|
||||
*
|
||||
*/
|
||||
public enum StudioStatusEnum {
|
||||
|
||||
NEW("新建"), START("开始"), END("结束");
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
NEW("新建"),
|
||||
/**
|
||||
* 开始
|
||||
*/
|
||||
START("开始"),
|
||||
/**
|
||||
* 结束
|
||||
*/
|
||||
END("结束");
|
||||
|
||||
private final String clientName;
|
||||
|
||||
@ -21,7 +32,4 @@ public enum StudioStatusEnum {
|
||||
return this.clientName;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package cn.lili.modules.broadcast.mapper;
|
||||
|
||||
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||
import cn.lili.modules.broadcast.entity.dto.SimpleCommodity;
|
||||
import cn.lili.modules.broadcast.entity.vos.CommodityVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@ -20,15 +19,39 @@ import java.util.List;
|
||||
*/
|
||||
public interface CommodityMapper extends BaseMapper<Commodity> {
|
||||
|
||||
/**
|
||||
* 获取直播商品ID列表
|
||||
*
|
||||
* @return 直播商品ID列表
|
||||
*/
|
||||
@Select("SELECT live_goods_id FROM li_commodity WHERE audit_status='0' or audit_status='1'")
|
||||
List<String> getAuditCommodity();
|
||||
|
||||
/**
|
||||
* 获取直播间关联直播商品列表
|
||||
*
|
||||
* @param roomId 直播间ID
|
||||
* @return 直播商品列表
|
||||
*/
|
||||
@Select("SELECT * FROM li_commodity c INNER JOIN li_studio_commodity sc ON sc.goods_id = c.live_goods_id WHERE sc.room_id =#{roomId}")
|
||||
List<Commodity> getCommodityByRoomId(Integer roomId);
|
||||
|
||||
/**
|
||||
* 获取直播商品图片列表
|
||||
*
|
||||
* @param roomId 直播间ID
|
||||
* @return 直播商品图片列表
|
||||
*/
|
||||
@Select("SELECT goods_image FROM li_commodity c INNER JOIN li_studio_commodity sc ON sc.goods_id = c.live_goods_id WHERE sc.room_id =#{roomId}")
|
||||
List<String> getSimpleCommodityByRoomId(Integer roomId);
|
||||
|
||||
/**
|
||||
* 获取直播商品VO分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 直播商品VO分页
|
||||
*/
|
||||
@Select("SELECT c.*,gs.quantity,s.store_name FROM li_commodity c INNER JOIN li_goods_sku gs ON c.sku_id = gs.id INNER JOIN li_store s ON s.id=c.store_id ${ew.customSqlSegment}")
|
||||
IPage<CommodityVO> commodityVOList(IPage<CommodityVO> page, @Param(Constants.WRAPPER) Wrapper<CommodityVO> queryWrapper);
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ public interface CommodityService extends IService<Commodity> {
|
||||
|
||||
/**
|
||||
* 添加直播商品
|
||||
* @param commodity 直播商品列表
|
||||
* @return 添加结果
|
||||
*/
|
||||
boolean addCommodity(List<Commodity> commodity);
|
||||
|
||||
@ -50,9 +50,9 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
|
||||
checkCommodity(commodity);
|
||||
//添加直播商品
|
||||
JSONObject json = wechatLivePlayerUtil.addGoods(commodity);
|
||||
if(!json.getStr("errcode").equals("0")){
|
||||
if(!"0".equals(json.getStr("errcode"))){
|
||||
log.error(json.getStr("errmsg"));
|
||||
throw new ServiceException(ResultCode.COMMODITY_ERROR);
|
||||
throw new ServiceException(ResultCode.COMMODITY_ERROR);
|
||||
}
|
||||
commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId")));
|
||||
commodity.setAuditId(json.getStr("auditId"));
|
||||
@ -79,7 +79,7 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
|
||||
@Override
|
||||
public boolean deleteCommodity(String goodsId) {
|
||||
JSONObject json = wechatLivePlayerUtil.deleteGoods(goodsId);
|
||||
if (json.getStr("errcode").equals("0")) {
|
||||
if ("0".equals(json.getStr("errcode"))) {
|
||||
return this.remove(new LambdaQueryWrapper<Commodity>().eq(Commodity::getLiveGoodsId, goodsId));
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -52,49 +52,42 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
|
||||
private StudioCommodityService studioCommodityService;
|
||||
@Resource
|
||||
private CommodityMapper commodityMapper;
|
||||
//延时任务
|
||||
@Autowired
|
||||
private TimeTrigger timeTrigger;
|
||||
//Rocketmq
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Override
|
||||
public Boolean create(Studio studio) {
|
||||
try {
|
||||
//创建小程序直播
|
||||
Map<String, String> roomMap = wechatLivePlayerUtil.create(studio);
|
||||
studio.setRoomId(Convert.toInt(roomMap.get("roomId")));
|
||||
studio.setQrCodeUrl(roomMap.get("qrcodeUrl"));
|
||||
studio.setStoreId(UserContext.getCurrentUser().getStoreId());
|
||||
studio.setStatus(StudioStatusEnum.NEW.name());
|
||||
//直播间添加成功发送直播间开启、关闭延时任务
|
||||
if (this.save(studio)) {
|
||||
//直播开启延时任务
|
||||
BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name());
|
||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
|
||||
Long.parseLong(studio.getStartTime()) * 1000L,
|
||||
broadcastMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
//创建小程序直播
|
||||
Map<String, String> roomMap = wechatLivePlayerUtil.create(studio);
|
||||
studio.setRoomId(Convert.toInt(roomMap.get("roomId")));
|
||||
studio.setQrCodeUrl(roomMap.get("qrcodeUrl"));
|
||||
studio.setStoreId(UserContext.getCurrentUser().getStoreId());
|
||||
studio.setStatus(StudioStatusEnum.NEW.name());
|
||||
//直播间添加成功发送直播间开启、关闭延时任务
|
||||
if (this.save(studio)) {
|
||||
//直播开启延时任务
|
||||
BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name());
|
||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
|
||||
Long.parseLong(studio.getStartTime()) * 1000L,
|
||||
broadcastMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
|
||||
//直播结束延时任务
|
||||
broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.END.name());
|
||||
timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
|
||||
Long.parseLong(studio.getEndTime()) * 1000L, broadcastMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
//直播结束延时任务
|
||||
broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.END.name());
|
||||
timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
|
||||
Long.parseLong(studio.getEndTime()) * 1000L, broadcastMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -37,13 +37,13 @@ public class WechatLivePlayerUtil {
|
||||
* @param studio 小程序直播
|
||||
* @return 房间ID
|
||||
*/
|
||||
public Map<String, String> create(Studio studio) throws Exception {
|
||||
public Map<String, String> create(Studio studio) {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=";
|
||||
//添加直播间
|
||||
Map<String, String> map = this.mockRoom(studio);
|
||||
JSONObject json = this.doPostWithJson(url, map);
|
||||
Map<String, String> roomMap = new HashMap<>();
|
||||
Map<String, String> roomMap = new HashMap<>(2);
|
||||
roomMap.put("roomId", json.getStr("roomId"));
|
||||
roomMap.put("qrcodeUrl", json.getStr("qrcode_url"));
|
||||
return roomMap;
|
||||
@ -76,7 +76,7 @@ public class WechatLivePlayerUtil {
|
||||
public String getLiveInfo(Integer roomId) {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
//获取回放
|
||||
map.put("action", "get_replay");
|
||||
//直播间ID
|
||||
@ -100,7 +100,7 @@ public class WechatLivePlayerUtil {
|
||||
public Boolean pushGoods(Integer roomId, Integer goodsId) {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
//直播间回放
|
||||
Integer[] ids = {goodsId};
|
||||
map.put("ids", ids);
|
||||
@ -120,7 +120,7 @@ public class WechatLivePlayerUtil {
|
||||
public Boolean goodsDeleteInRoom(Integer roomId, Integer goodsId) {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=";
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
Map<String, Integer> map = new HashMap<>(2);
|
||||
//直播间回放
|
||||
map.put("goodsId", goodsId);
|
||||
//商品ID
|
||||
@ -149,7 +149,7 @@ public class WechatLivePlayerUtil {
|
||||
GoodsInfo goodsInfo = new GoodsInfo(commodity);
|
||||
//上传微信临时图片
|
||||
goodsInfo.setCoverImgUrl(wechatMediaUtil.uploadMedia("image", commodity.getGoodsImage()));
|
||||
Map<String, GoodsInfo> map = new HashMap<>();
|
||||
Map<String, GoodsInfo> map = new HashMap<>(2);
|
||||
//调用新增直播商品接口
|
||||
map.put("goodsInfo", goodsInfo);
|
||||
return this.doPostWithJson(url, map);
|
||||
@ -164,7 +164,7 @@ public class WechatLivePlayerUtil {
|
||||
public JSONObject deleteGoods(String goodsId) {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("goodsId", goodsId);
|
||||
return this.doPostWithJson(url, map);
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class WechatLivePlayerUtil {
|
||||
public JSONObject getGoodsWareHouse(List<String> goodsIdList) {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("goods_ids", goodsIdList);
|
||||
return this.doPostWithJson(url, map);
|
||||
}
|
||||
@ -201,9 +201,9 @@ public class WechatLivePlayerUtil {
|
||||
log.info("微信小程序请求结果:" + content);
|
||||
//获取请求内容,如果token过期则重新获取,如果出错则抛出错误
|
||||
JSONObject jsonObject = new JSONObject(content);
|
||||
if (jsonObject.get("errcode").toString().equals("0")) {
|
||||
if (("0").equals(jsonObject.get("errcode").toString())) {
|
||||
return jsonObject;
|
||||
} else if (jsonObject.get("errcode").equals("40001")) {
|
||||
} else if (("40001").equals(jsonObject.get("errcode"))) {
|
||||
wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||
return this.doPostWithJson(url, map);
|
||||
} else {
|
||||
@ -212,7 +212,7 @@ public class WechatLivePlayerUtil {
|
||||
}
|
||||
|
||||
private Map<String, String> mockRoom(Studio studio) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
Map<String, String> map = new HashMap<>(16);
|
||||
//背景图
|
||||
map.put("coverImg", wechatMediaUtil.uploadMedia("image", studio.getCoverImg()));
|
||||
//分享图
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.broadcast.util;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
||||
import cn.lili.modules.message.util.WechatAccessTokenUtil;
|
||||
@ -11,7 +12,6 @@ import org.springframework.stereotype.Component;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 微信媒体工具
|
||||
@ -78,7 +78,7 @@ public class WechatMediaUtil {
|
||||
//使用outputStream流输出信息到请求体当中去
|
||||
out.write(("--" + boundary + "\r\n").getBytes());
|
||||
out.write(("Content-Disposition: form-data; name=\"media\";\r\n"
|
||||
+ "filename=\"" + (new Date().getTime()) + fileExt + "\"\r\n"
|
||||
+ "filename=\"" + (System.currentTimeMillis()) + fileExt + "\"\r\n"
|
||||
+ "Content-Type: " + contentType + "\r\n\r\n").getBytes());
|
||||
while ((size = bufferedIn.read(bytes)) != -1) {
|
||||
out.write(bytes, 0, size);
|
||||
@ -108,7 +108,7 @@ public class WechatMediaUtil {
|
||||
JSONObject jsonObject = new JSONObject(resultStr.toString());
|
||||
log.info("微信媒体上传:" + jsonObject.toString());
|
||||
//判断是否传递成功,如果token过期则重新获取
|
||||
if (jsonObject.get("errcode") != null && jsonObject.get("errcode").equals("40001")) {
|
||||
if (jsonObject.get("errcode") != null && ("40001").equals(jsonObject.get("errcode"))) {
|
||||
wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||
return this.uploadMedia(type, mediaFileUrl);
|
||||
} else if (jsonObject.get("errcode") != null) {
|
||||
@ -137,6 +137,8 @@ public class WechatMediaUtil {
|
||||
case "image/jpg":
|
||||
fileExt = ".jpg";
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException(ResultCode.IMAGE_FILE_EXT_ERROR);
|
||||
}
|
||||
return fileExt;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user