feat:多钱包、电子饭卡、饭卡充值

This commit is contained in:
dzc committed 2024-12-30 17:24:34 +08:00
1 parent d684f1bc97
commit 0f6da3a679
40 files changed
+1781 -225

No files matched your search

@@ -51,4 +51,10 @@ public class UserInfo implements Serializable {
@Schema(description = "角色标识集合")
private Long[] roles;
/**
* 角色集合
*/
@Schema(description = "角色标识集合")
private String[] roleCodes;
}
@@ -37,94 +37,113 @@ import java.util.List;
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.UPMS_SERVICE)
public interface RemoteUserService {
/**
* 通过用户名查询用户、角色信息
* @param username 用户名
* @return R
*/
@NoToken
@GetMapping("/user/info/{username}")
R<UserInfo> info(@PathVariable("username") String username);
/**
* 通过用户名查询用户、角色信息
*
* @param username 用户名
* @return R
*/
@NoToken
@GetMapping("/user/info/{username}")
R<UserInfo> info(@PathVariable("username") String username);
/**
* 根据用户ID获取用户
* @param userIds ID
* @return SysUser
*/
@GetMapping("/user/list")
R<List<SysUser>> getUserById(@RequestParam("userIds") List<Long> userIds);
/**
* 通过用户id查询用户、角色信息
*
* @param userId 用户名
* @return R
*/
@NoToken
@GetMapping("/user/get-by-user-id")
R<UserInfo> getByUserId(@RequestParam("userId") Long userId);
/**
* 通过社交账号或手机号查询用户、角色信息
* @param inStr appid@code
* @return
*/
@NoToken
@GetMapping("/social/info/{inStr}")
R<UserInfo> social(@PathVariable("inStr") String inStr);
/**
* 根据用户ID获取用户
*
* @param userIds ID
* @return SysUser
*/
@GetMapping("/user/list")
R<List<SysUser>> getUserById(@RequestParam("userIds") List<Long> userIds);
/**
* 查询上级部门的用户信息
* @param username 用户名
* @return R
*/
@GetMapping("/user/ancestor/{username}")
R<List<SysUser>> ancestorUsers(@PathVariable("username") String username);
/**
* 通过社交账号或手机号查询用户、角色信息
*
* @param inStr appid@code
* @return
*/
@NoToken
@GetMapping("/social/info/{inStr}")
R<UserInfo> social(@PathVariable("inStr") String inStr);
/**
* 锁定用户
* @param username 用户名
* @return
*/
@NoToken
@PutMapping("/user/lock/{username}")
R<Boolean> lockUser(@PathVariable("username") String username);
/**
* 查询上级部门的用户信息
*
* @param username 用户名
* @return R
*/
@GetMapping("/user/ancestor/{username}")
R<List<SysUser>> ancestorUsers(@PathVariable("username") String username);
/**
* 根据角色ID查询用户列表
* @param roleIdList 角色ID列表
* @return 用户ID列表
*/
@GetMapping("/user/getUserIdListByRoleIdList")
R<List<Long>> getUserIdListByRoleIdList(@RequestParam("roleIdList") List<Long> roleIdList);
/**
* 锁定用户
*
* @param username 用户名
* @return
*/
@NoToken
@PutMapping("/user/lock/{username}")
R<Boolean> lockUser(@PathVariable("username") String username);
/**
* 根据部门ID列表获取用户ID列表接口
* @param deptIdList 部门ID列表
* @return 用户ID列表
*/
@GetMapping("/user/getUserIdListByDeptIdList")
R<List<SysUser>> getUserIdListByDeptIdList(@RequestParam("deptIdList") List<Long> deptIdList);
/**
* 根据角色ID查询用户列表
*
* @param roleIdList 角色ID列表
* @return 用户ID列表
*/
@GetMapping("/user/getUserIdListByRoleIdList")
R<List<Long>> getUserIdListByRoleIdList(@RequestParam("roleIdList") List<Long> roleIdList);
/**
* 通过用户名查询用户列表
* @param userName 用户名
* @return 用户列表
*/
@GetMapping("/user/getUserListByUserName")
R<List<SysUser>> getUserListByUserName(@RequestParam("username") String userName);
/**
* 根据部门ID列表获取用户ID列表接口
*
* @param deptIdList 部门ID列表
* @return 用户ID列表
*/
@GetMapping("/user/getUserIdListByDeptIdList")
R<List<SysUser>> getUserIdListByDeptIdList(@RequestParam("deptIdList") List<Long> deptIdList);
/**
* 注册用户
* @param userDTO 用户信息
* @return success/false
*/
@NoToken
@PostMapping("/register/user")
R<Boolean> registerUser(@RequestBody UserDTO userDTO);
/**
* 通过用户名查询用户列表
*
* @param userName 用户名
* @return 用户列表
*/
@GetMapping("/user/getUserListByUserName")
R<List<SysUser>> getUserListByUserName(@RequestParam("username") String userName);
/**
* 根据钉钉号和手机号查询用户信息
* @param employeeCode 钉钉号
*
* @return 用户信息
*/
@NoToken
@GetMapping("/user/getUserByMobileOrEmployeeCode")
R<List<SysUser>> getUserByMobileOrEmployeeCode(@RequestParam("employeeCode")String employeeCode,
@RequestParam("mobile") String mobile);
/**
* 注册用户
*
* @param userDTO 用户信息
* @return success/false
*/
@NoToken
@PostMapping("/register/user")
R<Boolean> registerUser(@RequestBody UserDTO userDTO);
@NoToken
@GetMapping("/user/getUserByMobile")
R<List<SysUser>> getUserByMobile(@RequestParam("mobile") String mobile);
/**
* 根据钉钉号和手机号查询用户信息
*
* @param employeeCode 钉钉号
* @return 用户信息
*/
@NoToken
@GetMapping("/user/getUserByMobileOrEmployeeCode")
R<List<SysUser>> getUserByMobileOrEmployeeCode(@RequestParam("employeeCode") String employeeCode,
@RequestParam("mobile") String mobile);
@NoToken
@GetMapping("/user/getUserByMobile")
R<List<SysUser>> getUserByMobile(@RequestParam("mobile") String mobile);
}
@@ -3,84 +3,113 @@ package com.bsd.pjcloud.admin.api.utils;
import cn.hutool.core.collection.CollUtil;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.entity.SysMenu;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import lombok.experimental.UtilityClass;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@UtilityClass
public class DataUtil {
/**
* 根据当前部门id,向上查找所有的部门
* @param deptId 当前部门id
* @param allDeptList 所有部门列表
* @return 返回包括自己部门在内的所有父级部门
*/
public List<SysDept> selectParentByDept(long deptId, List<SysDept> allDeptList) {
List<SysDept> list = new ArrayList<>();
Optional<SysDept> optionalDept = allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst();
/**
* 根据当前部门id,向上查找所有的部门
*
* @param deptId 当前部门id
* @param allDeptList 所有部门列表
* @return 返回包括自己部门在内的所有父级部门
*/
public List<SysDept> selectParentByDept(long deptId, List<SysDept> allDeptList) {
List<SysDept> list = new ArrayList<>();
Optional<SysDept> optionalDept = allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst();
optionalDept.ifPresent(dept -> {
if (dept.getParentId() != null) {
Long parentId = dept.getParentId();
List<SysDept> depts = selectParentByDept(parentId, allDeptList);
list.add(dept);
list.addAll(depts);
}
});
optionalDept.ifPresent(dept -> {
if (dept.getParentId() != null) {
Long parentId = dept.getParentId();
List<SysDept> depts = selectParentByDept(parentId, allDeptList);
list.add(dept);
list.addAll(depts);
}
});
return list;
}
return list;
}
/**
* 根据当前部门id,向下查找所有的部门
* @param deptId 当前部门id
* @param allDeptList 所有部门列表
* @return 返回包括自己部门在内的所有子级部门
*/
public List<SysDept> selectChildrenByDept(long deptId, List<SysDept> allDeptList) {
List<SysDept> list = new ArrayList<>();
Optional<SysDept> optionalDept = allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst();
/**
* 根据当前部门id,向下查找所有的部门
*
* @param deptId 当前部门id
* @param allDeptList 所有部门列表
* @return 返回包括自己部门在内的所有子级部门
*/
public List<SysDept> selectChildrenByDept(long deptId, List<SysDept> allDeptList) {
List<SysDept> list = new ArrayList<>();
Optional<SysDept> optionalDept = allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst();
optionalDept.ifPresent(list::add);
optionalDept.ifPresent(list::add);
List<SysDept> collect = allDeptList.stream()
.filter(w -> w.getParentId() == deptId)
.collect(Collectors.toList());
List<SysDept> collect = allDeptList.stream()
.filter(w -> w.getParentId() == deptId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
return list;
}
if (CollUtil.isEmpty(collect)) {
return list;
}
collect.forEach(dept -> {
List<SysDept> depts = selectChildrenByDept(dept.getDeptId(), allDeptList);
list.addAll(depts);
});
collect.forEach(dept -> {
List<SysDept> depts = selectChildrenByDept(dept.getDeptId(), allDeptList);
list.addAll(depts);
});
return list;
}
return list;
}
/**
* 根据当前菜单id,向下查找所有的菜单
* @param menuId 当前菜单id
* @param allMenuList 所有菜单列表
* @return 返回包括自己在内的所有子级菜单
*/
public List<SysMenu> selectChildrenByMenu(long menuId, List<SysMenu> allMenuList) {
List<SysMenu> list = new ArrayList<>();
list.add(allMenuList.stream().filter(w -> w.getMenuId() == menuId).findFirst().get());
/**
* 根据当前菜单id,向下查找所有的菜单
*
* @param menuId 当前菜单id
* @param allMenuList 所有菜单列表
* @return 返回包括自己在内的所有子级菜单
*/
public List<SysMenu> selectChildrenByMenu(long menuId, List<SysMenu> allMenuList) {
List<SysMenu> list = new ArrayList<>();
list.add(allMenuList.stream().filter(w -> w.getMenuId() == menuId).findFirst().get());
List<SysMenu> collect = allMenuList.stream()
.filter(w -> w.getParentId() == menuId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
return list;
}
collect.forEach(dept -> list.addAll(selectChildrenByMenu(dept.getMenuId(), allMenuList)));
return list;
}
List<SysMenu> collect = allMenuList.stream()
.filter(w -> w.getParentId() == menuId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
return list;
}
collect.forEach(dept -> list.addAll(selectChildrenByMenu(dept.getMenuId(), allMenuList)));
return list;
}
public <T extends BaseUserInterface> List<T> convertUserList(List<T> list, Map<Long, SysUser> map) {
return CollectionUtils.convertList(list, user -> convertUser(user, map.get(user.getUserId())));
}
public <T extends BaseUserInterface> T convertUser(T v, SysUser user) {
v.setUsername(user.getUsername());
v.setUserMobile(user.getPhone());
v.setUserAvatar(user.getAvatar());
return v;
}
public <T extends BaseDeptInterface> List<T> convertDeptList(List<T> list, Map<Long, SysDept> map) {
return CollectionUtils.convertList(list, user -> convertDept(user, map.get(user.getDeptId())));
}
public <T extends BaseDeptInterface> T convertDept(T v, SysDept dept) {
v.setDeptId(dept.getDeptId());
v.setDeptName(dept.getName());
return v;
}
}
@@ -0,0 +1,19 @@
package com.bsd.pjcloud.admin.api.vo.base;
public interface BaseDeptInterface {
/**
* 部门id
*/
Long getDeptId();
void setDeptId(Long deptId);
/**
* 部门名
*/
String getDeptName();
void setDeptName(String deptName);
}
@@ -0,0 +1,33 @@
package com.bsd.pjcloud.admin.api.vo.base;
public interface BaseUserInterface {
/**
* 用户id
*/
Long getUserId();
void setUserId(Long userId);
/**
* 用户名
*/
String getUsername();
void setUsername(String username);
/**
* 用户手机号
*/
String getUserMobile();
void setUserMobile(String userMobile);
/**
* 用户头像
*/
String getUserAvatar();
void setUserAvatar(String userAvatar);
}
+6
View File
@@ -189,6 +189,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-wallet-api</artifactId>
<version>5.7.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -78,6 +78,21 @@ public class SysUserController {
return R.ok(userService.findUserInfo(user));
}
/**
* 获取指定用户全部信息
*
* @return 用户信息
*/
@Inner
@GetMapping("/get-by-user-id")
public R getByUserId(@RequestParam Long userId) {
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUserId, userId));
if (user == null) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, userId));
}
return R.ok(userService.findUserInfo(user));
}
/**
* 获取当前用户全部信息
*
@@ -314,6 +329,7 @@ public class SysUserController {
/**
* 根据浙政钉号和手机号查询
*
* @param employeeCode
* @param mobile
* @return
@@ -49,6 +49,7 @@ import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.common.excel.vo.ErrorMessage;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
@@ -90,6 +91,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final CacheManager cacheManager;
private final RemoteWalletService remoteWalletService;
/**
* 保存用户信息
*
@@ -135,6 +138,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userRole.setRoleId(roleId);
return userRole;
}).forEach(sysUserRoleMapper::insert);
// 创建用户默认钱包
remoteWalletService.createWallet(userDto.getUserId());
return Boolean.TRUE;
}
@@ -155,6 +162,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
.collect(Collectors.toList());
userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class));
// 设置角色列表 (CODE)
List<String> roleCodes = sysRoleService.findRolesByUserId(sysUser.getUserId())
.stream()
.map(SysRole::getRoleCode)
.collect(Collectors.toList());
userInfo.setRoleCodes(ArrayUtil.toArray(roleCodes, String.class));
// 设置权限列表(menu.permission)
Set<String> permissions = new HashSet<>();
roleIds.forEach(roleId -> {
@@ -267,6 +281,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}).forEach(SysUserPost::insert);
}
// 创建用户默认钱包
remoteWalletService.createWallet(userDto.getUserId());
return Boolean.TRUE;
}