|  |  |  | 
|---|
|  |  |  | 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.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.DispatchUnitQueryDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.SaveDispatchUnitDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.model.DispatchUnit; | 
|---|
|  |  |  | import com.doumee.service.business.DispatchUnitService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody DispatchUnit dispatchUnit) { | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.create(dispatchUnit)); | 
|---|
|  |  |  | public ApiResponse create(@RequestBody SaveDispatchUnitDTO saveDispatchUnitDTO) { | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.create(saveDispatchUnitDTO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("添加方案工种") | 
|---|
|  |  |  | @PostMapping("/createSolution") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:create") | 
|---|
|  |  |  | public ApiResponse createSolution(@RequestBody SaveDispatchUnitDTO saveDispatchUnitDTO) { | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.createSolution(saveDispatchUnitDTO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("修改信息") | 
|---|
|  |  |  | @PostMapping("/editDispatchUnit") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:update") | 
|---|
|  |  |  | public ApiResponse editDispatchUnit(@RequestBody SaveDispatchUnitDTO saveDispatchUnitDTO) { | 
|---|
|  |  |  | dispatchUnitService.editDispatchUnit(saveDispatchUnitDTO); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:query") | 
|---|
|  |  |  | public ApiResponse<PageData<DispatchUnit>> findPage (@RequestBody PageWrap<DispatchUnit> pageWrap) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | pageWrap.getModel().setCompanyId(user.getCompanyId()); | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<DispatchUnit> pageWrap, HttpServletResponse response) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | pageWrap.getModel().setCompanyId(user.getCompanyId()); | 
|---|
|  |  |  | ExcelExporter.build(DispatchUnit.class).export(dispatchUnitService.findPage(pageWrap).getRecords(), "派遣单位信息表", response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:query") | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id) { | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.findById(id)); | 
|---|
|  |  |  | public ApiResponse<DispatchUnit> findById(@PathVariable Integer id) { | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.detailById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("数据列表") | 
|---|
|  |  |  | @PostMapping("/findListByDTO") | 
|---|
|  |  |  | @RequiresPermissions("business:dispatchunit:query") | 
|---|
|  |  |  | public ApiResponse<List<DispatchUnit>> findListByDTO (@RequestBody DispatchUnitQueryDTO dispatchUnitQueryDTO) { | 
|---|
|  |  |  | return ApiResponse.success(dispatchUnitService.findByDTO(dispatchUnitQueryDTO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|