枚举
public enum CouponStatus {
UNUSED("未使用", 0), USED("已使用", 1), EXPIRED("已过期", 2);
private String name;
private int index;
private CouponStatus(String name, Integer index)
{
this.name = name;
this.index = index;
}
public static String getStatusName(Integer index)
{
for(CouponStatus status : CouponStatus.values()) {
if (status.getIndex() == index) {
return status.getName();
}
}
return null;
}
private String getName()
{
return this.name;
}
private Integer getIndex()
{
return this.index;
}
}
使用
<td th:text="${data.user?.getNickname()}"></td>
<td th:text="${#dates.format(data.startat, 'yyyy-MM-dd HH:mm:ss')}"></td>
<td th:text="${#dates.format(data.endat, 'yyyy-MM-dd HH:mm:ss')}"></td>
<td th:text="${T(com.cardriving.car.utils.constenum.CouponStatus).getStatusName(data.status)}"></td>