Commit ca144c25 authored by 王向伟's avatar 王向伟

添加权限接口

parent 92d62da3
package cn.quantgroup.cashloanflowboss.api.permissionmodule.controller; package cn.quantgroup.cashloanflowboss.api.permissionmodule.controller;
import cn.quantgroup.cashloanflowboss.api.permissionmodule.model.PermissionVO; import cn.quantgroup.cashloanflowboss.api.permissionmodule.model.PermissionVO;
import cn.quantgroup.cashloanflowboss.api.permissionmodule.service.IPermissionService;
import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security; import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security;
import cn.quantgroup.cashloanflowboss.core.base.Result; import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -19,6 +21,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -19,6 +21,8 @@ import org.springframework.web.bind.annotation.RestController;
public class PermissionController { public class PermissionController {
@Autowired
private IPermissionService permissionService;
/** /**
* 角色 未拥有的权限 * 角色 未拥有的权限
* @param roleId * @param roleId
...@@ -33,14 +37,13 @@ public class PermissionController { ...@@ -33,14 +37,13 @@ public class PermissionController {
/** /**
* 权限列表 * 权限列表
* @param permissionVO
* @return * @return
*/ */
@GetMapping("list") @GetMapping("all")
@Security(authorityId = "Permission.permissionList") //@Security(authorityId = "Permission.permissionList")
public Result permissionList(PermissionVO permissionVO) { public Result permissionList() {
// 分页查询
return null; return permissionService.getAll();
} }
/** /**
......
package cn.quantgroup.cashloanflowboss.api.permissionmodule.service;
import cn.quantgroup.cashloanflowboss.api.permissionmodule.entity.Permission;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import java.util.List;
/**
* @author Wang Xiangwei
* @version 2020/3/6
*/
public interface IPermissionService {
Result<List<Permission>> getAll();
}
package cn.quantgroup.cashloanflowboss.api.permissionmodule.service;
import cn.quantgroup.cashloanflowboss.api.permissionmodule.entity.Permission;
import cn.quantgroup.cashloanflowboss.api.permissionmodule.repository.PermissionRepository;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author Wang Xiangwei
* @version 2020/3/6
*/
@Service
public class PermissionServiceImpl implements IPermissionService {
@Autowired
private PermissionRepository permissionRepository;
@Override
public Result<List<Permission>> getAll() {
List<Permission> permissionList = permissionRepository.findAll();
return Result.buildSuccess(permissionList);
}
}
...@@ -231,7 +231,6 @@ public class UserServiceImpl implements UserService { ...@@ -231,7 +231,6 @@ public class UserServiceImpl implements UserService {
return Result.buildFail(username + " 账户已存在"); return Result.buildFail(username + " 账户已存在");
} }
Long roleId = userModelVo.getRoleId(); Long roleId = userModelVo.getRoleId();
Role role = null; Role role = null;
if (roleId != null) { if (roleId != null) {
...@@ -246,14 +245,13 @@ public class UserServiceImpl implements UserService { ...@@ -246,14 +245,13 @@ public class UserServiceImpl implements UserService {
//渠道检查 //渠道检查
Long channelId = user.getChannelId(); Long channelId = user.getChannelId();
if (channelId != null) { if (channelId != null) {
if (!clfChannelConfigurationRepository.exists(channelId)) { ClfChannelConfiguration configuration = clfChannelConfigurationRepository.findByRegisteredFrom(channelId);
if(configuration == null){
log.error("{},渠道不存在 channelId={}",LOG_PRE,channelId); log.error("{},渠道不存在 channelId={}",LOG_PRE,channelId);
return Result.buildFail("channelId="+channelId+"的渠道不存在"); return Result.buildFail("channelId="+channelId+"的渠道不存在");
} }
ClfChannelConfiguration configuration = clfChannelConfigurationRepository.findOne(channelId);
user.setChannelName(configuration.getChannelName()); user.setChannelName(configuration.getChannelName());
} }
userRepository.save(user); userRepository.save(user);
return Result.buildSuccess(true); return Result.buildSuccess(true);
} }
...@@ -296,12 +294,13 @@ public class UserServiceImpl implements UserService { ...@@ -296,12 +294,13 @@ public class UserServiceImpl implements UserService {
Long channelId = exist.getChannelId(); Long channelId = exist.getChannelId();
//渠道检查
if (channelId != null) { if (channelId != null) {
if (!clfChannelConfigurationRepository.exists(channelId)) { ClfChannelConfiguration configuration = clfChannelConfigurationRepository.findByRegisteredFrom(channelId);
if(configuration == null){
log.error("{},渠道不存在 channelId={}",LOG_PRE,channelId); log.error("{},渠道不存在 channelId={}",LOG_PRE,channelId);
return Result.buildFail("channelId="+channelId+"的渠道不存在"); return Result.buildFail("channelId="+channelId+"的渠道不存在");
} }
ClfChannelConfiguration configuration = clfChannelConfigurationRepository.findOne(channelId);
exist.setChannelName(configuration.getChannelName()); exist.setChannelName(configuration.getChannelName());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment