接口调整
This commit is contained in:
@@ -6,6 +6,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.user.pojo.po.Function;
|
||||||
|
import com.njcn.user.pojo.vo.FunctionVO;
|
||||||
import com.njcn.user.service.IRoleFunctionService;
|
import com.njcn.user.service.IRoleFunctionService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -42,10 +44,10 @@ public class RoleFunctionController extends BaseController {
|
|||||||
@PostMapping("/getFunctionsByRoleIndex")
|
@PostMapping("/getFunctionsByRoleIndex")
|
||||||
@ApiOperation("根据角色id查询相关联的资源")
|
@ApiOperation("根据角色id查询相关联的资源")
|
||||||
@ApiImplicitParam(name = "id", value = "角色id", required = true)
|
@ApiImplicitParam(name = "id", value = "角色id", required = true)
|
||||||
public HttpResult<List<String>> getFunctionsByRoleIndex(@RequestParam("id") String id) {
|
public HttpResult<List<FunctionVO>> getFunctionsByRoleIndex(@RequestParam("id") String id) {
|
||||||
String methodDescribe = getMethodDescribe("getFunctionsByRoleIndex");
|
String methodDescribe = getMethodDescribe("getFunctionsByRoleIndex");
|
||||||
LogUtil.njcnDebug(log, "{},传入的角色id:{}", methodDescribe,id);
|
LogUtil.njcnDebug(log, "{},传入的角色id:{}", methodDescribe,id);
|
||||||
List<String> list = roleFunctionService.getFunctionsByRoleIndex(id);
|
List<FunctionVO> list = roleFunctionService.getFunctionsByRoleIndex(id);
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, list, methodDescribe);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ public interface FunctionMapper extends BaseMapper<Function> {
|
|||||||
|
|
||||||
List<FunctionVO> getUserFunctionsByList(@Param("list")List<String> functionList);
|
List<FunctionVO> getUserFunctionsByList(@Param("list")List<String> functionList);
|
||||||
|
|
||||||
|
List<FunctionVO> getByList(@Param("list")List<String> functionList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,4 +60,24 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getByList" resultType="FunctionVO">
|
||||||
|
SELECT
|
||||||
|
Id,Pid,
|
||||||
|
`Name` title,
|
||||||
|
`Code`,
|
||||||
|
Path routePath,
|
||||||
|
Icon,Sort,
|
||||||
|
Type,
|
||||||
|
Remark,
|
||||||
|
Route_Name routeName
|
||||||
|
FROM
|
||||||
|
sys_function
|
||||||
|
WHERE
|
||||||
|
STATE = 1 AND
|
||||||
|
Id in
|
||||||
|
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -113,4 +113,10 @@ public interface IFunctionService extends IService<Function> {
|
|||||||
*/
|
*/
|
||||||
List<FunctionVO> getUserFunctionTree();
|
List<FunctionVO> getUserFunctionTree();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单集合获取数据
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
List<Function> getFunctionByList(List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.njcn.user.service;
|
package com.njcn.user.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.user.pojo.po.Function;
|
||||||
import com.njcn.user.pojo.po.RoleFunction;
|
import com.njcn.user.pojo.po.RoleFunction;
|
||||||
|
import com.njcn.user.pojo.vo.FunctionVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ import java.util.List;
|
|||||||
* @since 2021-12-13
|
* @since 2021-12-13
|
||||||
*/
|
*/
|
||||||
public interface IRoleFunctionService extends IService<RoleFunction> {
|
public interface IRoleFunctionService extends IService<RoleFunction> {
|
||||||
List<String> getFunctionsByRoleIndex(String id);
|
List<FunctionVO> getFunctionsByRoleIndex(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述: 根据角色集合获取菜单方法
|
* 功能描述: 根据角色集合获取菜单方法
|
||||||
|
|||||||
@@ -236,6 +236,11 @@ public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> i
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Function> getFunctionByList(List<String> list) {
|
||||||
|
return this.lambdaQuery().in(Function::getId,list).list();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色删除资源
|
* 根据角色删除资源
|
||||||
* @param roleIndex
|
* @param roleIndex
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
package com.njcn.user.service.impl;
|
package com.njcn.user.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.user.mapper.FunctionMapper;
|
||||||
import com.njcn.user.mapper.RoleFunctionMapper;
|
import com.njcn.user.mapper.RoleFunctionMapper;
|
||||||
|
import com.njcn.user.pojo.po.Function;
|
||||||
import com.njcn.user.pojo.po.RoleFunction;
|
import com.njcn.user.pojo.po.RoleFunction;
|
||||||
|
import com.njcn.user.pojo.vo.FunctionVO;
|
||||||
|
import com.njcn.user.service.IFunctionService;
|
||||||
import com.njcn.user.service.IRoleFunctionService;
|
import com.njcn.user.service.IRoleFunctionService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -20,15 +26,22 @@ import java.util.stream.Collectors;
|
|||||||
* @since 2021-12-13
|
* @since 2021-12-13
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
public class RoleFunctionServiceImpl extends ServiceImpl<RoleFunctionMapper, RoleFunction> implements IRoleFunctionService {
|
public class RoleFunctionServiceImpl extends ServiceImpl<RoleFunctionMapper, RoleFunction> implements IRoleFunctionService {
|
||||||
|
|
||||||
|
private final FunctionMapper functionMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getFunctionsByRoleIndex(String id) {
|
public List<FunctionVO> getFunctionsByRoleIndex(String id) {
|
||||||
|
List<FunctionVO> result = new ArrayList<>();
|
||||||
List<String> functionList = new ArrayList<>();
|
List<String> functionList = new ArrayList<>();
|
||||||
QueryWrapper<RoleFunction> componentQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<RoleFunction> componentQueryWrapper = new QueryWrapper<>();
|
||||||
componentQueryWrapper.eq("sys_role_function.role_id",id);
|
componentQueryWrapper.eq("sys_role_function.role_id",id);
|
||||||
functionList = this.baseMapper.selectList(componentQueryWrapper).stream().map(RoleFunction::getFunctionId).collect(Collectors.toList());
|
functionList = this.baseMapper.selectList(componentQueryWrapper).stream().map(RoleFunction::getFunctionId).collect(Collectors.toList());
|
||||||
return functionList;
|
if (CollectionUtil.isNotEmpty(functionList)){
|
||||||
|
result = functionMapper.getByList(functionList);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user