|
@@ -16,28 +16,29 @@
|
|
|
*/
|
|
*/
|
|
|
package org.springblade.client.corps.controller;
|
|
package org.springblade.client.corps.controller;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
-import javax.validation.Valid;
|
|
|
|
|
-
|
|
|
|
|
|
|
+import org.springblade.client.corps.service.ICorpsTypeService;
|
|
|
import org.springblade.client.entity.CorpsType;
|
|
import org.springblade.client.entity.CorpsType;
|
|
|
|
|
+import org.springblade.client.vo.CorpsTypeVO;
|
|
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
-import org.springblade.client.vo.CorpsTypeVO;
|
|
|
|
|
-import org.springblade.client.corps.service.ICorpsTypeService;
|
|
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -106,12 +107,12 @@ public class CorpsTypeController extends BladeController {
|
|
|
@ApiOperationSupport(order = 5)
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "修改", notes = "传入corpsType")
|
|
@ApiOperation(value = "修改", notes = "传入corpsType")
|
|
|
public R update(@Valid @RequestBody CorpsType corpsType) {
|
|
public R update(@Valid @RequestBody CorpsType corpsType) {
|
|
|
- if (corpsType.getId() == null){
|
|
|
|
|
- return R.fail(500,"请选择要删除的数据");
|
|
|
|
|
|
|
+ if (corpsType.getId() == null) {
|
|
|
|
|
+ return R.fail(500, "请选择要删除的数据");
|
|
|
}
|
|
}
|
|
|
Integer count = corpsTypeService.count(new QueryWrapper<CorpsType>().eq("parent_id", corpsType.getId()).eq("is_deleted", 0));
|
|
Integer count = corpsTypeService.count(new QueryWrapper<CorpsType>().eq("parent_id", corpsType.getId()).eq("is_deleted", 0));
|
|
|
- if (count != null && count>0){
|
|
|
|
|
- return R.fail(500,"存在下级类别不能删除");
|
|
|
|
|
|
|
+ if (count != null && count > 0) {
|
|
|
|
|
+ return R.fail(500, "存在下级类别不能删除");
|
|
|
}
|
|
}
|
|
|
corpsType.setIsDeleted(1);
|
|
corpsType.setIsDeleted(1);
|
|
|
return R.status(corpsTypeService.updateById(corpsType));
|
|
return R.status(corpsTypeService.updateById(corpsType));
|
|
@@ -124,14 +125,14 @@ public class CorpsTypeController extends BladeController {
|
|
|
@ApiOperationSupport(order = 6)
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入corpsType")
|
|
@ApiOperation(value = "新增或修改", notes = "传入corpsType")
|
|
|
public R submit(@Valid @RequestBody CorpsType corpsType) {
|
|
public R submit(@Valid @RequestBody CorpsType corpsType) {
|
|
|
- if (StringUtils.isBlank(corpsType.getTenantId())){
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(corpsType.getTenantId())) {
|
|
|
corpsType.setTenantId(SecureUtil.getTenantId());
|
|
corpsType.setTenantId(SecureUtil.getTenantId());
|
|
|
}
|
|
}
|
|
|
- if (StringUtils.isBlank(corpsType.getCname())){
|
|
|
|
|
- return R.fail(500,"名称不能为空");
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(corpsType.getCname())) {
|
|
|
|
|
+ return R.fail(500, "名称不能为空");
|
|
|
}
|
|
}
|
|
|
- if ("NotUNIQUE".equals(corpsTypeService.selectCorpsTypeCname(corpsType))){
|
|
|
|
|
- return R.fail(500,"名称已存在");
|
|
|
|
|
|
|
+ if ("NotUNIQUE".equals(corpsTypeService.selectCorpsTypeCname(corpsType))) {
|
|
|
|
|
+ return R.fail(500, "名称已存在");
|
|
|
}
|
|
}
|
|
|
return R.status(corpsTypeService.saveMessage(corpsType));
|
|
return R.status(corpsTypeService.saveMessage(corpsType));
|
|
|
}
|
|
}
|
|
@@ -146,6 +147,7 @@ public class CorpsTypeController extends BladeController {
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
return R.status(corpsTypeService.removeByIds(Func.toLongList(ids)));
|
|
return R.status(corpsTypeService.removeByIds(Func.toLongList(ids)));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取客户类别树形结构
|
|
* 获取客户类别树形结构
|
|
|
*
|
|
*
|
|
@@ -154,18 +156,19 @@ public class CorpsTypeController extends BladeController {
|
|
|
@GetMapping("/tree")
|
|
@GetMapping("/tree")
|
|
|
@ApiOperationSupport(order = 7)
|
|
@ApiOperationSupport(order = 7)
|
|
|
@ApiOperation(value = "树形结构", notes = "树形结构")
|
|
@ApiOperation(value = "树形结构", notes = "树形结构")
|
|
|
- public R<List<CorpsTypeVO>> tree(String tenantId, BladeUser bladeUser,String corpType) {
|
|
|
|
|
- List<CorpsTypeVO> tree = corpsTypeService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()),corpType);
|
|
|
|
|
|
|
+ public R<List<CorpsTypeVO>> tree(String tenantId, BladeUser bladeUser, String corpType) {
|
|
|
|
|
+ List<CorpsTypeVO> tree = corpsTypeService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), corpType);
|
|
|
return R.data(tree);
|
|
return R.data(tree);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 懒加载获取部门树形结构
|
|
* 懒加载获取部门树形结构
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/lazy-tree")
|
|
@GetMapping("/lazy-tree")
|
|
|
@ApiOperationSupport(order = 9)
|
|
@ApiOperationSupport(order = 9)
|
|
|
@ApiOperation(value = "懒加载树形结构", notes = "树形结构")
|
|
@ApiOperation(value = "懒加载树形结构", notes = "树形结构")
|
|
|
- public R<List<CorpsTypeVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser,String corpType,String cname) {
|
|
|
|
|
- List<CorpsTypeVO> tree = corpsTypeService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId,corpType,cname);
|
|
|
|
|
|
|
+ public R<List<CorpsTypeVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser, String corpType, String cname) {
|
|
|
|
|
+ List<CorpsTypeVO> tree = corpsTypeService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId, corpType, cname);
|
|
|
return R.data(tree);
|
|
return R.data(tree);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -176,7 +179,11 @@ public class CorpsTypeController extends BladeController {
|
|
|
@ApiOperationSupport(order = 2)
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "分页", notes = "传入corpsType")
|
|
@ApiOperation(value = "分页", notes = "传入corpsType")
|
|
|
public R<List<CorpsType>> list(CorpsType corpsType) {
|
|
public R<List<CorpsType>> list(CorpsType corpsType) {
|
|
|
- List<CorpsType> pages = corpsTypeService.list(Condition.getQueryWrapper(corpsType));
|
|
|
|
|
|
|
+ LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0)
|
|
|
|
|
+ .eq(CorpsType::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
+ .apply("find_in_set(corp_type,'" + corpsType.getCorpType() + "')");
|
|
|
|
|
+ List<CorpsType> pages = corpsTypeService.list(lambdaQueryWrapper);
|
|
|
return R.data(pages);
|
|
return R.data(pages);
|
|
|
}
|
|
}
|
|
|
|
|
|