fix:整理

上级 b611c2b4
package com.kwan.springbootkwan.controller; package com.kwan.springbootkwan.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kwan.springbootkwan.entity.CsdnTripletDayInfo;
import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.entity.Result;
import com.kwan.springbootkwan.entity.dto.CsdnTripletDayInfoDTO;
import com.kwan.springbootkwan.entity.query.CsdnTripletDayInfoQuery;
import com.kwan.springbootkwan.service.CsdnTripletDayInfoService; import com.kwan.springbootkwan.service.CsdnTripletDayInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
/** /**
* 每日三连监控(CsdnTripletDayInfo)表控制层 * 每日三连监控(CsdnTripletDayInfo)表控制层
* *
...@@ -24,5 +35,33 @@ public class CsdnTripletDayInfoController { ...@@ -24,5 +35,33 @@ public class CsdnTripletDayInfoController {
public Result autoReply() { public Result autoReply() {
return Result.ok(csdnTripletDayInfoService.todayInfo()); return Result.ok(csdnTripletDayInfoService.todayInfo());
} }
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@PostMapping("/page")
public Result selectAll(@RequestBody CsdnTripletDayInfoQuery query) {
final Date startDate = query.getStartDate();
final Date endDate = query.getEndDate();
Page<CsdnTripletDayInfo> pageParm = new Page<>();
pageParm.setCurrent(query.getPage());
pageParm.setSize(query.getPageSize());
QueryWrapper<CsdnTripletDayInfo> wrapper = new QueryWrapper<>();
wrapper.eq("is_delete", 0);
if (Objects.nonNull(startDate)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String startFormattedDate = sdf.format(startDate);
wrapper.ge("triplet_date", startFormattedDate);
}
if (Objects.nonNull(endDate)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String endFormattedDate = sdf.format(endDate);
wrapper.le("triplet_date", endFormattedDate);
}
wrapper.orderByDesc("create_time");
return Result.ok(CsdnTripletDayInfoDTO.Converter.INSTANCE.from(this.csdnTripletDayInfoService.page(pageParm, wrapper)));
}
} }
package com.kwan.springbootkwan.entity.dto;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.kwan.springbootkwan.entity.CsdnTripletDayInfo;
import com.kwan.springbootkwan.mapstruct.FromConverter;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
import java.util.Date;
@Data
public class CsdnTripletDayInfoDTO extends Model<CsdnTripletDayInfoDTO> {
//主键id
private Integer id;
//三连日期
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date tripletDate;
//点赞数量
private Integer likeNum;
//收藏数量
private Integer collectNum;
//评论数量
private Integer commentNum;
//创建时间
private Date createTime;
//更新时间
private Date updateTime;
//逻辑删除,0未删除,1已删除
private Integer isDelete;
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface Converter extends FromConverter<CsdnTripletDayInfoDTO, CsdnTripletDayInfo> {
Converter INSTANCE = Mappers.getMapper(Converter.class);
}
}
\ No newline at end of file
package com.kwan.springbootkwan.entity.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.kwan.springbootkwan.entity.BasePage;
import lombok.Data;
import java.util.Date;
@Data
public class CsdnTripletDayInfoQuery extends BasePage {
//主键id
private Integer id;
//开始日期
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startDate;
//结束日期
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endDate;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册