feat(修复): 报错,MP枚举类无法识别
This commit is contained in:
parent
a6db5a7600
commit
5d1ac9432b
|
@ -1,5 +1,6 @@
|
|||
package com.atguigu.ssyx.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
|
@ -7,8 +8,10 @@ public enum ActivityType {
|
|||
FULL_REDUCTION(1, "满减"),
|
||||
FULL_DISCOUNT(2, "满量打折");
|
||||
|
||||
private final String comment;
|
||||
@EnumValue
|
||||
private final Integer code;
|
||||
@EnumValue
|
||||
private final String comment;
|
||||
|
||||
ActivityType(Integer code, String comment) {
|
||||
this.code = code;
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -18,41 +19,42 @@ import java.util.Date;
|
|||
*
|
||||
* @author qy
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel(description = "ActivityInfo")
|
||||
@TableName("activity_info")
|
||||
public class ActivityInfo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "活动名称")
|
||||
@TableField("activity_name")
|
||||
private String activityName;
|
||||
|
||||
@ApiModelProperty(value = "活动类型(满减、折扣)")
|
||||
@TableField("activity_type")
|
||||
private ActivityType activityType;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "活动描述")
|
||||
@TableField("activity_desc")
|
||||
private String activityDesc;
|
||||
@ApiModelProperty(value = "活动名称")
|
||||
@TableField("activity_name")
|
||||
private String activityName;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
@TableField("start_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date startTime;
|
||||
@ApiModelProperty(value = "活动类型(满减、折扣)")
|
||||
@TableField("activity_type")
|
||||
private ActivityType activityType;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
@TableField("end_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
@ApiModelProperty(value = "活动描述")
|
||||
@TableField("activity_desc")
|
||||
private String activityDesc;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField("create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
@TableField("start_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date startTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String activityTypeString;
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
@TableField("end_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField("create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String activityTypeString;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,21 +28,10 @@ spring:
|
|||
|
||||
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.atguigu.model # 配置每个包前缀
|
||||
type-enums-package: com.atguigu.ssyx.enums # 加上枚举类型
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
auto-mapping-behavior: full
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||
global-config:
|
||||
db-config:
|
||||
# 设置表名前缀,不用在每个tableName添加前缀
|
||||
# table-prefix: t_
|
||||
# 全局配置主键值方式
|
||||
id-type: assign_id
|
||||
logic-not-delete-value: 0 # 未删除默认为0
|
||||
logic-delete-value: 1 # 删除
|
||||
logic-delete-field: deleted # 全局配置逻辑删除
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.atguigu.ssyx.model.activity.ActivityRule;
|
|||
import com.atguigu.ssyx.model.activity.ActivitySku;
|
||||
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||
import com.atguigu.ssyx.vo.activity.ActivityRuleVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -41,11 +42,12 @@ public class ActivityInfoServiceImpl extends ServiceImpl<ActivityInfoMapper, Act
|
|||
*/
|
||||
@Override
|
||||
public IPage<ActivityInfo> selectPage(Page<ActivityInfo> pageParam) {
|
||||
Page<ActivityInfo> page = page(pageParam);
|
||||
List<ActivityInfo> activityInfoList = page.getRecords();
|
||||
activityInfoList.forEach(activityInfo -> {
|
||||
String comment = activityInfo.getActivityType().getComment();
|
||||
activityInfo.setActivityTypeString(comment);
|
||||
QueryWrapper<ActivityInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
IPage<ActivityInfo> page = baseMapper.selectPage(pageParam, queryWrapper);
|
||||
|
||||
page.getRecords().forEach(item -> {
|
||||
item.setActivityTypeString(item.getActivityType().getComment());
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
@ -120,14 +122,18 @@ public class ActivityInfoServiceImpl extends ServiceImpl<ActivityInfoMapper, Act
|
|||
public List<SkuInfo> findSkuInfoByKeyword(String keyword) {
|
||||
// 根据关键字查询sku匹配内容
|
||||
List<SkuInfo> skuInfoList = productFeignClient.findSkuInfoByKeyword(keyword).getData();
|
||||
List<Long> skuIdList = skuInfoList.stream().map(SkuInfo::getId).collect(Collectors.toList());
|
||||
|
||||
// 判断添加商品之前是否参加过活动
|
||||
List<Long> existSkuIdList = baseMapper.selectSkuIdListExist(skuIdList);
|
||||
// 如果参加的话就剔除
|
||||
skuInfoList.removeIf(skuInfo -> existSkuIdList.contains(skuInfo.getId()));
|
||||
if (!skuInfoList.isEmpty()) {
|
||||
List<Long> skuIdList = skuInfoList.stream().map(SkuInfo::getId).collect(Collectors.toList());
|
||||
|
||||
// 返回结果
|
||||
// 判断添加商品之前是否参加过活动
|
||||
List<Long> existSkuIdList = baseMapper.selectSkuIdListExist(skuIdList);
|
||||
// 如果参加的话就剔除
|
||||
skuInfoList.removeIf(skuInfo -> existSkuIdList.contains(skuInfo.getId()));
|
||||
|
||||
// 返回结果
|
||||
return skuInfoList;
|
||||
}
|
||||
return skuInfoList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,21 +27,11 @@ spring:
|
|||
time-zone: GMT+8
|
||||
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.atguigu.model # 配置每个包前缀
|
||||
type-enums-package: com.atguigu.ssyx.enums # 加上枚举类型
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
auto-mapping-behavior: full
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||
global-config:
|
||||
db-config:
|
||||
# 设置表名前缀,不用在每个tableName添加前缀
|
||||
# table-prefix: t_
|
||||
# 全局配置主键值方式
|
||||
id-type: assign_id
|
||||
logic-not-delete-value: 0 # 未删除默认为0
|
||||
logic-delete-value: 1 # 删除
|
||||
logic-delete-field: deleted # 全局配置逻辑删除
|
||||
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
|
|
@ -3,15 +3,13 @@
|
|||
<mapper namespace="com.atguigu.ssyx.activity.mapper.ActivityInfoMapper">
|
||||
<!-- 判断添加商品之前是否参加过活动 -->
|
||||
<select id="selectSkuIdListExist" resultType="java.lang.Long">
|
||||
select *
|
||||
select sku.sku_id
|
||||
from activity_info info
|
||||
inner join activity_sku sku on info.id = sku.activity_id
|
||||
<if test="skuIdList != null">
|
||||
where sku.sku_id in
|
||||
<foreach collection="skuIdList" item="skuId" open="(" close=")" separator=",">
|
||||
#{skuId}
|
||||
</foreach>
|
||||
</if>
|
||||
where sku.sku_id in
|
||||
<foreach collection="skuIdList" item="skuId" open="(" close=")" separator=",">
|
||||
#{skuId}
|
||||
</foreach>
|
||||
and now() between info.start_time and info.end_time
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -46,21 +46,10 @@ spring:
|
|||
stateless: true # true 无状态 false 有状态。如果业务中包含事务,这里改为false
|
||||
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.atguigu.model # 配置每个包前缀
|
||||
type-enums-package: com.atguigu.ssyx.enums # 加上枚举类型
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
auto-mapping-behavior: full
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||
global-config:
|
||||
db-config:
|
||||
# 设置表名前缀,不用在每个tableName添加前缀
|
||||
# table-prefix: t_
|
||||
# 全局配置主键值方式
|
||||
id-type: assign_id
|
||||
logic-not-delete-value: 0 # 未删除默认为0
|
||||
logic-delete-value: 1 # 删除
|
||||
logic-delete-field: deleted # 全局配置逻辑删除
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
|
|
@ -29,7 +29,8 @@ spring:
|
|||
|
||||
|
||||
mybatis-plus:
|
||||
type-aliases-package: com.atguigu.model # 配置每个包前缀
|
||||
type-enums-package: com.atguigu.ssyx.enums # 加上枚举类型
|
||||
type-aliases-package: com.atguigu.ssyx # 配置每个包前缀
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
|
Loading…
Reference in New Issue