1.add journal state=1 filter for app use

main
Gary 11 months ago
parent 3cd895c130
commit b7d6e25126

@ -0,0 +1,38 @@
package enums;
public enum JournalStatusEnum {
DISABLE("0", "停用"),
ENABLE("1", "启用");
private String status;
private String desc;
JournalStatusEnum(String status, String desc) {
this.status = status;
this.desc = desc;
}
public static JournalStatusEnum getByStatus(String status) {
for (JournalStatusEnum item : JournalStatusEnum.values()) {
if (item.getStatus().equals(status)) {
return item;
}
}
return null;
}
public String getStatus() {
return status;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

@ -75,11 +75,13 @@ public class JournalMapper {
Poem poem = RandomSource.languageSource().randomTangPoem();
journalRespDTO.setEditor(poem.getAuthor());
journalRespDTO.setContent(Arrays.stream(poem.getContent()).collect(Collectors.joining("\r\n")));
journalRespDTO.setSummary(journalRespDTO.getContent());
} else {
journalRespDTO.setContent(content);
journalRespDTO.setSummary(journal.getSummary());
journalRespDTO.setEditor(getEditor(journal.getUserName()));
}
return journalRespDTO;
}
public static JournalRespDTO getJournalRespDTO(Journal journal, Set<String> journalCollectSet,

@ -20,6 +20,8 @@ public class JournalRespDTO implements Serializable {
private String image;
@ApiModelProperty(value = "期刊标签")
private List<String> tags;
@ApiModelProperty(value = "概要")
private String summary;
@ApiModelProperty(value = "文案")
private String content;
@ApiModelProperty(value = "编辑人")

@ -10,6 +10,7 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import api.Result;
import enums.JournalStatusEnum;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
@ -186,6 +187,8 @@ public class JournalService {
journalNoRange.getRight()));
}
predicateList.add(criteriaBuilder.equal(root.get("state").as(String.class), JournalStatusEnum.ENABLE.getStatus()));
query.orderBy(criteriaBuilder.desc(root.get("journalNo").as(Integer.class)));
return criteriaBuilder.and( predicateList.toArray(new Predicate[predicateList.size()]));
}

Loading…
Cancel
Save