|  |  |  | 
|---|
|  |  |  | 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.core.model.ApiResponse; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.service.business.YwBuildingService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:create") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody YwBuilding ywBuilding,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | ywBuilding.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(ywBuildingService.create(ywBuilding)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | ywBuildingService.deleteById(id); | 
|---|
|  |  |  | ywBuildingService.deleteById(id,this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding: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)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ywBuildingService.deleteByIdInBatch(idList); | 
|---|
|  |  |  | ywBuildingService.deleteByIdInBatch(idList,this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:update") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody YwBuilding ywBuilding,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | ywBuilding.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | ywBuildingService.updateById(ywBuilding); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:query") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:query") | 
|---|
|  |  |  | public ApiResponse<PageData<YwBuilding>> findPage (@RequestBody PageWrap<YwBuilding> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(ywBuildingService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("查询列表") | 
|---|
|  |  |  | @PostMapping("/list") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:query") | 
|---|
|  |  |  | public ApiResponse<List<YwBuilding>> findList (@RequestBody  YwBuilding pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | pageWrap.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(ywBuildingService.findList(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:exportExcel") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<YwBuilding> pageWrap, HttpServletResponse response ,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | ExcelExporter.build(YwBuilding.class).export(ywBuildingService.findPage(pageWrap).getRecords(), "运维楼宇信息表", response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:ywbuilding:query") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywbuilding:query") | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(ywBuildingService.findById(id)); | 
|---|
|  |  |  | } | 
|---|