| package com.doumee.api.business; | 
|   | 
| import com.doumee.api.BaseController; | 
| import com.doumee.core.annotation.excel.ExcelExporter; | 
| import com.doumee.core.annotation.pr.PreventRepeat; | 
| import com.doumee.core.model.ApiResponse; | 
| import com.doumee.core.model.PageWrap; | 
| import com.doumee.core.model.PageData; | 
| import com.doumee.dao.business.model.Contract; | 
| import com.doumee.service.business.ContractService; | 
| 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.*; | 
| import javax.servlet.http.HttpServletResponse; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| /** | 
|  * @author 江蹄蹄 | 
|  * @date 2024/10/28 19:16 | 
|  */ | 
| @Api(tags = "合同信息表") | 
| @RestController | 
| @RequestMapping("/business/contract") | 
| public class ContractController extends BaseController { | 
|   | 
|     @Autowired | 
|     private ContractService contractService; | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
|     @RequiresPermissions("business:contract:create") | 
|     public ApiResponse create(@RequestBody Contract contract) { | 
|         return ApiResponse.success(contractService.create(contract)); | 
|     } | 
|   | 
|     @ApiOperation("根据ID删除") | 
|     @GetMapping("/delete/{id}") | 
|     @RequiresPermissions("business:contract:delete") | 
|     public ApiResponse deleteById(@PathVariable Integer id) { | 
|         contractService.deleteById(id); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @GetMapping("/delete/batch") | 
|     @RequiresPermissions("business:contract:delete") | 
|     public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|         String [] idArray = ids.split(","); | 
|         List<Integer> idList = new ArrayList<>(); | 
|         for (String id : idArray) { | 
|             idList.add(Integer.valueOf(id)); | 
|         } | 
|         contractService.deleteByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("根据ID修改") | 
|     @PostMapping("/updateById") | 
|     @RequiresPermissions("business:contract:update") | 
|     public ApiResponse updateById(@RequestBody Contract contract) { | 
|         contractService.updateById(contract); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("分页查询") | 
|     @PostMapping("/page") | 
|     @RequiresPermissions("business:contract:query") | 
|     public ApiResponse<PageData<Contract>> findPage (@RequestBody PageWrap<Contract> pageWrap) { | 
|         return ApiResponse.success(contractService.findPage(pageWrap)); | 
|     } | 
|   | 
|     @ApiOperation("导出Excel") | 
|     @PostMapping("/exportExcel") | 
|     @RequiresPermissions("business:contract:exportExcel") | 
|     public void exportExcel (@RequestBody PageWrap<Contract> pageWrap, HttpServletResponse response) { | 
|         ExcelExporter.build(Contract.class).export(contractService.findPage(pageWrap).getRecords(), "合同信息表", response); | 
|     } | 
|   | 
|     @ApiOperation("根据ID查询") | 
|     @GetMapping("/{id}") | 
|     @RequiresPermissions("business:contract:query") | 
|     public ApiResponse findById(@PathVariable Integer id) { | 
|         return ApiResponse.success(contractService.findById(id)); | 
|     } | 
| } |