5 changed files with 46 additions and 119 deletions
@ -1,91 +1,78 @@ |
|||||||
package com.cloud.kicc.system.controller; |
package com.cloud.kicc.system.controller; |
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
import cn.hutool.core.util.StrUtil; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
import com.cloud.kicc.common.core.api.R; |
import com.cloud.kicc.common.core.api.R; |
||||||
import com.cloud.kicc.common.core.constant.AppConstants; |
import com.cloud.kicc.common.core.constant.AppConstants; |
||||||
|
import com.cloud.kicc.system.api.entity.Menu; |
||||||
import com.cloud.kicc.system.api.entity.Region; |
import com.cloud.kicc.system.api.entity.Region; |
||||||
import com.cloud.kicc.system.service.RegionService; |
import com.cloud.kicc.system.service.RegionService; |
||||||
import com.cloud.kicc.system.service.UserService; |
|
||||||
import io.swagger.annotations.Api; |
import io.swagger.annotations.Api; |
||||||
import lombok.RequiredArgsConstructor; |
import lombok.RequiredArgsConstructor; |
||||||
import org.springframework.web.bind.annotation.*; |
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
/** |
/** |
||||||
* @Author: TangSheng |
*<p> |
||||||
* @Description: 地址管理 |
* 区域管理 |
||||||
* @Since 1.0 |
*</p> |
||||||
* @Date Created in 10:22 2022/3/21 |
* |
||||||
|
* @Author: entfrm开发团队-王翔 |
||||||
|
* @Date: 2022/7/19 |
||||||
*/ |
*/ |
||||||
@RestController |
@RestController |
||||||
@RequiredArgsConstructor |
@RequiredArgsConstructor |
||||||
@RequestMapping(AppConstants.APP_SYSTEM + "/address") |
@RequestMapping(AppConstants.APP_SYSTEM + "/address") |
||||||
@Api(value = "app", tags = "地址管理模块") |
@Api(value = "app", tags = "地址管理模块") |
||||||
public class RegionController { |
public class RegionController { |
||||||
private final UserService userService; |
|
||||||
private final RegionService regionService; |
private final RegionService regionService; |
||||||
|
|
||||||
/** |
|
||||||
* 新增节点 |
private LambdaQueryWrapper<Region> getQueryWrapper(Region region) { |
||||||
* @param region 节点dto |
return new LambdaQueryWrapper<Region>() |
||||||
* @return |
.like(StrUtil.isNotBlank(region.getName()), Region::getName, region.getName()) |
||||||
*/ |
.eq(StrUtil.isNotBlank(region.getCode()), Region::getCode, region.getCode()) |
||||||
@PostMapping("/add") |
.between(StrUtil.isNotBlank(region.getBeginTime()) && StrUtil.isNotBlank(region.getEndTime()), Region::getCreateTime, region.getBeginTime(), region.getEndTime()) |
||||||
public R add(@RequestBody Region region){ |
.orderByAsc(Region::getSort); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/list") |
||||||
|
public R list(Region region) { |
||||||
|
List<Region> result = regionService.list(getQueryWrapper(region)); |
||||||
|
return R.ok(result, result.size()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/lazyList") |
||||||
|
public R lazyList(String parentId){ |
||||||
|
return R.ok(regionService.lazyList(parentId)); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/{id:\\w+}") |
||||||
|
public R getById(@PathVariable("id") String id) { |
||||||
|
return R.ok(regionService.getById(id)); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/save") |
||||||
|
public R save(@RequestBody Region region){ |
||||||
regionService.save(region); |
regionService.save(region); |
||||||
return R.ok(region); |
return R.ok(region); |
||||||
} |
} |
||||||
|
|
||||||
/** |
|
||||||
* 修改节点 |
|
||||||
* @param region 修改对象 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@PutMapping("/update") |
@PutMapping("/update") |
||||||
public R update(@RequestBody Region region){ |
public R update(@RequestBody Region region){ |
||||||
regionService.updateById(region); |
regionService.updateById(region); |
||||||
return R.ok(region); |
return R.ok(region); |
||||||
} |
} |
||||||
|
|
||||||
/** |
@DeleteMapping("/remove/{id:\\w+}") |
||||||
* 删除地址节点 |
|
||||||
* @param id 节点id |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@DeleteMapping("/remove/{id}") |
|
||||||
public R remove(@PathVariable("id") String id){ |
public R remove(@PathVariable("id") String id){ |
||||||
if(regionService.getMap(Wrappers.<Region>lambdaQuery().eq(Region::getParentId,id))!=null){ |
if (regionService.count(new LambdaQueryWrapper<Region>().eq(Region::getParentId, id)) > 0) { |
||||||
return R.error("存在下级区域,不允许删除"); |
return R.error("存在下级区域,不允许删除"); |
||||||
} |
} |
||||||
regionService.removeById(id); |
regionService.removeById(id); |
||||||
return R.ok(); |
return R.ok(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
|
||||||
* 查询根据id |
|
||||||
* @param id |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@GetMapping("/{id:\\w+}") |
|
||||||
public R getById(@PathVariable("id") String id) { |
|
||||||
return R.ok(regionService.getById(id)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 查询地址列表 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@GetMapping("/list") |
|
||||||
public R list(Region region){ |
|
||||||
return R.ok(regionService.queryList(region)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 查询地址列表 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@GetMapping("/lazyList") |
|
||||||
public R lazyList(String parentId){ |
|
||||||
return R.ok(regionService.lazyList(parentId)); |
|
||||||
} |
|
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue