GeneratedArticleDTO.java
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.aigeo.article.dto;
import com.aigeo.article.entity.GeneratedArticle;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.time.LocalDateTime;
/**
* 生成文章DTO
*/
@Data
@Schema(description = "生成文章DTO")
public class GeneratedArticleDTO {
@Schema(description = "文章ID")
private Integer id;
@Schema(description = "任务ID")
private Integer taskId;
@Schema(description = "公司ID")
private Integer companyId;
@Schema(description = "标题")
private String title;
@Schema(description = "内容")
private String content;
@Schema(description = "状态")
private String status;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")
private LocalDateTime updatedAt;
/**
* 将DTO转换为实体类
*/
public GeneratedArticle toEntity() {
GeneratedArticle entity = new GeneratedArticle();
BeanUtils.copyProperties(this, entity);
return entity;
}
/**
* 将实体类转换为DTO
*/
public static GeneratedArticleDTO fromEntity(GeneratedArticle entity) {
GeneratedArticleDTO dto = new GeneratedArticleDTO();
BeanUtils.copyProperties(entity, dto);
return dto;
}
}