src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -360,4 +360,14 @@ return R.success("操作成功"); } /** * 获取用户信息 * @return */ @GetMapping("/getUserInfo") public R getUserInfo(){ //根据保安员编码查询保安员信息 return R.data(userService.getUserInfo(AuthUtil.getUserId())); } } src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -22,6 +22,7 @@ import org.apache.ibatis.annotations.Param; import org.springblade.modules.system.excel.UserExcel; import org.springblade.modules.system.entity.User; import org.springblade.modules.system.vo.UserDetailVO; import org.springblade.modules.system.vo.UserVO; import java.util.List; @@ -82,4 +83,11 @@ * @return */ List<User> getUserListByPhoneOrAccount(@Param("phoneNumber") String phoneNumber); /** * 用户详情接口 * @param userId * @return */ UserDetailVO getUserInfo(@Param("userId") Long userId); } src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -107,4 +107,10 @@ and (account = #{phoneNumber} or phone = #{phoneNumber}) </select> <!--用户详情接口--> <select id="getUserInfo" resultType="org.springblade.modules.system.vo.UserDetailVO"> SELECT * FROM blade_user where is_deleted = 0 and id = #{userId} </select> </mapper> src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -26,6 +26,7 @@ import org.springblade.modules.system.entity.UserInfo; import org.springblade.modules.system.entity.UserOauth; import org.springblade.modules.system.excel.UserExcel; import org.springblade.modules.system.vo.UserDetailVO; import org.springblade.modules.system.vo.UserVO; import java.util.List; @@ -227,4 +228,10 @@ * @return */ List<User> getUserListByPhoneOrAccount(String phoneNumber); /** * 获取用户信息 * @return */ UserDetailVO getUserInfo(Long userId); } src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -48,6 +48,7 @@ import org.springblade.modules.system.service.IUserDeptService; import org.springblade.modules.system.service.IUserOauthService; import org.springblade.modules.system.service.IUserService; import org.springblade.modules.system.vo.UserDetailVO; import org.springblade.modules.system.vo.UserVO; import org.springblade.modules.system.wrapper.UserWrapper; import org.springframework.stereotype.Service; @@ -466,4 +467,19 @@ public List<User> getUserListByPhoneOrAccount(String phoneNumber) { return baseMapper.getUserListByPhoneOrAccount( phoneNumber); } /** * 获取用户信息 * @return */ @Override public UserDetailVO getUserInfo(Long userId) { // 根据用户id 获取用户详情信息 UserDetailVO userVO = baseMapper.getUserInfo(userId); if (null!=userVO){ userVO.setPassword(null); } // 返回 return userVO; } } src/main/java/org/springblade/modules/system/vo/UserDetailVO.java
New file @@ -0,0 +1,43 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.system.vo; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.modules.system.entity.Role; import org.springblade.modules.system.entity.User; import java.util.ArrayList; import java.util.List; /** * 视图实体类 * * @author Chill */ @Data @EqualsAndHashCode(callSuper = true) @ApiModel(value = "UserVO对象", description = "UserVO对象") public class UserDetailVO extends User { private static final long serialVersionUID = 1L; private List<Role> roleList = new ArrayList<>(); }