|  |  |  | 
|---|
|  |  |  | 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.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.model.PlatformBooks; | 
|---|
|  |  |  | import com.doumee.dao.business.model.PlatformReason; | 
|---|
|  |  |  | import com.doumee.dao.web.reqeust.PlatformBooksApplyDTO; | 
|---|
|  |  |  | import com.doumee.dao.web.reqeust.PlatformBooksCheckNumDTO; | 
|---|
|  |  |  | import com.doumee.dao.web.response.DriverHomeVO; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformBooksService; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformReasonService; | 
|---|
|  |  |  | 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.math.BigDecimal; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformBooksService platformBooksService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformReasonService platformReasonService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:create") | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody PlatformBooks platformBooks) { | 
|---|
|  |  |  | return ApiResponse.success(platformBooksService.create(platformBooks)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id) { | 
|---|
|  |  |  | platformBooksService.deleteById(id); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:delete") | 
|---|
|  |  |  | public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|---|
|  |  |  | String [] idArray = ids.split(","); | 
|---|
|  |  |  | List<Integer> idList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:update") | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody PlatformBooks platformBooks) { | 
|---|
|  |  |  | platformBooksService.updateById(platformBooks); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:query") | 
|---|
|  |  |  | public ApiResponse<PageData<PlatformBooks>> findPage (@RequestBody PageWrap<PlatformBooks> pageWrap) { | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:query") | 
|---|
|  |  |  | public ApiResponse<PageData<PlatformBooks>> findPage (@RequestBody PageWrap<PlatformBooks> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(platformBooksService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:exportExcel") | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<PlatformBooks> pageWrap, HttpServletResponse response) { | 
|---|
|  |  |  | ExcelExporter.build(PlatformBooks.class).export(platformBooksService.findPage(pageWrap).getRecords(), "月台入园预约信息表", response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:platformbooks:query") | 
|---|
|  |  |  | @CloudRequiredPermission("business:platformbooks:query") | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id) { | 
|---|
|  |  |  | return ApiResponse.success(platformBooksService.findById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("入园原因") | 
|---|
|  |  |  | @GetMapping("/platformReasonList") | 
|---|
|  |  |  | public ApiResponse<List<PlatformReason>> platformReasonList (@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | List<PlatformReason> platformReasons = platformReasonService.findList(null); | 
|---|
|  |  |  | return ApiResponse.success(platformReasons); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("查询可预约量") | 
|---|
|  |  |  | @PostMapping("/checkSurplusNum") | 
|---|
|  |  |  | public ApiResponse<BigDecimal> checkSurplusNum (@RequestBody PlatformBooksCheckNumDTO platformBooksCheckNumDTO , @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(platformBooksService.checkNum(platformBooksCheckNumDTO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("物流车预约") | 
|---|
|  |  |  | @PostMapping("/apply") | 
|---|
|  |  |  | public ApiResponse<Integer> apply (@RequestBody PlatformBooksApplyDTO platformBooksApplyDTO , @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = getLoginUser(token); | 
|---|
|  |  |  | platformBooksApplyDTO.setUserId(loginUserInfo.getMemberId()); | 
|---|
|  |  |  | platformBooksApplyDTO.setDriverId(loginUserInfo.getMemberId()); | 
|---|
|  |  |  | return ApiResponse.success(platformBooksService.apply(platformBooksApplyDTO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("物流车预约详情") | 
|---|
|  |  |  | @GetMapping("/getDetail") | 
|---|
|  |  |  | public ApiResponse<PlatformBooks> getDetail (@RequestParam Integer id, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | PlatformBooks platformBooks = platformBooksService.getDetail(id,getLoginUser(token).getMemberId()); | 
|---|
|  |  |  | return ApiResponse.success(platformBooks); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|