Skip to content

Commit

Permalink
采用阿里代码规约,对代码进行优化
Browse files Browse the repository at this point in the history
  • Loading branch information
lifenlong committed Jul 8, 2021
1 parent 9e240f2 commit 3e73257
Show file tree
Hide file tree
Showing 343 changed files with 2,627 additions and 1,477 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class DistributionBuyerController {
@Autowired
private DistributionOrderService distributionOrderService;

//申请分销员
@ApiOperation(value = "申请分销员")
@PostMapping
public ResultMessage<Object> applyDistribution(DistributionApplyDTO distributionApplyDTO) {
Expand All @@ -63,7 +62,6 @@ public ResultMessage<Distribution> getDistribution() {
return ResultUtil.data(distributionService.getDistribution());
}

//申请分销员
@ApiOperation(value = "绑定分销员")
@ApiImplicitParam(name = "distributionId", value = "分销员ID", required = true, paramType = "path")
@GetMapping("/bindingDistribution/{distributionId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public ResultMessage<File> upload(@RequestHeader String accessToken, String id,
if (file.getUserEnums().equals(authUser.getRole().name())) {
break;
}
default:
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
}
fileService.updateById(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;

Expand All @@ -23,13 +24,18 @@
* @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;

Expand All @@ -48,6 +54,9 @@ public void orderChange(OrderMessage orderMessage) {
distributionOrderService.cancelOrder(orderMessage.getOrderSn());
break;
}
default:
log.error("分销订单执行异常:", orderMessage.getOrderSn());
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void orderCreate(TradeDTO tradeDTO) {
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);
//保存站内信
Expand All @@ -58,7 +58,7 @@ public void orderChange(OrderMessage orderMessage) {
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:
Expand Down Expand Up @@ -103,7 +103,7 @@ public void orderChange(OrderMessage orderMessage) {
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);
Expand Down Expand Up @@ -154,7 +154,7 @@ public void memberPointChange(MemberPointMessage memberPointMessage) {
//组织站内信参数
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());
Expand All @@ -178,7 +178,7 @@ public void memberWithdrawal(MemberWithdrawalMessage memberWithdrawalMessage) {
//组织参数
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);
Expand Down
5 changes: 5 additions & 0 deletions consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;

Expand All @@ -19,6 +20,7 @@
* @author Chopper
* @date 2021-03-13 16:58
*/
@Slf4j
@Service
public class PaymentExecute implements OrderStatusChangeEvent {

Expand Down Expand Up @@ -64,6 +66,9 @@ public void orderChange(OrderMessage orderMessage) {
break;
case BANK_TRANSFER:
break;
default:
log.error("订单支付执行异常,订单编号:", orderMessage.getOrderSn());
break;
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
@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;

Expand All @@ -43,6 +45,8 @@ public void onMessage(MessageExt messageExt) {
e);
}
}
default:
log.error("售后状态修改事件执行异常:", new String(messageExt.getBody()));
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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;
Expand Down Expand Up @@ -123,6 +122,9 @@ public void onMessage(MessageExt messageExt) {
case BUY_GOODS_COMPLETE:
this.goodsBuyComplete(messageExt);
break;
default:
log.error("商品执行异常:", new String(messageExt.getBody()));
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
@Component
public class BillExecute implements EveryDayExecute {

//结算单
/**
* 结算单
*/
@Autowired
private BillService billService;
//店铺详情
/**
* 店铺详情
*/
@Resource
private StoreDetailMapper storeDetailMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
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;

Expand All @@ -22,11 +22,15 @@
*/
@Component
public class GoodsExecute implements EveryDayExecute {
//会员评价
@Autowired
/**
* 会员评价
*/
@Resource
private MemberEvaluationMapper memberEvaluationMapper;
//商品
@Autowired
/**
* 商品
*/
@Resource
private GoodsMapper goodsMapper;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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;
Expand All @@ -28,12 +27,15 @@
**/
@Slf4j
@Component

public class CancelOrderTaskExecute implements EveryMinuteExecute {
//订单
/**
* 订单
*/
@Autowired
private OrderService orderService;
//设置
/**
* 设置
*/
@Autowired
private SettingService settingService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
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;

/**
Expand All @@ -29,7 +29,7 @@ public class StoreRatingExecute implements EveryDayExecute {
@Autowired
private StoreService storeService;
//会员评价
@Autowired
@Resource
private MemberEvaluationMapper memberEvaluationMapper;


Expand All @@ -39,10 +39,10 @@ public void execute() {
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) {
//保存评分
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private void startDelayQueueMachine() {

/**
* 要实现延时队列的名字
* @return 促销延时队列名称
*/
public abstract String setDelayQueueName();

Expand All @@ -88,7 +89,7 @@ private void startDelayQueueMachine() {
*/
@PostConstruct
public void init() {
new Thread(this::startDelayQueueMachine).start();
ThreadPoolUtil.getPool().execute(this::startDelayQueueMachine);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ public void interceptor(LimitPoint limitPointAnnotation) {
}


//默认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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -61,7 +61,7 @@ public void controllerAspect() {
*/
@Before("controllerAspect()")
public void doBefore() {
beginTimeThreadLocal.set(new Date());
BEGIN_TIME_THREAD_LOCAL.set(new Date());
}


Expand Down Expand Up @@ -110,7 +110,7 @@ public void after(JoinPoint joinPoint, Object rvt) {
//写入自定义日志内容
systemLogVO.setCustomerLog(customerLog);
//请求开始时间
long beginTime = beginTimeThreadLocal.get().getTime();
long beginTime = BEGIN_TIME_THREAD_LOCAL.get().getTime();
long endTime = System.currentTimeMillis();
//请求耗时
Long usedTime = endTime - beginTime;
Expand Down Expand Up @@ -157,7 +157,7 @@ public void run() {
*/
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();
Expand Down
Loading

0 comments on commit 3e73257

Please sign in to comment.