¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.dto.AreasDto; |
| | | import com.doumee.dao.business.model.Areas; |
| | | import com.doumee.service.business.AreasService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | 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 2023/02/15 08:55 |
| | | */ |
| | | @Api(tags = "çå¸åºä¿¡æ¯è¡¨") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/business/areas") |
| | | public class AreasCloudController extends BaseController { |
| | | |
| | | @Autowired |
| | | private AreasService areasService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | | @CloudRequiredPermission("business:areas:create") |
| | | public ApiResponse create(@RequestBody Areas areas,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | areas.setLoginUserInfo(getLoginUser(token)); |
| | | return ApiResponse.success(areasService.create(areas)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDå é¤") |
| | | @GetMapping("/delete/{id}") |
| | | @CloudRequiredPermission("business:areas:delete") |
| | | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | areasService.deleteById(id); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| | | @CloudRequiredPermission("business:areas: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)); |
| | | } |
| | | areasService.deleteByIdInBatch(idList); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDä¿®æ¹") |
| | | @PostMapping("/updateById") |
| | | @CloudRequiredPermission("business:areas:update") |
| | | public ApiResponse updateById(@RequestBody Areas areas,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | areas.setLoginUserInfo(getLoginUser(token)); |
| | | areasService.updateById(areas); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | // @CloudRequiredPermission("business:areas:query") |
| | | public ApiResponse<PageData<Areas>> findPage (@RequestBody PageWrap<Areas> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(areasService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("å
¨é¨æ å½¢æ¥è¯¢") |
| | | @PostMapping("/treeList") |
| | | // @CloudRequiredPermission("business:areas:query") |
| | | public ApiResponse<List<Areas>> treeList (@RequestBody AreasDto pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | Areas a = new Areas(); |
| | | BeanUtils.copyProperties(pageWrap,a); |
| | | return ApiResponse.success(areasService.findList(a)); |
| | | } |
| | | @ApiOperation("æ ¹æ®ç¶èç¹æ¥ä¸") |
| | | @PostMapping("/listByParentId") |
| | | // @CloudRequiredPermission("business:areas:query") |
| | | public ApiResponse<List<Areas>> listByParentId (@RequestBody AreasDto pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | Areas a = new Areas(); |
| | | BeanUtils.copyProperties(pageWrap,a); |
| | | // PageWrap<Areas> wrap = new PageWrap<>(); |
| | | // wrap.setPage(Constants.ONE); |
| | | // wrap.setCapacity(9999); |
| | | // wrap.setModel(a); |
| | | return ApiResponse.success(areasService.listByParentId(a)); |
| | | } |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @CloudRequiredPermission("business:areas:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<Areas> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | ExcelExporter.build(Areas.class).export(areasService.findPage(pageWrap).getRecords(), "çå¸åºä¿¡æ¯è¡¨", response); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/{id}") |
| | | @CloudRequiredPermission("business:areas:query") |
| | | public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(areasService.findById(id)); |
| | | } |
| | | } |