feat:订单优化

This commit is contained in:
haoxr 2021-03-20 23:58:50 +08:00
parent 5aec657f19
commit bd249300f0
21 changed files with 129 additions and 186 deletions

View File

@ -1,10 +1,7 @@
package com.youlai.mall.oms.pojo.bo.app;
import com.youlai.common.base.BaseVO;
import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery;
import com.youlai.mall.oms.pojo.domain.OmsOrder;
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
import com.youlai.mall.oms.pojo.domain.OmsOrderLog;
import lombok.Data;
import java.util.List;
@ -22,8 +19,4 @@ public class OrderBO {
private List<OmsOrderItem> orderItems;
private OmsOrderLog orderLog;
private OmsOrderDelivery orderDelivery;
}

View File

@ -1,13 +1,16 @@
package com.youlai.mall.oms.pojo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.base.BaseEntity;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* 订单详情表
@ -94,5 +97,7 @@ public class OmsOrder extends BaseEntity {
*/
private Integer deleted;
@TableField(exist = false)
private List<OmsOrderItem> orderItems;
}

View File

@ -3,8 +3,10 @@ package com.youlai.mall.oms.pojo.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.base.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
@ -17,8 +19,9 @@ import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OmsOrderItem extends BaseEntity {
/**
* id
*/
@ -89,4 +92,6 @@ public class OmsOrderItem extends BaseEntity {
*/
private Integer deleted;
}

View File

@ -1,64 +0,0 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.base.BaseVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* @author huawei
* @desc
* @email huawei_code@163.com
* @date 2021/2/13
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderListVO extends BaseVO {
/**
* time : 2019-04-06 11:37
* state : 9
* goodsList : [{"title":"古黛妃 短袖t恤女 春夏装2019新款韩版宽松","price":179.5,"image":"https://img13.360buyimg.com/n8/jfs/t1/30343/20/1029/481370/5c449438Ecb46a15b/2b2adccb6dc742fd.jpg","number":1,"attr":"珊瑚粉 M"}]
*/
private Long id;
private String orderSn;
private Long totalAmount;
private Long payAmount;
private Date gmtCreate;
private Integer totalQuantity;
private String time;
private Integer status;
private String statusDesc;
private List<OrderItemBean> orderItemLIst;
@Data
public static class OrderItemBean extends BaseVO {
/**
* title : 古黛妃 短袖t恤女 春夏装2019新款韩版宽松
* price : 179.5
* image : https://img13.360buyimg.com/n8/jfs/t1/30343/20/1029/481370/5c449438Ecb46a15b/2b2adccb6dc742fd.jpg
* number : 1
* attr : 珊瑚粉 M
*/
private Long id;
private Long orderId;
private String skuId;
private String skuPic;
private Integer skuQuantity;
private Long skuTotalPrice;
private String title;
private Long price;
private String image;
private Integer number;
private String attr;
}
}

View File

@ -1,10 +1,12 @@
package com.youlai.mall.oms.controller.app;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.result.Result;
import com.youlai.mall.oms.enums.PayTypeEnum;
import com.youlai.mall.oms.pojo.domain.OmsOrder;
import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO;
import com.youlai.mall.oms.pojo.vo.OrderConfirmVO;
import com.youlai.mall.oms.pojo.vo.OrderListVO;
import com.youlai.mall.oms.pojo.vo.OrderSubmitVO;
import com.youlai.mall.oms.pojo.dto.OrderSubmitDTO;
import com.youlai.mall.oms.service.IOrderPayService;
@ -13,9 +15,7 @@ import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
@ -33,24 +33,31 @@ public class OrderController {
private IOrderService orderService;
private IOrderPayService orderPayService;
@ApiOperation("订单列表")
@GetMapping
@ApiImplicitParam(name = "status", value = "订单状态", required = true, defaultValue = "0")
public Result<List<OrderListVO>> list(Integer status) {
List<OrderListVO> orderList = orderService.list(status);
return Result.success(orderList);
@ApiImplicitParams({
@ApiImplicitParam(name = "page",defaultValue = "1", value = "页码", paramType = "query", dataType = "Long"),
@ApiImplicitParam(name = "limit",defaultValue = "10", value = "每页数量", paramType = "query", dataType = "Long"),
@ApiImplicitParam(name = "status", value = "订单状态", paramType = "query", dataType = "Integer")
})
public Result list(
Long page,
Long limit,
Integer status
) {
IPage<OmsOrder> result = orderService.list(new Page<>(page, limit), new OmsOrder().setStatus(status));
return Result.success(result.getRecords(), result.getTotal());
}
@ApiOperation( "订单确认")
@ApiImplicitParam(name = "orderConfirm",value = "确认订单信息",required = true, paramType = "body", dataType = "OrderConfirmDTO")
@ApiOperation("订单确认")
@ApiImplicitParam(name = "orderConfirm", value = "确认订单信息", required = true, paramType = "body", dataType = "OrderConfirmDTO")
@PostMapping("/_confirm")
public Result<OrderConfirmVO> confirm(@RequestBody OrderConfirmDTO orderConfirm) {
OrderConfirmVO result = orderService.confirm(orderConfirm);
return Result.success(result);
}
@ApiOperation( "订单提交")
@ApiOperation("订单提交")
@ApiImplicitParam(name = "orderSubmitDTO", value = "提交订单信息", required = true, paramType = "body", dataType = "orderSubmitDTO")
@PostMapping("/_submit")
public Result submit(@Valid @RequestBody OrderSubmitDTO orderSubmitDTO) {

View File

@ -2,7 +2,11 @@ package com.youlai.mall.oms.mapper;
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.mall.pms.pojo.domain.PmsSku;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 订单商品信息表
@ -14,4 +18,9 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface OrderItemMapper extends BaseMapper<OmsOrderItem> {
@Select("<script>" +
" select id,order_id,sku_id,sku_name,sku_pic,sku_price,sku_quantity from oms_order_item where order_id=#{orderId}" +
"</script>")
List<OmsOrderItem> listByOrderId(Long orderId);
}

View File

@ -1,8 +1,10 @@
package com.youlai.mall.oms.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.mall.oms.pojo.domain.OmsOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* 订单详情表
@ -14,4 +16,17 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface OrderMapper extends BaseMapper<OmsOrder> {
@Select("<script>" +
" select id,order_sn,total_amount,pay_amount,status from oms_order" +
" where 1=1 " +
" <if test ='order.status !=null ' >" +
" AND status= #{order.status} " +
" </if>" +
"</script>")
@Results({
@Result(id = true, column = "id", property = "id"),
@Result(property = "orderItems",column = "id",many = @Many(select="com.youlai.mall.oms.mapper.OrderItemMapper.listByOrderId"))
})
List<OmsOrder> list(Page<OmsOrder> page, OmsOrder order);
}

View File

@ -1,11 +1,12 @@
package com.youlai.mall.oms.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.oms.pojo.domain.OmsOrder;
import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO;
import com.youlai.mall.oms.pojo.vo.OrderConfirmVO;
import com.youlai.mall.oms.pojo.vo.OrderListVO;
import com.youlai.mall.oms.pojo.vo.OrderSubmitVO;
import com.youlai.mall.oms.pojo.dto.OrderSubmitDTO;
@ -30,9 +31,6 @@ public interface IOrderService extends IService<OmsOrder> {
*/
OrderSubmitVO submit(OrderSubmitDTO orderSubmitDTO) ;
/**
* 系统关闭订单
*/
@ -48,14 +46,7 @@ public interface IOrderService extends IService<OmsOrder> {
*/
boolean deleteOrder(Long id);
/**
* 订单列表查询
*/
List<OrderListVO> list(Integer status);
/**
* 根据订单ID获取订单信息
*/
OmsOrder getByOrderId(Long id);
IPage<OmsOrder> list(Page<OmsOrder> omsOrderPage, OmsOrder order);
}

View File

@ -36,7 +36,7 @@ public class OrderPayServiceImpl extends ServiceImpl<OrderPayMapper, OmsOrderPay
@GlobalTransactional(rollbackFor = Exception.class)
public boolean pay(Long orderId) {
OmsOrder order = orderService.getByOrderId(orderId);
OmsOrder order = orderService.getById(orderId);
if (order != null && !OrderStatusEnum.PENDING_PAYMENT.getCode().equals(order.getStatus())) {
throw new BizException("支付失败,请检查订单状态");
}

View File

@ -5,6 +5,8 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.result.Result;
import com.youlai.common.web.exception.BizException;
@ -24,6 +26,7 @@ import com.youlai.mall.oms.service.IOrderItemService;
import com.youlai.mall.oms.service.IOrderService;
import com.youlai.mall.pms.api.app.PmsSkuFeignService;
import com.youlai.mall.pms.pojo.domain.PmsSku;
import com.youlai.mall.pms.pojo.domain.PmsSpu;
import com.youlai.mall.pms.pojo.dto.SkuLockDTO;
import com.youlai.mall.ums.api.UmsAddressFeignService;
import com.youlai.mall.ums.pojo.domain.UmsAddress;
@ -64,7 +67,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
*/
@Override
public OrderConfirmVO confirm(OrderConfirmDTO orderConfirmDTO) {
log.info("=======================订单确认=======================");
log.info("=======================订单确认=======================\n订单确认信息{}",orderConfirmDTO);
OrderConfirmVO orderConfirmVO = new OrderConfirmVO();
Long memberId = RequestUtils.getUserId();
// 获取购买商品信息
@ -112,7 +115,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
}, threadPoolExecutor);
CompletableFuture.allOf(orderItemsCompletableFuture, addressesCompletableFuture, orderTokenCompletableFuture).join();
log.info("获取确认信息",orderConfirmVO.toString());
log.info("订单确认响应:{}", orderConfirmVO.toString());
return orderConfirmVO;
}
@ -122,7 +125,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
@Override
@GlobalTransactional
public OrderSubmitVO submit(OrderSubmitDTO submitDTO) {
log.info("=======================订单提交=======================");
log.info("=======================订单提交=======================\n订单提交信息{}",submitDTO);
// 订单重复提交校验
String orderToken = submitDTO.getOrderToken();
DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>(RELEASE_LOCK_LUA_SCRIPT, Long.class);
@ -134,7 +137,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
List<OrderItemDTO> orderItems = submitDTO.getOrderItems();
if (CollectionUtil.isEmpty(orderItems)) {
throw new BizException("请选择商品再提交");
throw new BizException("订单");
}
// 订单验价
@ -184,23 +187,24 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
.build()).collect(Collectors.toList());
orderItemService.saveBatch(orderItemList);
// 将订单放入延时队列超时未支付系统自动关单
// 将订单放入延时队列超时未支付由交换机order.exchange切换到死信队列完成系统自动关单
rabbitTemplate.convertAndSend("order.exchange", "order.create", orderToken);
OrderSubmitVO submitVO = new OrderSubmitVO();
submitVO.setOrderId(order.getId());
submitVO.setOrderSn(order.getOrderSn());
log.info("订单提交返回结果:{}",submitVO.toString());
log.info("订单提交响应:{}", submitVO.toString());
return submitVO;
}
@Override
public boolean closeOrder(String orderToken) {
log.info("=======================订单关闭订单SN{}=======================", orderToken);
OmsOrder order = this.getOne(new LambdaQueryWrapper<OmsOrder>()
.eq(OmsOrder::getOrderSn, orderToken));
if (!OrderStatusEnum.PENDING_PAYMENT.getCode().equals(order.getStatus())) {
return false;
return false;
}
order.setStatus(OrderStatusEnum.AUTO_CANCEL.getCode());
return this.updateById(order);
@ -208,67 +212,47 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
@Override
public boolean cancelOrder(Long id) {
OmsOrder order = getByOrderId(id);
if (!OrderStatusEnum.PENDING_PAYMENT.getCode().equals(order.getStatus())) {
throw new BizException("取消失败,订单状态不支持取消");
log.info("=======================订单取消订单ID{}=======================", id);
OmsOrder order = this.getById(id);
if ( order != null &&!OrderStatusEnum.PENDING_PAYMENT.getCode().equals(order.getStatus()) ) {
throw new BizException("取消失败,订单状态不支持取消"); // 通过自定义异常将异常信息抛出由异常处理器捕获显示给前端页面
}
order.setStatus(OrderStatusEnum.USER_CANCEL.getCode());
return this.updateById(order);
boolean result = this.updateById(order);
if(result){
// 释放被锁定的库存
Result unlockResult = skuFeignService.unlockStock(order.getOrderSn());
if(!Result.isSuccess(unlockResult)){
throw new BizException(unlockResult.getMsg());
}
result=true;
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteOrder(Long id) {
// 查询订单校验订单状态
OmsOrder order = this.getByOrderId(id);
if (!OrderStatusEnum.AUTO_CANCEL.getCode().equals(order.getStatus()) &&
!OrderStatusEnum.USER_CANCEL.getCode().equals(order.getStatus())) {
throw new BizException("删除失败,订单状态不允许删除");
log.info("=======================订单删除订单ID{}=======================", id);
OmsOrder order = this.getById(id);
if (
order != null &&
!OrderStatusEnum.AUTO_CANCEL.getCode().equals(order.getStatus()) &&
!OrderStatusEnum.USER_CANCEL.getCode().equals(order.getStatus())
) {
throw new BizException("订单删除失败,订单不存在或订单状态不支持删除");
}
return this.removeById(id);
}
@Override
public List<OrderListVO> list(Integer status) {
log.info("订单列表查询status={}", status);
QueryWrapper<OmsOrder> orderQuery = new QueryWrapper<>();
if (status != 0) {
orderQuery.eq("status", status);
}
orderQuery.orderByDesc("id");
List<OmsOrder> orderList = this.list(orderQuery);
if (orderList == null || orderList.size() <= 0) {
log.info("订单列表查询结果为空status={}", status);
return null;
}
List<Long> orderIds = orderList.stream().map(order -> order.getId()).collect(Collectors.toList());
Map<Long, List<OmsOrderItem>> orderItemsMap = orderItemService.getByOrderIds(orderIds);
List<OrderListVO> result = orderList.stream().map(order -> {
OrderListVO orderListVO = BeanMapperUtils.map(order, OrderListVO.class);
orderListVO.setStatusDesc(OrderStatusEnum.getValue(orderListVO.getStatus()).getText());
List<OmsOrderItem> orderItems = orderItemsMap.get(orderListVO.getId());
if (CollectionUtil.isNotEmpty(orderItems)) {
List<OrderListVO.OrderItemBean> orderItemBeans = orderItems.stream()
.map(orderItem -> BeanMapperUtils.map(orderItem, OrderListVO.OrderItemBean.class))
.collect(Collectors.toList());
orderListVO.setOrderItemLIst(orderItemBeans);
}
return orderListVO;
}).collect(Collectors.toList());
return result;
}
@Override
public OmsOrder getByOrderId(Long id) {
Long memberId = RequestUtils.getUserId();
OmsOrder order = this.getOne(new LambdaQueryWrapper<OmsOrder>()
.eq(OmsOrder::getId, id)
.eq(OmsOrder::getMemberId, memberId));
if (order == null) {
throw new BizException("订单不存在订单ID非法");
}
return order;
public IPage<OmsOrder> list(Page<OmsOrder> page, OmsOrder order) {
List<OmsOrder> list = this.baseMapper.list(page, order);
page.setRecords(list);
return page;
}
}

View File

@ -16,7 +16,7 @@ import java.util.List;
* @date 2020-11-06
*/
@Mapper
public interface PmsProductMapper extends BaseMapper<PmsSpu> {
public interface PmsSpuMapper extends BaseMapper<PmsSpu> {
@Select("<script>" +
" SELECT " +

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.mall.pms.mapper.PmsProductMapper;
import com.youlai.mall.pms.mapper.PmsSpuMapper;
import com.youlai.mall.pms.pojo.bo.admin.ProductBO;
import com.youlai.mall.pms.pojo.domain.*;
import com.youlai.mall.pms.pojo.dto.SpuDTO;
@ -26,7 +26,7 @@ import java.util.stream.Collectors;
*/
@Service
@AllArgsConstructor
public class PmsSpuServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> implements IPmsSpuService {
public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> implements IPmsSpuService {
private IPmsSkuService iPmsSkuService;
private IPmsSpuAttributeValueService iPmsSpuAttributeValueService;

View File

@ -5,7 +5,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.mall.pms.mapper.PmsProductMapper;
import com.youlai.mall.pms.mapper.PmsSpuMapper;
import com.youlai.mall.pms.pojo.bo.app.ProductBO;
import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue;
import com.youlai.mall.pms.pojo.domain.PmsSku;
@ -27,7 +27,7 @@ import java.util.List;
*/
@Service
@AllArgsConstructor
public class ProductServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> implements IProductService {
public class ProductServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> implements IProductService {
private IPmsSkuService iPmsSkuService;
private IPmsSpuAttributeValueService iPmsSpuAttributeValueService;

View File

@ -35,7 +35,7 @@ public interface UmsMemberFeignService {
/**
* 扣减会员余额
*/
@PutMapping("/api.app/v1/members/{id}/balance")
@PutMapping("/api.app/v1/members/{id}/deduct_balance")
Result deductBalance(@PathVariable Long id, @RequestParam Long balance);

View File

@ -99,18 +99,4 @@ public class MemberController {
.set(UmsMember::getDeleted, GlobalConstants.DELETED_VALUE));
return Result.judge(status);
}
@ApiOperation(value = "扣减余额")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "用户ID", required = true, paramType = "path", dataType = "Long"),
@ApiImplicitParam(name = "amount", value = "实体JSON对象", required = true, paramType = "body", dataType = "UmsMember")
})
@PatchMapping("/{id}/balance/_deduct")
public Result deductBalance(@PathVariable Long id, @RequestParam Long amount) {
LambdaUpdateWrapper<UmsMember> updateWrapper = new LambdaUpdateWrapper<UmsMember>().eq(UmsMember::getId, id);
updateWrapper.setSql(" balance = balance - " + amount);
updateWrapper.gt(UmsMember::getBalance, amount);
boolean result = iUmsUserService.update(updateWrapper);
return Result.judge(result);
}
}

View File

@ -2,6 +2,7 @@ package com.youlai.mall.ums.controller.app;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import com.youlai.common.web.util.RequestUtils;
@ -96,16 +97,17 @@ public class MemberController {
return Result.judge(result);
}
@ApiOperation(value = "修改会员余额")
@ApiOperation(value = "扣减会员余额")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "会员ID", required = true, paramType = "path", dataType = "Long"),
@ApiImplicitParam(name = "balance", value = "会员余额", required = true, paramType = "query", dataType = "Long")
})
@PutMapping("/{id}/balance")
@PutMapping("/{id}/deduct_balance")
public Result updateBalance(@PathVariable Long id, @RequestParam Long balance) {
UmsMember user = iUmsUserService.getById(id);
user.setBalance(user.getBalance() - balance);
boolean result = iUmsUserService.updateById(user);
boolean result = iUmsUserService.update(new LambdaUpdateWrapper<UmsMember>()
.setSql("balance = balance - " + balance)
.eq(UmsMember::getId, id)
);
return Result.judge(result);
}

View File

@ -38,7 +38,7 @@
<lombok.version>1.18.18</lombok.version>
<hutool.version>5.5.8</hutool.version>
<mysql.version>8.0.19</mysql.version>
<druid.version>1.2.5</druid.version>
<druid.version>1.2.4</druid.version>
<mybatis-plus.version>3.4.2</mybatis-plus.version>
<minio.version>7.1.0</minio.version>
<weixin-java-miniapp.version>4.0.4.B</weixin-java-miniapp.version>

View File

@ -19,7 +19,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -77,7 +77,7 @@ public class Result<T> implements Serializable {
public static boolean isSuccess(Result result) {
if(ResultCode.SUCCESS.getCode().equals(result.getCode())){
if(result!=null&&ResultCode.SUCCESS.getCode().equals(result.getCode())){
return true;
}
return false;

View File

@ -22,9 +22,14 @@
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
</dependencies>
</project>
</project>

View File

@ -1,25 +1,31 @@
package com.youlai.common.mybatis.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.youlai.common.mybatis.handler.FieldFillHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@Slf4j
@EnableTransactionManagement
public class MybatisPlusConfig {
/**
* 分页插件自动识别数据库类型 多租户请参考官网插件扩展
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
/**
* 自动填充数据库创建人创建时间更新人更新时间
*/