New file |
| | |
| | | package com.cl.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; |
| | | import com.cl.common.result.Result; |
| | | import com.cl.pojo.dto.AddDataDTO; |
| | | |
| | | import com.cl.pojo.dto.DataPageDTO; |
| | | import com.cl.pojo.entity.DataEntity; |
| | | |
| | | import com.cl.pojo.vo.DataDetailVO; |
| | | import com.cl.pojo.vo.DataVO; |
| | | import com.cl.pojo.vo.EditDataDTO; |
| | | |
| | | import com.cl.pojo.vo.screen.ScreenVO; |
| | | import com.cl.service.DataService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | @RestController |
| | | @RequestMapping("/data") |
| | | @Slf4j |
| | | @Api(tags = "数据") |
| | | public class DataController { |
| | | |
| | | @Autowired |
| | | private DataService dataService; |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation("数据上报") |
| | | public Result<String> add(@RequestBody @Valid AddDataDTO addDataDTO) { |
| | | dataService.add(addDataDTO); |
| | | return Result.success("上传成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | @PostMapping("/pageList") |
| | | @ApiOperation("用户分页查询") |
| | | public Result<IPage<DataVO>> selectPageUser(@RequestBody @Valid DataPageDTO dataPageDTO){ |
| | | IPage<DataEntity> page = new Page<>(dataPageDTO.getPageNum(), dataPageDTO.getPageSize()); |
| | | IPage<DataVO> iPage=dataService.pageList(page,dataPageDTO.getCountyList(),dataPageDTO.getName()); |
| | | return Result.success(iPage); |
| | | } |
| | | |
| | | /** |
| | | * 列表查看详情(数据回显) 返回两次数据 查询该id和该id上一次数据 同比增加减少 |
| | | */ |
| | | @PostMapping("/detail") |
| | | @ApiOperation("查看详情") |
| | | public Result<DataDetailVO> detail(@RequestParam(value = "id")Integer id) { |
| | | |
| | | return Result.success( dataService.detail(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增回显 |
| | | */ |
| | | @PostMapping("/add/detail") |
| | | @ApiOperation("查看详情(新增回显上一次数据)") |
| | | public Result<DataDetailVO> addDetail(@RequestParam(value = "county" )Integer county) { |
| | | return Result.success( dataService.addDetail(county)); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @PutMapping("/edit") |
| | | @ApiOperation("数据修改") |
| | | public Result<String> edit(@RequestBody @Valid EditDataDTO editDataDTO) { |
| | | dataService.edit(editDataDTO); |
| | | return Result.success("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation("删除数据") |
| | | public Result<String> delete(@PathVariable Integer id) { |
| | | dataService.delete(id); |
| | | return Result.success("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 大屏数据 |
| | | */ |
| | | @PostMapping("/screen") |
| | | @ApiOperation("大屏数据") |
| | | public Result<ScreenVO> screen(@RequestParam(value = "county",required = false)Integer county, |
| | | @RequestParam(value = "year")Integer year) { |
| | | return Result.success( dataService.screen(county==null?0:county,year)); |
| | | } |
| | | /** |
| | | * 补贴总人数 |
| | | */ |
| | | @GetMapping("/getAssistiveDeviceTotal") |
| | | @ApiOperation("补贴总人数") |
| | | public Result<Integer> getAssistiveDeviceTotal(@RequestParam(value = "county",required = false)Integer county,@RequestParam("year") Integer year) { |
| | | |
| | | return Result.success( dataService.getAssistiveDeviceTotal(county==null?0:county,year)); |
| | | } |
| | | |
| | | /** |
| | | * 可选择年份列表 |
| | | */ |
| | | @GetMapping("/getYearList") |
| | | @ApiOperation("可选择年份列表") |
| | | public Result<List<Integer>> getYearList(@RequestParam(value = "county",required = false)Integer county) { |
| | | return Result.success( dataService.getYearList( county)); |
| | | } |
| | | |
| | | |
| | | } |