公告增加类型
This commit is contained in:
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 公告表
|
||||
@@ -14,12 +15,13 @@ import lombok.Data;
|
||||
*/
|
||||
@TableName(value ="announcement")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
public class Announcement implements Serializable {
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
// @TableId
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
@@ -36,6 +38,8 @@ public class Announcement implements Serializable {
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@@ -49,53 +53,4 @@ public class Announcement implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Announcement other = (Announcement) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
|
||||
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
|
||||
result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
|
||||
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", title=").append(title);
|
||||
sb.append(", content=").append(content);
|
||||
sb.append(", state=").append(state);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.sqx.modules.announcement.entity.Announcement;
|
||||
import com.sqx.modules.announcement.service.AnnouncementService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,9 +23,10 @@ public class AppAnnouncementController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Result get() {
|
||||
public Result get(@RequestParam Integer type) {
|
||||
PageHelper.startPage(1,1);
|
||||
List<Announcement> list = announcementService.list(new LambdaQueryWrapper<Announcement>()
|
||||
.eq(Announcement::getType, type)
|
||||
.eq(Announcement::getState, 1)
|
||||
.orderByDesc(Announcement::getCreateTime));
|
||||
return Result.success().put("data", list.isEmpty() ? null : list.get(0));
|
||||
|
||||
@@ -13,4 +13,5 @@ public class AddAnnouncementDTO {
|
||||
private String content;
|
||||
@NotNull
|
||||
private Integer state;
|
||||
private Integer type = 0;
|
||||
}
|
||||
|
||||
@@ -12,4 +12,5 @@ public class UpdateAnnouncementDTO {
|
||||
private String title;
|
||||
private String content;
|
||||
private Integer state;
|
||||
private Integer type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user