java:枚举类使用
前言
枚举类使用
代码实现
/** * @Description: 订单状态 枚举 */
public enum OrderStatusEnum {
WAIT_PAY(10, "待付款"),
WAIT_DELIVER(20, "已付款,待发货"),
WAIT_RECEIVE(30, "已发货,待收货"),
SUCCESS(40, "交易成功"),
CLOSE(50, "交易关闭");
public final Integer type;
public final String value;
OrderStatusEnum(Integer type, String value){
this.type = type;
this.value = value;
}
}
代码使用:
@Transactional(propagation = Propagation.REQUIRED)
void doCloseOrder(String orderId) {
OrderStatus close = new OrderStatus();
close.setOrderId(orderId);
close.setOrderStatus(OrderStatusEnum.CLOSE.type);
close.setCloseTime(new Date());
orderStatusMapper.updateByPrimaryKeySelective(close);
}
还没有评论,来说两句吧...