采用阿里代码规约,对代码进行优化
This commit is contained in:
parent
9e240f22b6
commit
3e73257922
@ -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}")
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
* @author Chopper
|
||||
* @date 2021-03-13 16:58
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
|
||||
@ -64,6 +66,9 @@ public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
break;
|
||||
case BANK_TRANSFER:
|
||||
break;
|
||||
default:
|
||||
log.error("订单支付执行异常,订单编号:", orderMessage.getOrderSn());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -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;
|
||||
@ -123,6 +122,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
case BUY_GOODS_COMPLETE:
|
||||
this.goodsBuyComplete(messageExt);
|
||||
break;
|
||||
default:
|
||||
log.error("商品执行异常:", new String(messageExt.getBody()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ public class StoreRatingExecute implements EveryDayExecute {
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
//会员评价
|
||||
@Autowired
|
||||
@Resource
|
||||
private MemberEvaluationMapper memberEvaluationMapper;
|
||||
|
||||
|
||||
@ -39,10 +39,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) {
|
||||
//保存评分
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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() + "}_";
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -9,6 +9,10 @@ import cn.lili.common.token.SecretKeyUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 用户上下文
|
||||
@ -20,15 +24,16 @@ import io.jsonwebtoken.Jwts;
|
||||
*/
|
||||
public class UserContext {
|
||||
|
||||
private static AuthenticationHandler authenticationHandler;
|
||||
private static RequestContextHolder requestContextHolder;
|
||||
|
||||
public static void setHolder(AuthenticationHandler authenticationHandler) {
|
||||
UserContext.authenticationHandler = authenticationHandler;
|
||||
public static void setRequestContextHolder(RequestContextHolder requestContextHolder) {
|
||||
UserContext.requestContextHolder = requestContextHolder;
|
||||
}
|
||||
|
||||
|
||||
public static AuthUser getCurrentUser() {
|
||||
return authenticationHandler.getAuthUser();
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String accessToken = request.getHeader("accessToken");
|
||||
return getAuthUser(accessToken);
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +49,18 @@ public class UserContext {
|
||||
if (cache.keys("*" + accessToken).size() == 0) {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
return getAuthUser(accessToken);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据jwt获取token重的用户信息
|
||||
* @param accessToken token
|
||||
* @return
|
||||
*/
|
||||
public static AuthUser getAuthUser(String accessToken) {
|
||||
try {
|
||||
//获取token的信息
|
||||
Claims claims
|
||||
= Jwts.parser()
|
||||
|
@ -31,6 +31,6 @@ public class UserContextInit implements ApplicationRunner {
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
UserContext.setHolder(authenticationHandler);
|
||||
//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 {
|
||||
|
||||
|
@ -9,12 +9,14 @@ import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 对象属性复制
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 复制属性
|
||||
*
|
||||
* @param objectFrom
|
||||
* @param objectTo
|
||||
*/
|
||||
@ -36,7 +38,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();
|
||||
@ -45,8 +47,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,8 +54,8 @@ 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();
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
default:
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
@ -106,6 +107,7 @@ public class ImageUtil {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void fillMatrix(int[][] matrix, int[] values) {
|
||||
int filled = 0;
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
@ -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;
|
||||
|
||||
|
@ -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,7 +50,7 @@ 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);
|
||||
}
|
||||
@ -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,10 +52,8 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
|
||||
private StudioCommodityService studioCommodityService;
|
||||
@Resource
|
||||
private CommodityMapper commodityMapper;
|
||||
//延时任务
|
||||
@Autowired
|
||||
private TimeTrigger timeTrigger;
|
||||
//Rocketmq
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class WechatLivePlayerUtil {
|
||||
//添加直播间
|
||||
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;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class AuthCallback implements Serializable {
|
||||
/**
|
||||
* 访问AuthorizeUrl后回调时带的参数auth_code,该参数目前只使用于支付宝登录
|
||||
*/
|
||||
private String auth_code;
|
||||
private String authCode;
|
||||
|
||||
/**
|
||||
* 访问AuthorizeUrl后回调时带的参数state,用于和请求AuthorizeUrl前的state比较,防止CSRF攻击
|
||||
|
@ -23,20 +23,36 @@ public class AuthToken implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2701476618576443366L;
|
||||
|
||||
//第三方token
|
||||
/**
|
||||
* 第三方token
|
||||
*/
|
||||
private String accessToken;
|
||||
//第三方刷新token
|
||||
/**
|
||||
* 第三方刷新token
|
||||
*/
|
||||
private String refreshToken;
|
||||
//有效时间
|
||||
/**
|
||||
* 有效时间
|
||||
*/
|
||||
private int expireIn;
|
||||
//会员id
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private String uid;
|
||||
//联合登录id
|
||||
/**
|
||||
* 联合登录id
|
||||
*/
|
||||
private String unionId;
|
||||
//联合登录openid
|
||||
/**
|
||||
* 联合登录openid
|
||||
*/
|
||||
private String openId;
|
||||
//请求码
|
||||
/**
|
||||
* 请求码
|
||||
*/
|
||||
private String accessCode;
|
||||
|
||||
/**
|
||||
* 范围
|
||||
*/
|
||||
private String scope;
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public enum AuthUserGender {
|
||||
* @since 1.13.2
|
||||
*/
|
||||
public static AuthUserGender getWechatRealGender(String originalGender) {
|
||||
if (StringUtils.isEmpty(originalGender) || "0".equals(originalGender)) {
|
||||
String noGender="0";
|
||||
if (StringUtils.isEmpty(originalGender) || noGender.equals(originalGender)) {
|
||||
return AuthUserGender.UNKNOWN;
|
||||
}
|
||||
return getRealGender(originalGender);
|
||||
|
@ -14,7 +14,8 @@ public enum ConnectEnum {
|
||||
*/
|
||||
QQ("QQ登录"),
|
||||
WEIBO("微博联合登录"),
|
||||
WECHAT("微信联合登录"),//只存放unionid
|
||||
WECHAT("微信联合登录"),
|
||||
//只存放unionid
|
||||
WECHAT_OPEN_ID("微信openid登录"),
|
||||
WECHAT_MP_OPEN_ID("微信openid登录"),
|
||||
ALIPAY("支付宝登录"),
|
||||
|
@ -44,7 +44,7 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||
request.setGrantType("authorization_code");
|
||||
request.setCode(authCallback.getAuth_code());
|
||||
request.setCode(authCallback.getAuthCode());
|
||||
AlipaySystemOauthTokenResponse response = null;
|
||||
try {
|
||||
response = this.alipayClient.execute(request);
|
||||
|
@ -71,10 +71,6 @@ public abstract class AuthDefaultRequest implements AuthRequest {
|
||||
public AuthResponse login(AuthCallback authCallback) {
|
||||
try {
|
||||
AuthChecker.checkCode(source, authCallback);
|
||||
// if (!config.isIgnoreCheckState()) {
|
||||
// AuthChecker.checkState(authCallback.getState(), source, cache);
|
||||
// }
|
||||
|
||||
AuthToken authToken = this.getAccessToken(authCallback);
|
||||
ConnectAuthUser user = this.getUserInfo(authToken);
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();
|
||||
|
@ -23,14 +23,16 @@ public interface ConnectConfigService extends IService<ConnectConfig> {
|
||||
/**
|
||||
* 获取配置详情
|
||||
*
|
||||
* @return
|
||||
* @param key 配置关键字
|
||||
* @return 配置参数
|
||||
*/
|
||||
ConnectConfig getConfig(String key);
|
||||
|
||||
/**
|
||||
* 获取配置详情
|
||||
* 保存配置
|
||||
*
|
||||
* @return
|
||||
* @param connectConfig 联合登录配置
|
||||
* @return 联合登录配置
|
||||
*/
|
||||
ConnectConfig saveConfig(ConnectConfig connectConfig);
|
||||
}
|
@ -30,9 +30,12 @@ public interface ConnectService extends IService<Connect> {
|
||||
/**
|
||||
* 联合登陆
|
||||
*
|
||||
* @param type
|
||||
* @param unionid
|
||||
* @return
|
||||
* @param type 类型
|
||||
* @param unionid unionid
|
||||
* @param longTerm 是否长时间有效
|
||||
* @param uuid UUID
|
||||
* @return token
|
||||
* @throws NoPermissionException 不允许操作
|
||||
*/
|
||||
Token unionLoginCallback(String type, String unionid, String uuid, boolean longTerm) throws NoPermissionException;
|
||||
|
||||
@ -42,6 +45,7 @@ public interface ConnectService extends IService<Connect> {
|
||||
* @param type 第三方登录类型
|
||||
* @param authUser 第三方登录返回封装类
|
||||
* @param uuid 用户uuid
|
||||
* @return token
|
||||
*/
|
||||
Token unionLoginCallback(String type, ConnectAuthUser authUser, String uuid);
|
||||
|
||||
@ -86,7 +90,7 @@ public interface ConnectService extends IService<Connect> {
|
||||
*
|
||||
* @param authUser 登录对象
|
||||
* @param uuid uuid
|
||||
* @return
|
||||
* @return token
|
||||
*/
|
||||
Token appLoginCallback(ConnectAuthUser authUser, String uuid);
|
||||
|
||||
@ -95,7 +99,8 @@ public interface ConnectService extends IService<Connect> {
|
||||
* 微信一键登录
|
||||
* 小程序自动登录 没有账户自动注册
|
||||
*
|
||||
* @return
|
||||
* @param params 微信小程序登录参数
|
||||
* @return token
|
||||
*/
|
||||
Token miniProgramAutoLogin(WechatMPLoginParams params);
|
||||
}
|
@ -66,7 +66,7 @@ public class AuthChecker {
|
||||
public static void checkCode(ConnectAuth connectAuth, AuthCallback callback) {
|
||||
String code = callback.getCode();
|
||||
if (connectAuth == ConnectAuthEnum.ALIPAY) {
|
||||
code = callback.getAuth_code();
|
||||
code = callback.getAuthCode();
|
||||
}
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
throw new AuthException(AuthResponseStatus.ILLEGAL_CODE, connectAuth);
|
||||
|
@ -19,28 +19,28 @@ public class Base64Utils {
|
||||
/**
|
||||
* 标准编码表
|
||||
*/
|
||||
private static final byte[] STANDARD_ENCODE_TABLE = { //
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', //
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', //
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', //
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', //
|
||||
'4', '5', '6', '7', '8', '9', '+', '/' //
|
||||
private static final byte[] STANDARD_ENCODE_TABLE = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/'
|
||||
};
|
||||
/**
|
||||
* URL安全的编码表,将 + 和 / 替换为 - 和 _
|
||||
*/
|
||||
private static final byte[] URL_SAFE_ENCODE_TABLE = { //
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', //
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', //
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', //
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', //
|
||||
'4', '5', '6', '7', '8', '9', '-', '_' //
|
||||
private static final byte[] URL_SAFE_ENCODE_TABLE = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '-', '_'
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------- encode
|
||||
@ -174,7 +174,8 @@ public class Base64Utils {
|
||||
}
|
||||
}
|
||||
|
||||
int left = len - evenlen;//剩余位数
|
||||
//剩余位数
|
||||
int left = len - evenlen;
|
||||
if (left > 0) {
|
||||
int i = ((arr[evenlen] & 0xff) << 10) | (left == 2 ? ((arr[len - 1] & 0xff) << 2) : 0);
|
||||
|
||||
|
@ -64,7 +64,11 @@ public class ConnectUtil {
|
||||
|
||||
static String prefix = "/buyer/connect/callback/";
|
||||
|
||||
//回调地址获取
|
||||
/**
|
||||
* 回调地址获取
|
||||
* @param connectAuthEnum 用户枚举
|
||||
* @return 回调地址
|
||||
*/
|
||||
String getRedirectUri(ConnectAuthEnum connectAuthEnum) {
|
||||
return apiProperties.getBuyer() + prefix + connectAuthEnum.getName();
|
||||
}
|
||||
@ -191,39 +195,6 @@ public class ConnectUtil {
|
||||
}
|
||||
|
||||
break;
|
||||
// case ALIPAY:
|
||||
// //支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip
|
||||
// authRequest = new AuthAlipayRequest(AuthConfig.builder()
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
// .alipayPublicKey("")
|
||||
// .redirectUri(getRedirectUri(authInterface))
|
||||
// .build(), cache);
|
||||
// break;
|
||||
// case WEIBO:
|
||||
// List<String> scopes = new ArrayList<>();
|
||||
// scopes.add("all");
|
||||
// authRequest = new AuthWeiboRequest(AuthConfig.builder()
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
// .redirectUri(getRedirectUri(authInterface))
|
||||
// .scopes(scopes)
|
||||
// .build(), cache);
|
||||
// break;
|
||||
// case "wechat_open":
|
||||
// authRequest = new AuthWeChatOpenRequest(AuthConfig.builder()
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
// .redirectUri("https://z171l91606.51mypc.cn/callback/wechat")
|
||||
// .build());
|
||||
// break;
|
||||
// case "wechat_mp":
|
||||
// authRequest = new AuthWeChatMpRequest(AuthConfig.builder()
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
// .redirectUri("")
|
||||
// .build());
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -233,9 +204,11 @@ public class ConnectUtil {
|
||||
return authRequest;
|
||||
}
|
||||
|
||||
//\b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
|
||||
//字符串在编译时会被转码一次,所以是 "\\b"
|
||||
//\B 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
|
||||
/**
|
||||
* \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"
|
||||
@ -244,7 +217,9 @@ public class ConnectUtil {
|
||||
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);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class DistributionGoods {
|
||||
this.specs = "";
|
||||
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
|
||||
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
||||
if (!entry.getKey().equals("images")) {
|
||||
if (!"images".equals(entry.getKey())) {
|
||||
this.specs = this.specs + entry.getKey() + ":" + entry.getValue() + " ";
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,35 @@ import org.apache.ibatis.annotations.Select;
|
||||
*/
|
||||
public interface DistributionGoodsMapper extends BaseMapper<DistributionGoods> {
|
||||
|
||||
/**
|
||||
* 获取分销员未选择商品VO分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 查询条件
|
||||
* @param distributionId 分销员ID
|
||||
* @return 分销员未选择商品VO分页
|
||||
*/
|
||||
@Select("SELECT dg.* FROM li_distribution_goods dg WHERE dg.id NOT IN(SELECT distribution_goods_id FROM li_distribution_selected_goods WHERE distribution_id=${distributionId}) ${ew.customSqlSegment}")
|
||||
IPage<DistributionGoodsVO> notSelectGoods(IPage<DistributionGoodsVO> page, @Param(Constants.WRAPPER) Wrapper<DistributionGoodsVO> queryWrapper, String distributionId);
|
||||
|
||||
/**
|
||||
* 获取分销员已选择分销商品VO分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 查询条件
|
||||
* @param distributionId 分销员ID
|
||||
* @return 分销员已选择分销商品VO分页
|
||||
*/
|
||||
@Select("SELECT dg.* FROM li_distribution_goods dg WHERE dg.id IN(SELECT distribution_goods_id FROM li_distribution_selected_goods WHERE distribution_id=${distributionId}) ${ew.customSqlSegment}")
|
||||
IPage<DistributionGoodsVO> selectGoods(IPage<DistributionGoodsVO> page, @Param(Constants.WRAPPER) Wrapper<DistributionGoodsVO> queryWrapper, String distributionId);
|
||||
|
||||
/**
|
||||
* 获取分销商品VO分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 分销商品VO分页
|
||||
*/
|
||||
@Select("SELECT dg.* FROM li_distribution_goods dg LEFT JOIN li_distribution_selected_goods dsg ON dg.id = dsg.distribution_goods_id ${ew.customSqlSegment}")
|
||||
IPage<DistributionGoodsVO> getDistributionGoodsVO(IPage<DistributionGoodsVO> page, @Param(Constants.WRAPPER) Wrapper<DistributionGoodsVO> queryWrapper);
|
||||
|
||||
|
@ -13,9 +13,21 @@ import org.apache.ibatis.annotations.Update;
|
||||
*/
|
||||
public interface DistributionMapper extends BaseMapper<Distribution> {
|
||||
|
||||
/**
|
||||
* 修改分销员可提现金额
|
||||
*
|
||||
* @param canRebate 提现金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@Update("UPDATE li_distribution set can_rebate = can_rebate+#{canRebate} WHERE id = #{distributionId}")
|
||||
void subCanRebate(Double canRebate, String distributionId);
|
||||
|
||||
/**
|
||||
* 添加可提现金额
|
||||
*
|
||||
* @param canRebate 提现金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@Update("UPDATE li_distribution set can_rebate = (can_rebate+#{canRebate}) , rebate_total=(rebate_total+#{canRebate}) , distribution_order_count=(distribution_order_count+1) WHERE id = #{distributionId}")
|
||||
void addCanRebate(Double canRebate, String distributionId);
|
||||
}
|
@ -14,7 +14,10 @@ import org.apache.ibatis.annotations.Update;
|
||||
public interface DistributionOrderMapper extends BaseMapper<DistributionOrder> {
|
||||
|
||||
/**
|
||||
* 分销提佣
|
||||
* 修改分销员提现金额
|
||||
*
|
||||
* @param distributionOrderStatus 分销订单状态
|
||||
* @param settleCycle 时间
|
||||
*/
|
||||
@Update("UPDATE li_distribution AS d " +
|
||||
"SET d.can_rebate =(d.can_rebate +(SELECT SUM( dorder.rebate ) FROM li_distribution_order AS dorder WHERE dorder.distribution_id = d.id AND dorder.distribution_order_status=#{distributionOrderStatus} AND dorder.settle_cycle< #{settleCycle} ))")
|
||||
|
@ -19,14 +19,16 @@ public interface DistributionCashService extends IService<DistributionCash> {
|
||||
/**
|
||||
* 提交分销提现申请
|
||||
*
|
||||
* @param applyMoney
|
||||
* @param applyMoney 申请金额
|
||||
* @return 操作状态
|
||||
*/
|
||||
Boolean cash(Double applyMoney);
|
||||
|
||||
/**
|
||||
* 获取当前会员的分销提现分页列表
|
||||
*
|
||||
* @return
|
||||
* @param page 分页
|
||||
* @return 申请提现分页
|
||||
*/
|
||||
IPage<DistributionCash> getDistributionCash(PageVO page);
|
||||
|
||||
|
@ -35,7 +35,8 @@ public interface DistributionService extends IService<Distribution> {
|
||||
/**
|
||||
* 提交分销申请
|
||||
*
|
||||
* @return
|
||||
* @param distributionApplyDTO 分销申请DTO
|
||||
* @return 分销员
|
||||
*/
|
||||
Distribution applyDistribution(DistributionApplyDTO distributionApplyDTO);
|
||||
|
||||
@ -67,7 +68,7 @@ public interface DistributionService extends IService<Distribution> {
|
||||
/**
|
||||
* 绑定会员的分销员关系
|
||||
*
|
||||
* @return
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
void bindingDistribution(String distributionId);
|
||||
|
||||
@ -78,6 +79,7 @@ public interface DistributionService extends IService<Distribution> {
|
||||
|
||||
/**
|
||||
* 修改可提现金额
|
||||
*
|
||||
* @param canRebate 修改金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@ -85,7 +87,9 @@ public interface DistributionService extends IService<Distribution> {
|
||||
|
||||
/**
|
||||
* 添加分销金额
|
||||
* @param rebate
|
||||
*
|
||||
* @param rebate 金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
void addRebate(Double rebate, String distributionId);
|
||||
}
|
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