救援APP

This commit is contained in:
xiao-fajia 2024-08-23 20:41:20 +08:00
parent 77f6d157a5
commit a601ee0246
2 changed files with 66 additions and 56 deletions

View File

@ -12,4 +12,5 @@ public interface CommonErrorCodeConstants extends ErrorCodeConstants {
ErrorCode LOGIN_ACCOUNT_EXIST = new ErrorCode(2_002_000_004, "登录账号已存在");
ErrorCode LOGIN_ACCOUNT_NOT_EXIST = new ErrorCode(2_002_000_005, "登录账号不存在");
ErrorCode SYSTEM_ERROR = new ErrorCode(2_002_000_005, "系统错误");
ErrorCode MISTAKEN_IDENTITY = new ErrorCode(2_002_000_006, "身份有误");
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.rescue.app.controller.admin;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@ -24,8 +25,12 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -304,62 +309,66 @@ public class SysLoginController {
// return ajax;
// }
//
// /**
// * 获取App用户信息
// *
// * @return 用户信息
// */
// @GetMapping("/getJcgfInfo")
// public AjaxResult getJcgfInfo() throws Exception {
// SysUser user = SecurityUtils.getLoginUser().getUser();
// SysUser sysUser = userService.selectUserById(user.getUserId());
// // 角色集合
// Set<String> roles = permissionService.getRolePermission(user);
// AjaxResult ajax = success();
// ajax.put("user", sysUser);
// ajax.put("role", roles);
// if (CollectionUtil.isNotEmpty(roles)){
// AtomicBoolean flag = new AtomicBoolean(false);
// roles.forEach(it->{
// if (it.equals("jcgf")){
// flag.set(true);
// }
// });
// if (!flag.get()){
// throw new Exception("身份有误");
// }
// }else {
// throw new Exception("身份有误");
// }
//
// return ajax;
// }
// //获取交警的信息
// @GetMapping("/getJjInfo")
// public AjaxResult getJjInfo() throws Exception {
// SysUser user = SecurityUtils.getLoginUser().getUser();
// SysUser sysUser = userService.selectUserById(user.getUserId());
// // 角色集合
// Set<String> roles = permissionService.getRolePermission(user);
// AjaxResult ajax = success();
// ajax.put("user", sysUser);
// ajax.put("role", roles);
// if (CollectionUtil.isNotEmpty(roles)){
// AtomicBoolean flag = new AtomicBoolean(false);
// roles.forEach(it->{
// if (it.equals("jjdd")){
// flag.set(true);
// }
// });
// if (!flag.get()){
// throw new Exception("身份有误");
// }
// }else {
// throw new Exception("身份有误");
// }
//
// return ajax;
// }
/**
* 获取App用户信息
*
* @return 用户信息
*/
@GetMapping("/getJcgfInfo")
public CommonResult getJcgfInfo() throws Exception {
Map<String, Object> map = new HashMap<>();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
AdminUserRespDTO user = userService.getUser(loginUser.getId());
// 角色集合
List<RoleReqDTO> roleList = roleApi.getRoleList();
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
List<RoleReqDTO> roles = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
map.put("user", user);
map.put("role", roles);
if (CollectionUtil.isNotEmpty(roles)){
AtomicBoolean flag = new AtomicBoolean(false);
roles.forEach(it->{
if (it.getCode().equals("jcgf")){
flag.set(true);
}
});
if (!flag.get()){
throw exception(CommonErrorCodeConstants.MISTAKEN_IDENTITY);
}
}else {
throw exception(CommonErrorCodeConstants.MISTAKEN_IDENTITY);
}
return success(map);
}
//获取交警的信息
@GetMapping("/getJjInfo")
public CommonResult getJjInfo() throws Exception {
Map<String, Object> map = new HashMap<>();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
AdminUserRespDTO user = userService.getUser(loginUser.getId());
// 角色集合
List<RoleReqDTO> roleList = roleApi.getRoleList();
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
List<RoleReqDTO> roles = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
map.put("user", user);
map.put("role", roles);
if (CollectionUtil.isNotEmpty(roles)){
AtomicBoolean flag = new AtomicBoolean(false);
roles.forEach(it->{
if (it.getCode().equals("jjdd")){
flag.set(true);
}
});
if (!flag.get()){
throw exception(CommonErrorCodeConstants.MISTAKEN_IDENTITY);
}
}else {
throw exception(CommonErrorCodeConstants.MISTAKEN_IDENTITY);
}
return success(map);
}
// /**
// * 获取App用户信息
// *