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