fix:解决冲突

This commit is contained in:
hxrui 2021-01-25 11:45:52 +08:00
commit 9372b2135a
41 changed files with 907 additions and 41 deletions

View File

@ -29,6 +29,7 @@
<artifactId>ums-api</artifactId>
<version>${youlai.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,33 @@
package com.youlai.mall.oms.enums;
import lombok.AllArgsConstructor;
import lombok.ToString;
/**
* @author huawei
* @desc
* @email huawei_code@163.com
* @date 2021/1/16
*/
@ToString
@AllArgsConstructor
public enum OrderStatusEnum {
NEED_PAY(101, "待支付"),
USER_CANCEL(102, "用户取消"),
SYS_CANCEL(103, "系统自动取消"),
IS_PAY(201, "已支付"),
APPLY_REFUND(202, "申请退款"),
IS_REFUND(203, "已退款"),
NEED_DELIVER(301, "待发货"),
IS_DELIVER(402, "已发货"),
USER_RECEIVE(501, "用户收货"),
SYS_RECEIVE(502, "系统自动收货"),
FINISH(901, "已完成"),
;
public final Integer code;
public final String desc;
}

View File

@ -0,0 +1,24 @@
package com.youlai.mall.oms.enums;
import lombok.AllArgsConstructor;
import lombok.ToString;
/**
* @author huawei
* @desc 订单来源类型枚举
* @email huawei_code@163.com
* @date 2021/1/16
*/
@ToString
@AllArgsConstructor
public enum OrderTypeEnum {
WEB(0, "PC订单"),
APP(1, "APP订单"),
;
public final Integer code;
public final String desc;
}

View File

@ -1,11 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
@ -22,7 +22,7 @@ public class OrderDeliveryEntity extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
private Long id;
/**
* 订单id

View File

@ -1,11 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
@ -22,7 +22,7 @@ public class OrderEntity extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
private Long id;
/**
* 订单号
@ -51,7 +51,7 @@ public class OrderEntity extends BaseEntity {
/**
* 会员id
*/
private Long userId;
private Long memberId;
/**
* 使用的优惠券
*/

View File

@ -1,12 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* 订单商品信息表
*
@ -21,7 +20,7 @@ public class OrderGoodsEntity extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
private Long id;
/**
* order_id

View File

@ -1,13 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 订单操作历史记录
*
@ -22,7 +20,7 @@ public class OrderLogsEntity extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
private Long id;
/**
* 订单id

View File

@ -1,11 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
@ -22,7 +22,7 @@ public class OrderPayEntity extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
private Long id;
/**
* 订单id

View File

@ -1,13 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 订单配置信息
*
@ -22,7 +20,7 @@ public class OrderSettingEntity extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
private Long id;
/**
* 秒杀订单超时关闭时间()

View File

@ -0,0 +1,18 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
/**
* @author huawei
* @desc 优惠券信息
* @email huawei_code@163.com
* @date 2021/1/13
*/
@Data
public class CouponVO extends BaseVO {
private String title;
private Long price;
}

View File

@ -0,0 +1,7 @@
package com.youlai.mall.oms.pojo.vo;
/**
* 会员收货地址列表
*/
public class MemberAddressVO {
}

View File

@ -0,0 +1,64 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* 订单确认页需要的数据
*/
public class OrderConfirmVO extends BaseVO {
/**
* 商品列表
*/
@Getter
@Setter
private List<OrderItemVO> items;
// 发票信息
// 优惠券信息
@Getter
@Setter
private List<CouponVO> coupons;
// 积分信息
@Getter
@Setter
private Integer integration;
/**
* 订单总额
*/
@Setter
private Long totalPrice;
/**
* 应付价格
*/
@Setter
private Long payPrice;
public Long getTotalPrice() {
Long total = 0L;
if (items != null && items.size() > 0) {
total = items.stream().mapToLong(OrderItemVO::getSubTotal).sum();
}
return total;
}
public Long getPayPrice() {
Long total = 0L;
if (items != null && items.size() > 0) {
total = items.stream().mapToLong(OrderItemVO::getSubTotal).sum();
}
return total;
}
}

View File

@ -0,0 +1,66 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
/**
* 订单商品
*/
@Builder
public class OrderItemVO extends BaseVO {
/**
* 商品id
*/
@Getter
@Setter
private Long skuId;
/**
* 商品图片
*/
@Getter
@Setter
private String skuImg;
/**
* 商品名称
*/
@Getter
@Setter
private String skuName;
/**
* 商品数量
*/
@Getter
@Setter
private Integer number;
/**
* 商品单价
*/
@Getter
@Setter
private Long price;
@Getter
@Setter
private Long coupon = 0L;
/**
* 小计
*/
@Setter
private Long subTotal;
public Long getSubTotal() {
Long total = 0L;
if (price != null && number != null){
total = price * number;
}
return total;
}
}

View File

@ -0,0 +1,24 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
/**
* @author huawei
* @desc 订单创建响应结果VO
* @email huawei_code@163.com
* @date 2021/1/21
*/
@Data
public class OrderSubmitResultVO extends BaseVO {
/**
* 订单id
*/
private Long id;
/**
* 订单号
*/
private String orderSn;
}

View File

@ -0,0 +1,46 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/**
* @author huawei
* @desc 订单提交实体类
* @email huawei_code@163.com
* @date 2021/1/16
*/
@Data
public class OrderSubmitVO extends BaseVO {
/**
* 用户选择地址id
*/
@NotBlank(message = "请选择收货地址")
private String addressId;
/**
* 如果携带skuId则表示该订单通过直接下单方式生成
* 否则从购物车中生成 -- 清空购物车
*/
private String skuId;
/**
* 直接下单时商品数量
*/
private Integer skuNumber;
/**
* 优惠券id
*/
private String couponId;
@Size(max = 500, message = "订单备注长度不能超过500")
private String remark;
private Long payAmount;
}

View File

@ -0,0 +1,29 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity;
import com.youlai.mall.oms.pojo.entity.OrderEntity;
import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity;
import com.youlai.mall.oms.pojo.entity.OrderLogsEntity;
import lombok.Data;
import java.util.List;
/**
* @author huawei
* @desc
* @email huawei_code@163.com
* @date 2021/1/19
*/
@Data
public class OrderVO extends BaseVO {
private OrderEntity orderEntity;
private List<OrderGoodsEntity> orderGoods;
private OrderLogsEntity orderLogsEntity;
private OrderDeliveryEntity orderDeliveryEntity;
}

View File

@ -2,17 +2,28 @@ package com.youlai.mall.pms.api;
import com.youlai.common.core.result.Result;
import com.youlai.mall.pms.pojo.dto.SkuDTO;
import com.youlai.mall.pms.pojo.vo.SkuInfoVO;
import com.youlai.mall.pms.pojo.vo.WareSkuStockVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient("mall-pms")
public interface ProductFeignService {
/**
* 批量获取商品详情
*
* @param skuIds
* @return
*/
@GetMapping("/api.app/v1/sku/infos")
Result<List<SkuInfoVO>> infos(@RequestParam("skuId") List<String> skuIds);
/**
* 获取商品信息
*
* @param id
* @return
*/
@ -25,4 +36,13 @@ public interface ProductFeignService {
@PutMapping("/api.admin/v1/sku/{id}/stock")
Result updateStock(@PathVariable Long id, @RequestParam Integer num);
/**
* 订单下单锁定库存
*
* @param skuStockVO
* @return
*/
@PostMapping("/api.app/v1/sku/stock/lock")
Result lockStock(@RequestBody WareSkuStockVO skuStockVO);
}

View File

@ -0,0 +1,77 @@
package com.youlai.mall.pms.pojo.dto;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
/**
* @author huawei
* @desc
* @email huawei_code@163.com
* @date 2021/1/13
*/
@Data
public class SkuInfoDTO extends BaseVO {
private Long id;
/**
* 商品sku id
*/
private Long skuId;
/**
* 商品sku编号
*/
private String skuCode;
/**
* 商品sku名字
*/
private String skuName;
/**
* 商品sku图片
*/
private String skuPic;
/**
* 商品原始价格
*/
private Long skuOriginPrice;
/**
* 商品sku价格()
*/
private Long skuPrice;
/**
* 商品库存
*/
private Integer stock;
/**
* spu_id
*/
private Long spuId;
/**
* spu_name
*/
private String spuName;
/**
* spu_pic
*/
private String spuPic;
/**
* 品牌id
*/
private Long brandId;
/**
* 品牌名称
*/
private String brandName;
/**
* 商品分类id
*/
private Long categoryId;
/**
* 商品分类名称
*/
private String categoryName;
}

View File

@ -0,0 +1,20 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
/**
* @author huawei
* @desc 订单锁定库存 VO
* @email huawei_code@163.com
* @date 2021/1/16
*/
@Data
public class LockStockResultVO extends BaseVO {
private Long skuId;
private String skuName;
private boolean locked;
}

View File

@ -0,0 +1,66 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
/**
* 订单商品
*/
@Builder
public class OrderItemVO extends BaseVO {
/**
* 商品id
*/
@Getter
@Setter
private Long skuId;
/**
* 商品图片
*/
@Getter
@Setter
private String skuImg;
/**
* 商品名称
*/
@Getter
@Setter
private String skuName;
/**
* 商品数量
*/
@Getter
@Setter
private Integer number;
/**
* 商品单价
*/
@Getter
@Setter
private Long price;
@Getter
@Setter
private Long coupon = 0L;
/**
* 小计
*/
@Setter
private Long subTotal;
public Long getSubTotal() {
Long total = 0L;
if (price != null && number != null){
total = price * number;
}
return total;
}
}

View File

@ -0,0 +1,77 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
/**
* @author huawei
* @desc
* @email huawei_code@163.com
* @date 2021/1/13
*/
@Data
public class SkuInfoVO extends BaseVO {
private Long id;
/**
* 商品sku id
*/
private Long skuId;
/**
* 商品sku编号
*/
private String skuCode;
/**
* 商品sku名字
*/
private String skuName;
/**
* 商品sku图片
*/
private String skuPic;
/**
* 商品原始价格
*/
private Long skuOriginPrice;
/**
* 商品sku价格()
*/
private Long skuPrice;
/**
* 商品库存
*/
private Integer stock;
/**
* spu_id
*/
private Long spuId;
/**
* spu_name
*/
private String spuName;
/**
* spu_pic
*/
private String spuPic;
/**
* 品牌id
*/
private Long brandId;
/**
* 品牌名称
*/
private String brandName;
/**
* 商品分类id
*/
private Long categoryId;
/**
* 商品分类名称
*/
private String categoryName;
}

View File

@ -0,0 +1,18 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
/**
* @author huawei
* @desc 商品库存信息
* @email huawei_code@163.com
* @date 2021/1/21
*/
@Data
public class SkuStockVO extends BaseVO {
private Long skuId;
private Integer number;
}

View File

@ -0,0 +1,18 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import lombok.Data;
import java.util.List;
/**
* @author huawei
* @desc 锁定库存VO
* @email huawei_code@163.com
* @date 2021/1/16
*/
@Data
public class WareSkuStockVO extends BaseVO {
private List<SkuStockVO> items;
}

View File

@ -4,6 +4,7 @@ import com.youlai.common.core.result.Result;
import com.youlai.mall.ums.pojo.UmsUser;
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
import com.youlai.mall.ums.pojo.dto.MemberDTO;
import com.youlai.mall.ums.pojo.dto.UmsAddressDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@ -33,6 +34,15 @@ public interface MemberFeignService {
@PutMapping("/api.admin/v1/users/{id}/point")
Result updatePoint(@PathVariable Long id, @RequestParam Integer num);
/**
* 获取地址详情
*
* @param id 地址id
* @return 地址详情
*/
@GetMapping("/api.app/v1/addresses/{id}")
Result<UmsAddressDTO> getAddressById(@PathVariable("id") String id);
}

View File

@ -25,7 +25,7 @@ public class UmsAddress extends BaseEntity {
private String city;
private String area;
private String area;
private String address;

View File

@ -49,6 +49,7 @@ public class UmsUser {
@TableField(exist = false)
private List<UmsAddress> addressList;
@TableField(exist = false)
private Integer balance;
}

View File

@ -0,0 +1,33 @@
package com.youlai.mall.ums.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@Accessors(chain = true)
public class UmsAddressDTO implements Serializable {
private Long id;
private Long userId;
private String name;
private String mobile;
private String province;
private String city;
private String area;
private String address;
private String zipCode;
private Integer defaulted;
}

View File

@ -19,6 +19,7 @@
<module>mall-ums</module>
<module>mall-pms</module>
<module>mall-oms</module>
<module>common-rabbitmq</module>
</modules>
<parent>
@ -44,6 +45,7 @@
<weixin-java-miniapp.version>3.9.4.B</weixin-java-miniapp.version>
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
<seata.version>1.4.0</seata.version>
</properties>
<dependencies>
@ -123,6 +125,7 @@
<version>${seata.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -37,6 +37,13 @@
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-core</artifactId>
<version>${dozer.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -17,6 +17,8 @@ import java.util.Date;
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间", example = "2020-01-01 00:00:00")
@JsonInclude(value = JsonInclude.Include.NON_NULL)

View File

@ -0,0 +1,19 @@
package com.youlai.common.core.base;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @author huawei
* @desc VO 基类
* @email huawei_code@163.com
* @date 2021/1/11
*/
@Data
@ToString
public class BaseVO implements Serializable {
private static final long serialVersionUID = 1L;
}

View File

@ -1,8 +0,0 @@
package com.youlai.common.core.constant;
public interface RedisKeyConstants {
String YOU_LAI = "youlai:";
String MALL_CART_KEY = YOU_LAI + "cart:";
}

View File

@ -17,7 +17,7 @@ public class MetaHandler implements MetaObjectHandler {
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("gmtCreate", new Date(), metaObject);
this.setFieldValByName("gmtModified", new Date(), metaObject);
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>youlai-common</artifactId>
<groupId>com.youlai</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-rabbitmq</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,92 @@
package com.youlai.common.rabbitmq.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.annotation.PostConstruct;
/**
* @author huawei
* @desc
* @email huawei_code@163.com
* @date 2021/1/17
*/
@Configuration
@EnableTransactionManagement
@Slf4j
public class RabbitMqConfig {
@Autowired
private RabbitTemplate rabbitTemplate;
/**
* 使用json序列化机制进行消息转换
*
* @return
*/
@Bean
public MessageConverter messageConverter() {
return new Jackson2JsonMessageConverter();
}
/**
* 为容器创建号rabbitTemplate注册confirmCallback
* 消息由生产者投递到Broker/Exchange回调
*/
@PostConstruct
public void setExchangeCallback() {
rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {
/**
* @param correlationData 发送消息时指定的唯一关联数据消息id
* @param ack 投递结果
* @param cause 失败原因
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
if (ack) {
log.info("消息投递到交换机成功:[correlationData={}]", correlationData);
} else {
log.error("消息投递到交换机成功:[correlationData={},原因={}]", correlationData, cause);
}
}
});
}
/**
* 注意下面两项必须同时配置可以尝试不配置第二项通过测试能够发现当消息路由到Queue失败(比如路由件错误)returnCallback并未被回调
* # 开启阶段二(消息从E->Q)的确认回调 Exchange --> Queue returnCallback
* spring.rabbitmq.publisher-returns=true
* # 官方文档说此时这一项必须设置为true
* # 实际上这一项的作用是消息未成功到达队列时能监听到到路由不可达的消息以异步方式优先调用我们自己设置的returnCallback默认情况下这个消息会被直接丢弃无法监听到
* spring.rabbitmq.template.mandatory=true
*/
@PostConstruct
public void setQueueCallback() {
rabbitTemplate.setReturnCallback(new RabbitTemplate.ReturnCallback() {
/**
* 这个方法的参数并没有像 confirmCallback 那样提供boolean类型的ack因此这个回调只能在失败情况下触发
* @param message 发送消息
* @param replyCode 回复错误码
* @param replyText 回复错误内容
* @param exchange 发送消息时指定的交换机
* @param routingKey 发送消息时使用的路由件
*/
@Override
public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
log.error("路由到队列失败,[消息内容:{},交换机:{},路由件:{},回复码:{},回复文本:{}]", message, exchange, routingKey, replyCode, replyText);
}
});
}
}

View File

@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.youlai.common.rabbitmq.config.RabbitMqConfig

View File

@ -14,17 +14,8 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
// RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
// redisTemplate.setKeySerializer(new StringRedisSerializer());
// redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
// redisTemplate.setHashKeySerializer(new StringRedisSerializer());
// redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
// redisTemplate.setConnectionFactory(factory);
// redisTemplate.afterPropertiesSet();
// return redisTemplate;
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(factory);

View File

@ -0,0 +1,12 @@
package com.youlai.common.redis.constant;
public interface RedisKeyConstants {
Long REDIS_KEY_TIME_OUT = 3600 * 24L;
String YOU_LAI = "youlai:";
String MALL_CART_KEY = YOU_LAI + "cart:";
String TOKEN_VERIFY ="token_verify:";
}

View File

@ -22,11 +22,25 @@
<version>${youlai.version}</version>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-redis</artifactId>
<version>${youlai.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-core</artifactId>
<version>6.2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,55 @@
package com.youlai.common.web.util;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class BeanMapperUtils {
private static Mapper mapper;
static {
mapper = DozerBeanMapperBuilder.buildDefault();
}
public static <S, D> D map(S source, Class<D> destinationClass) {
if (source == null) {
return null;
}
return mapper.map(source, destinationClass);
}
public static <S, D> void copy(S source, D dest) {
if (source == null) {
return;
}
mapper.map(source, dest);
}
public static <S, D> List<D> mapList(final List<S> source, final Class<D> destType) {
final List<D> dest = new ArrayList<D>();
if (source == null || source.size() == 0) {
return dest;
}
for (S element : source) {
dest.add(mapper.map(element, destType));
}
return dest;
}
public static <S, D> Collection<D> mapCollection(final Collection<S> source, final Class<D> destType) {
final Collection<D> dest = new ArrayList<>();
if (source == null || source.size() == 0) {
return dest;
}
for (S element : source) {
dest.add(mapper.map(element, destType));
}
return dest;
}
}

View File

@ -19,6 +19,7 @@
<module>common-redis</module>
<module>common-web</module>
<module>common-mybatis</module>
<module>common-rabbitmq</module>
</modules>
<properties>
@ -31,6 +32,7 @@
<redisson.version>3.12.5</redisson.version>
<common-pools.version>2.8.0</common-pools.version>
<youlai.version>1.0.0-SNAPSHOT</youlai.version>
<dozer.version>6.2.0</dozer.version>
</properties>
<dependencyManagement>
@ -122,6 +124,13 @@
<version>${youlai.version}</version>
</dependency>
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-core</artifactId>
<version>${dozer.version}</version>
</dependency>
</dependencies>
</dependencyManagement>