接口调整

This commit is contained in:
2023-08-08 10:17:42 +08:00
parent 0054466fd9
commit c4978d971e
7 changed files with 55 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
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.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -42,10 +44,10 @@ public class RoleFunctionController extends BaseController {
@PostMapping("/getFunctionsByRoleIndex")
@ApiOperation("根据角色id查询相关联的资源")
@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");
LogUtil.njcnDebug(log, "{},传入的角色id{}", methodDescribe,id);
List<String> list = roleFunctionService.getFunctionsByRoleIndex(id);
List<FunctionVO> list = roleFunctionService.getFunctionsByRoleIndex(id);
if(list.isEmpty()){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, list, methodDescribe);
}else {

View File

@@ -23,4 +23,6 @@ public interface FunctionMapper extends BaseMapper<Function> {
List<FunctionVO> getUserFunctionsByList(@Param("list")List<String> functionList);
List<FunctionVO> getByList(@Param("list")List<String> functionList);
}

View File

@@ -60,4 +60,24 @@
</foreach>
</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>

View File

@@ -113,4 +113,10 @@ public interface IFunctionService extends IService<Function> {
*/
List<FunctionVO> getUserFunctionTree();
/**
* 根据菜单集合获取数据
* @author xy
*/
List<Function> getFunctionByList(List<String> list);
}

View File

@@ -1,7 +1,9 @@
package com.njcn.user.service;
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.vo.FunctionVO;
import java.util.List;
@@ -14,7 +16,7 @@ import java.util.List;
* @since 2021-12-13
*/
public interface IRoleFunctionService extends IService<RoleFunction> {
List<String> getFunctionsByRoleIndex(String id);
List<FunctionVO> getFunctionsByRoleIndex(String id);
/**
* 功能描述: 根据角色集合获取菜单方法

View File

@@ -236,6 +236,11 @@ public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> i
return result;
}
@Override
public List<Function> getFunctionByList(List<String> list) {
return this.lambdaQuery().in(Function::getId,list).list();
}
/**
* 根据角色删除资源
* @param roleIndex

View File

@@ -1,10 +1,16 @@
package com.njcn.user.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.user.mapper.FunctionMapper;
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.vo.FunctionVO;
import com.njcn.user.service.IFunctionService;
import com.njcn.user.service.IRoleFunctionService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -20,15 +26,22 @@ import java.util.stream.Collectors;
* @since 2021-12-13
*/
@Service
@AllArgsConstructor
public class RoleFunctionServiceImpl extends ServiceImpl<RoleFunctionMapper, RoleFunction> implements IRoleFunctionService {
private final FunctionMapper functionMapper;
@Override
public List<String> getFunctionsByRoleIndex(String id) {
public List<FunctionVO> getFunctionsByRoleIndex(String id) {
List<FunctionVO> result = new ArrayList<>();
List<String> functionList = new ArrayList<>();
QueryWrapper<RoleFunction> componentQueryWrapper = new QueryWrapper<>();
componentQueryWrapper.eq("sys_role_function.role_id",id);
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