Commit a1049165 by 吕明尚

增加枚举类

parent 88e5bd71
......@@ -82,11 +82,12 @@ public class SConsumerCouponController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SConsumerCoupon sConsumerCoupon)
{
if (StringUtils.isNotBlank(sConsumerCoupon.getRoomType())){
sConsumerCoupon.setRoomType(String.valueOf(RoomType.getCodeList()));
if (StringUtils.isBlank(sConsumerCoupon.getRoomType())) {
sConsumerCoupon.setRoomType(RoomType.getCodeList());
}
if (StringUtils.isNotBlank(sConsumerCoupon.getStoreType())){
sConsumerCoupon.setStoreType(String.valueOf(StoreType.getCodeList()));
if (StringUtils.isBlank(sConsumerCoupon.getStoreType())) {
sConsumerCoupon.setStoreType(StoreType.getCodeList());
}
return toAjax(sConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon));
}
......
......@@ -81,11 +81,11 @@ public class SCouponController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SCoupon sCoupon)
{
if (StringUtils.isNotBlank(sCoupon.getRoomType())){
sCoupon.setRoomType(String.valueOf(RoomType.getCodeList()));
if (StringUtils.isBlank(sCoupon.getRoomType())) {
sCoupon.setRoomType(RoomType.getCodeList());
}
if (StringUtils.isNotBlank(sCoupon.getStoreType())){
sCoupon.setStoreType(String.valueOf(StoreType.getCodeList()));
if (StringUtils.isBlank(sCoupon.getStoreType())) {
sCoupon.setStoreType(StoreType.getCodeList());
}
return toAjax(sCouponService.insertSCoupon(sCoupon));
}
......
......@@ -21,8 +21,11 @@ public enum RoomType {
this.code = code;
this.name = name;
}
public static List<String> getCodeList() {
return Arrays.stream(RoomType.values()).map(RoomType::getCode).collect(Collectors.toList());
//code转1,2,3,4
public static String getCodeList() {
List<String> list = Arrays.stream(StoreType.values()).map(StoreType::getCode).collect(Collectors.toList());
return String.join(",", list);
}
......
......@@ -18,12 +18,12 @@ public enum StoreType {
this.code = code;
this.name = name;
}
public static List<String> getCodeList() {
return Arrays.stream(StoreType.values()).map(StoreType::getCode).collect(Collectors.toList());
}
//code转字符串1,2,3,4
public static String getCodeList() {
List<String> list = Arrays.stream(StoreType.values()).map(StoreType::getCode).collect(Collectors.toList());
return String.join(",", list);
}
public String getCode() {
return code;
}
......
package share.common.enums;
public enum UserStatusEnum {
/**
* (0:待使用,1:已使用,2:已失效)
*/
UNUSED(0, "待使用"),
USED(1, "已使用"),
EXPIRED(2, "已失效");
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
UserStatusEnum() {
}
UserStatusEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
}
......@@ -81,11 +81,11 @@ public class SCouponController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SCoupon sCoupon)
{
if (StringUtils.isNotBlank(sCoupon.getRoomType())){
sCoupon.setRoomType(String.valueOf(RoomType.getCodeList()));
if (StringUtils.isBlank(sCoupon.getRoomType())) {
sCoupon.setRoomType(RoomType.getCodeList());
}
if (StringUtils.isNotBlank(sCoupon.getStoreType())){
sCoupon.setStoreType(String.valueOf(StoreType.getCodeList()));
if (StringUtils.isBlank(sCoupon.getStoreType())) {
sCoupon.setStoreType(StoreType.getCodeList());
}
return toAjax(sCouponService.insertSCoupon(sCoupon));
}
......
......@@ -80,6 +80,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
@Override
public int insertSConsumerCoupon(SConsumerCoupon sConsumerCoupon) {
sConsumerCoupon.setCreateTime(DateUtils.getNowDate());
sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode());
return sConsumerCouponMapper.insertSConsumerCoupon(sConsumerCoupon);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment