12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package com.fuzamei.service.serviceImpl;
- import java.util.List;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.fuzamei.entity.Param;
- import com.fuzamei.entity.UserDetail;
- import com.fuzamei.mapperInterface.UserAuthoricationMapper;
- import com.fuzamei.service.UserAuthoricationService;
- @Service
- public class UserAuthoricationServiceImpl implements UserAuthoricationService {
- @Autowired
- private UserAuthoricationMapper userAuthoricationMapper;
-
- @Override
- public UserDetail queryUserDetail(Integer userId,String... roleNames) {
- UserDetail userDetail = userAuthoricationMapper.queryUserDetail(userId);
- if(userDetail==null){
- throw new RuntimeException("无此用户");
- }
- if (roleNames.length!=0) {
- String roleName = userDetail.getRoleName();
- boolean flag = false;
- for (String name : roleNames) {
- if (name.equals(roleName)) {
- flag = true;
- break;
- }
- }
- if (!flag) {
- throw new RuntimeException("无权操作");
- }
- }
- return userDetail;
- }
- @Override
- public UserDetail queryUserAuthority(Integer userId, String... roleNames) {
- UserDetail userDetail = userAuthoricationMapper.queryUserAuthority(userId);
- if(userDetail==null){
- throw new RuntimeException("无此用户");
- }
- if (roleNames.length!=0) {
- String roleName = userDetail.getRoleName();
- boolean flag = false;
- for (String name : roleNames) {
- if (name.equals(roleName)) {
- flag = true;
- break;
- }
- }
- if (!flag) {
- throw new RuntimeException("无权操作");
- }
- }
- return userDetail;
- }
- @Override
- public List<UserDetail> showAllCarriersUnderSupplier(Param param) {
- return userAuthoricationMapper.showAllCarriersUnderSupplier(param);
- }
- }
|