资源的状态加入枚举

This commit is contained in:
wangliwen 2022-05-10 09:57:18 +08:00
parent 6e5d988f16
commit dedb813021
2 changed files with 74 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package io.renren.modules.resource.dto;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -8,13 +9,14 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* 资源表
*
* @author dg
* @since 1.0 2022-04-13
*/
* 资源表
*
* @author dg
* @since 1.0 2022-04-13
*/
@Data
@ApiModel(value = "资源表")
public class ResourceDTO implements Serializable {
@ -54,6 +56,8 @@ public class ResourceDTO implements Serializable {
private Long visits;
@ApiModelProperty(value = "删除标志0:正常1:已删除2:待审核3:审核中9其他")
private Integer delFlag;
@ApiModelProperty(value = "删除标志tip0:正常1:已删除2:待审核3:审核中9其他")
private String delFlagTip;
@ApiModelProperty(value = "创建人")
private Long creator;
@ApiModelProperty(value = "创建时间")
@ -93,4 +97,18 @@ public class ResourceDTO implements Serializable {
@ApiModelProperty(value = "附件")
private String enclosure;
public String getDelFlagTip() {
if (this.delFlag != null) {
Optional<ResourceEntityDelFlag> resourceEntityDelFlagOptional = Optional.of(ResourceEntityDelFlag.getByFlag(this.delFlag));
if (resourceEntityDelFlagOptional.isPresent()) {
return resourceEntityDelFlagOptional.get().getTip();
}
return delFlagTip;
}
return delFlagTip;
}
public void setDelFlagTip(String delFlagTip) {
this.delFlagTip = delFlagTip;
}
}

View File

@ -0,0 +1,51 @@
package io.renren.modules.resource.entity;
import java.util.Arrays;
/**
* ResourceEntity del_flag 枚举
*/
public enum ResourceEntityDelFlag {
NORMAL(0, "正常"),
DELETED(1, "已删除"),
PENDING_REVIEW(2, "上架待审核"),
UNDER_REVIEW(3, "上架审核中"),
UNDERCARRIAGE_REVIEW(4, "下架审核中"),
UNDERCARRIAGE(5, "已下架"),
OTHER(9, "其他");
private int flag;
private String tip;
ResourceEntityDelFlag(int flag, String tip) {
this.flag = flag;
this.tip = tip;
}
public static ResourceEntityDelFlag getByFlag(int flag) {
if (flag < 1 || flag > ResourceEntityDelFlag.values().length) {
return null;
}
ResourceEntityDelFlag[] index = ResourceEntityDelFlag.values();
return Arrays.asList(index).stream().filter(index_ -> index_.flag == flag).findAny().orElse(null);
}
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
}