修改响应的Tag的articles字段类型

This commit is contained in:
小海
2020-03-29 14:16:17 +08:00
parent 8181fab48d
commit ebddbc0ecf
5 changed files with 86 additions and 32 deletions

View File

@@ -0,0 +1,41 @@
package cn.celess.blog.entity.model;
import cn.celess.blog.entity.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: 小海
* @Date: 2020-03-29 13:56
* @Desc:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TagModel {
private Long id;
private String name;
private List<Integer> articles;
public TagModel(Tag tag) {
this.id = tag.getId();
this.name = tag.getName();
if (tag.getArticles() == null || tag.getArticles().length() == 0) {
articles = null;
} else {
articles = new ArrayList<>();
for (String s : tag.getArticles().split(",")) {
if ("".equals(s)) {
return;
}
articles.add(Integer.parseInt(s));
}
}
}
}