|
@@ -1,9 +1,18 @@
|
|
|
package cn.cslg.permission.service;
|
|
|
|
|
|
+import cn.cslg.permission.common.model.vo.FunctionVO;
|
|
|
+import cn.cslg.permission.domain.Function;
|
|
|
+import cn.cslg.permission.mapper.FunctionMapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author 沈永艺
|
|
|
* @version 1.0
|
|
@@ -13,5 +22,109 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
-public class FunctionService {
|
|
|
+public class FunctionService extends ServiceImpl<FunctionMapper, Function> {
|
|
|
+ public void addFunction(FunctionVO functionVO) {
|
|
|
+ Function function = new Function();
|
|
|
+ function.setFunctionUp(functionVO.getFunction())
|
|
|
+ .setFunctionName(functionVO.getName())
|
|
|
+ .setFunctionCorresponding(functionVO.getSign())
|
|
|
+ .setApplicationId(functionVO.getApply())
|
|
|
+ .setFunctionDescription(functionVO.getDescribe());
|
|
|
+ function.insert();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Object queryPageList(FunctionVO functionVO) {
|
|
|
+ LambdaQueryWrapper<Function> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (functionVO.getSize() == null || functionVO.getCurrent() == null) {
|
|
|
+ LambdaQueryWrapper<Function> lambdaQueryWrapper = new LambdaQueryWrapper();
|
|
|
+
|
|
|
+ queryWrapper.eq(Function::getIsDelete, 0);
|
|
|
+ Function function = new Function();
|
|
|
+
|
|
|
+ List<Function> lst = function.selectList(queryWrapper);
|
|
|
+ List<FunctionVO> voList = new ArrayList<>();
|
|
|
+ for (Function value : lst) {
|
|
|
+ int id;
|
|
|
+ if (value.getFunctionUp() == 0) {
|
|
|
+
|
|
|
+ id = value.getId();
|
|
|
+ LambdaQueryWrapper<Function> functionLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ functionLambdaQueryWrapper.eq(Function::getFunctionUp, id);
|
|
|
+
|
|
|
+ Function function1 = new Function();
|
|
|
+ List<Function> children = function1.selectList(functionLambdaQueryWrapper);
|
|
|
+ List<FunctionVO> children1 = new ArrayList<>();
|
|
|
+ for (Function child : children) {
|
|
|
+ FunctionVO functionVO1 = new FunctionVO();
|
|
|
+ functionVO1.setFunction(child.getFunctionUp())
|
|
|
+ .setName(child.getFunctionName())
|
|
|
+ .setSign(child.getFunctionCorresponding())
|
|
|
+ .setDescribe(child.getFunctionDescription())
|
|
|
+ .setApply(child.getApplicationId())
|
|
|
+ .setId(child.getId());
|
|
|
+ children1.add(functionVO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ FunctionVO functionVO1 = new FunctionVO();
|
|
|
+ functionVO1.setChildren(children1)
|
|
|
+ .setFunction(value.getFunctionUp())
|
|
|
+ .setApply(value.getApplicationId())
|
|
|
+ .setName(value.getFunctionName())
|
|
|
+ .setDescribe(value.getFunctionDescription())
|
|
|
+ .setSign(value.getFunctionCorresponding())
|
|
|
+ .setUpName("测试")
|
|
|
+ .setId(value.getId());
|
|
|
+ voList.add(functionVO1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ } else {
|
|
|
+ queryWrapper.like(Function::getFunctionName, functionVO.getName());
|
|
|
+ queryWrapper.or();
|
|
|
+ queryWrapper.like(Function::getFunctionCorresponding, functionVO.getName());
|
|
|
+ queryWrapper.or();
|
|
|
+ queryWrapper.like(Function::getFunctionDescription, functionVO.getName());
|
|
|
+ queryWrapper.eq(Function::getIsDelete, 0);
|
|
|
+
|
|
|
+ Function function = new Function();
|
|
|
+ List<Function> lst = function.selectList(queryWrapper);
|
|
|
+
|
|
|
+ List<FunctionVO> voList = new ArrayList<>();
|
|
|
+ for (Function value : lst) {
|
|
|
+ int id;
|
|
|
+ if (value.getFunctionUp() == 0) {
|
|
|
+
|
|
|
+ id = value.getId();
|
|
|
+ LambdaQueryWrapper<Function> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(Function::getFunctionUp, id);
|
|
|
+
|
|
|
+ Function function1 = new Function();
|
|
|
+ List<Function> children = function1.selectList(lambdaQueryWrapper);
|
|
|
+ List<FunctionVO> children1 = new ArrayList<>();
|
|
|
+ for (Function child : children) {
|
|
|
+ FunctionVO functionVO1 = new FunctionVO();
|
|
|
+ functionVO1.setFunction(child.getFunctionUp())
|
|
|
+ .setName(child.getFunctionName())
|
|
|
+ .setSign(child.getFunctionCorresponding())
|
|
|
+ .setDescribe(child.getFunctionDescription())
|
|
|
+ .setApply(child.getApplicationId())
|
|
|
+ .setId(child.getId());
|
|
|
+ children1.add(functionVO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ FunctionVO functionVO1 = new FunctionVO();
|
|
|
+ functionVO1.setChildren(children1)
|
|
|
+ .setFunction(value.getFunctionUp())
|
|
|
+ .setApply(value.getApplicationId())
|
|
|
+ .setName(value.getFunctionName())
|
|
|
+ .setDescribe(value.getFunctionDescription())
|
|
|
+ .setSign(value.getFunctionCorresponding())
|
|
|
+ .setUpName("测试")
|
|
|
+ .setId(value.getId());
|
|
|
+ voList.add(functionVO1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|