| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.CloudRequiredPermission; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.service.business.third.model.ApiResponse; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.model.PlatformWaterGas; |
| | | import com.doumee.dao.business.vo.PlatformWaterGasForExcelVO; |
| | | import com.doumee.service.business.PlatformWaterGasService; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2024/08/26 16:22 |
| | | */ |
| | | @Api(tags = "æå°_ç¨æ°´ç¨æ°ä¿¡æ¯è®°å½è¡¨") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/business/platformWaterGas") |
| | | public class PlatformWaterGasCloudController extends BaseController { |
| | | |
| | | @Autowired |
| | | private PlatformWaterGasService platformWaterGasService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | | @CloudRequiredPermission("business:platformwatergas:create") |
| | | public ApiResponse create(@RequestBody PlatformWaterGas platformWaterGas,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | platformWaterGas.setLoginUserInfo(getLoginUser(token)); |
| | | return ApiResponse.success(platformWaterGasService.create(platformWaterGas)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDå é¤") |
| | | @GetMapping("/delete/{id}") |
| | | @CloudRequiredPermission("business:platformwatergas:delete") |
| | | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | platformWaterGasService.deleteById(id,getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| | | @CloudRequiredPermission("business:platformwatergas:delete") |
| | | public ApiResponse deleteByIdInBatch(@RequestParam String ids,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | String [] idArray = ids.split(","); |
| | | List<Integer> idList = new ArrayList<>(); |
| | | for (String id : idArray) { |
| | | idList.add(Integer.valueOf(id)); |
| | | } |
| | | platformWaterGasService.deleteByIdInBatch(idList,getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDä¿®æ¹") |
| | | @PostMapping("/updateById") |
| | | @CloudRequiredPermission("business:platformwatergas:update") |
| | | public ApiResponse updateById(@RequestBody PlatformWaterGas platformWaterGas,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | platformWaterGas.setLoginUserInfo(getLoginUser(token)); |
| | | platformWaterGasService.updateById(platformWaterGas); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @CloudRequiredPermission("business:platformwatergas:query") |
| | | public ApiResponse<PageData<PlatformWaterGas>> findPage (@RequestBody PageWrap<PlatformWaterGas> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(platformWaterGasService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @CloudRequiredPermission("business:platformwatergas:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<PlatformWaterGas> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | List<PlatformWaterGas> waterGasPageData = platformWaterGasService.findPage(pageWrap).getRecords(); |
| | | if(Objects.nonNull(pageWrap.getModel()) |
| | | && Objects.nonNull(pageWrap.getModel().getType()) && !Constants.equalsInteger(pageWrap.getModel().getType(),Constants.TWO)){ |
| | | List<PlatformWaterGasForExcelVO> pageData = new ArrayList<>(); |
| | | for (PlatformWaterGas platformWaterGas:waterGasPageData) { |
| | | PlatformWaterGasForExcelVO platformWaterGasForExcelVO = new PlatformWaterGasForExcelVO(); |
| | | BeanUtils.copyProperties(platformWaterGas,platformWaterGasForExcelVO); |
| | | pageData.add(platformWaterGasForExcelVO); |
| | | } |
| | | String title = "æå°_循ç¯ç箱记å½è¡¨"; |
| | | if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.ZERO)){ |
| | | title = "æå°_ç¨æ°´ä¿¡æ¯è®°å½è¡¨"; |
| | | }else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.ONE)){ |
| | | title = "æå°_ç¨æ°ä¿¡æ¯è®°å½è¡¨"; |
| | | } |
| | | ExcelExporter.build(PlatformWaterGasForExcelVO.class).export(pageData, title, response); |
| | | }else{ |
| | | ExcelExporter.build(PlatformWaterGas.class).export(waterGasPageData, "æå°_æ²¹èä¿¡æ¯è®°å½è¡¨", response); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "æ²¹èä¿¡æ¯å¯¼å
¥") |
| | | @PostMapping("/importExcel") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "file", required = true, paramType = "query", dataType = "file", dataTypeClass = File.class), |
| | | }) |
| | | @CloudRequiredPermission("business:platformwatergas:exportExcel") |
| | | public ApiResponse<String> importExcel (@ApiParam(value = "file") MultipartFile file, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(platformWaterGasService.importBatch(file,this.getLoginUser(token))); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/{id}") |
| | | @CloudRequiredPermission("business:platformwatergas:query") |
| | | public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(platformWaterGasService.findById(id)); |
| | | } |
| | | } |