feat(public): 新增更新信息
This commit is contained in:
@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jgy.xxs.core.http.resp.HttpResponse;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
import mjkf.xinke.dev.modular.file.entity.DevFile;
|
||||
import mjkf.xinke.dev.modular.file.service.DevFileService;
|
||||
import mjkf.xinke.main.common.http.FuHttpResponse;
|
||||
@@ -20,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -95,4 +99,46 @@ public class PublicController {
|
||||
var result = devFileService.page(new Page<>(1, 10), query);
|
||||
return FuHttpResponse.Builder().dataResponse(result.getRecords()).build();
|
||||
}
|
||||
|
||||
@Data
|
||||
static public class PublicUpdateInfo implements Serializable {
|
||||
@ApiModelProperty("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@ApiModelProperty("期数")
|
||||
private Integer period;
|
||||
|
||||
public PublicUpdateInfo () {}
|
||||
|
||||
public PublicUpdateInfo (PricePublish lastData) {
|
||||
Integer initialPeriod = 0;
|
||||
var initialDate = LocalDate.of(2000,1,1);
|
||||
|
||||
this.date = lastData.getCreateTime().toLocalDate();
|
||||
Integer months = 0;
|
||||
for (var i = 0; i < 1000;i++) {
|
||||
var date = initialDate.plusMonths(i);
|
||||
if (date.getYear() == this.date.getYear() && date.getMonth() == this.date.getMonth()) {
|
||||
months = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.period = initialPeriod + months;
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("更新信息")
|
||||
@GetMapping("/update-info")
|
||||
public HttpResponse updateInfo () throws Exception {
|
||||
var query = new LambdaQueryWrapper<PricePublish>();
|
||||
query.orderByDesc(PricePublish::getCreateTime);
|
||||
var items = pricePublishService.list();
|
||||
var data = items.get(0);
|
||||
|
||||
var result = new PublicUpdateInfo(data);
|
||||
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -65,6 +65,8 @@ public class PublicTrendResponse {
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String unit;
|
||||
|
||||
static public List<PublicTrendResponse> list(List<PricePublish> data, String region) {
|
||||
var result = data.stream().map(item -> new PublicTrendResponse(item, region)).collect(Collectors.toList());
|
||||
return result;
|
||||
@@ -89,6 +91,7 @@ public class PublicTrendResponse {
|
||||
this.tax = item.getTax();
|
||||
this.status = item.getStatus();
|
||||
this.type = item.getType();
|
||||
this.unit = item.getUnit();
|
||||
|
||||
this.price = item.getRegionPrice(region);
|
||||
}
|
||||
|
Reference in New Issue
Block a user