| | |
| | | package com.ycl.controller.region; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.controller.BaseController; |
| | | import com.ycl.entity.platform.region.SccgRegion; |
| | | import com.ycl.service.platform.region.ISccgRegionService; |
| | | import com.ycl.entity.region.SccgRegion; |
| | | import com.ycl.service.region.ISccgRegionService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | * @since 2022-09-16 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/sccg-region") |
| | | @RequestMapping("/sccg_region") |
| | | @Api(tags = "行政区域") |
| | | public class SccgRegionController extends BaseController { |
| | | |
| | |
| | | List<SccgRegion> treeList = iSccgRegionService.getTree(); |
| | | return CommonResult.success(treeList); |
| | | } |
| | | |
| | | @ApiOperation(value = "添加行政区域") |
| | | @RequestMapping(value = "/addRegion", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public CommonResult addRegion(@Validated @RequestBody SccgRegion sccgRegion) { |
| | | return CommonResult.success(iSccgRegionService.save(sccgRegion)); |
| | | } |
| | | @ApiOperation(value = "获取行政区域分页查询") |
| | | @RequestMapping(value = "/list", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public CommonResult<IPage<SccgRegion>> list(@Validated @RequestBody SccgRegion sccgRegion) { |
| | | return CommonResult.success(iSccgRegionService.list(sccgRegion)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("获取指定行政区域") |
| | | @RequestMapping(value = "/getRegion/{id}", method = RequestMethod.GET) |
| | | @ResponseBody |
| | | public CommonResult<SccgRegion> getMessage(@PathVariable Long id) { |
| | | SccgRegion sccgRegion = iSccgRegionService.getById(id); |
| | | return CommonResult.success(sccgRegion); |
| | | } |
| | | |
| | | @ApiOperation("修改指定行政区域") |
| | | @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public CommonResult update(@PathVariable Long id, @RequestBody SccgRegion sccgRegion) { |
| | | sccgRegion.setId(id); |
| | | boolean success = iSccgRegionService.updateById(sccgRegion); |
| | | if (success) { |
| | | return CommonResult.success(null); |
| | | } |
| | | return CommonResult.failed(); |
| | | } |
| | | |
| | | @ApiOperation("批量删除行政区域") |
| | | @RequestMapping(value = "/delete", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public CommonResult delete(@RequestParam("ids") List<Long> ids) { |
| | | boolean success = iSccgRegionService.removeBatchByIds(ids); |
| | | if (success) { |
| | | return CommonResult.success(null); |
| | | } |
| | | return CommonResult.failed(); |
| | | } |
| | | |
| | | @ApiOperation("获取子类") |
| | | @GetMapping("/getChildren/{parentId}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "parentId",value = "顶级parentId=0") |
| | | }) |
| | | public CommonResult<List<SccgRegion>> getChildren(@PathVariable Long parentId) { |
| | | List<SccgRegion> treeList = iSccgRegionService.getChildren(parentId); |
| | | return CommonResult.success(treeList); |
| | | } |
| | | } |