|
@@ -18,8 +18,11 @@
|
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysUserRole;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.MobileService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysUserRoleService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
@@ -31,9 +34,12 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author hnqz
|
|
@@ -48,10 +54,11 @@ import java.util.List;
|
|
|
@Api(value = "mobile", tags = "手机管理模块")
|
|
|
public class MobileController {
|
|
|
|
|
|
- private static final int FINA_ROLE_CODE = 7;
|
|
|
+ private static final Integer FINA_ROLE_CODE = 7;
|
|
|
|
|
|
private final MobileService mobileService;
|
|
|
private final SysUserService userService;
|
|
|
+ private final SysUserRoleService userRoleService;
|
|
|
|
|
|
@Inner(value = false)
|
|
|
@GetMapping("/{mobile}")
|
|
@@ -71,22 +78,22 @@ public class MobileController {
|
|
|
*
|
|
|
* @return 发送结果
|
|
|
*/
|
|
|
+ @Inner(value = false)
|
|
|
@GetMapping("/for-fina")
|
|
|
- public R<?> sendSmsCodeForFina() {
|
|
|
-
|
|
|
+ public R<?> sendSmsCodeForFina(@RequestParam(value = "userId") Integer userId) {
|
|
|
|
|
|
- // List<Integer> roles = SecurityUtils.getRoles();
|
|
|
- //
|
|
|
- // if (!roles.contains(FINA_ROLE_CODE)) {
|
|
|
- // return R.failed("请联系管理员开通财务管理员权限");
|
|
|
- // }
|
|
|
+ List<SysUserRole> userRoles = userRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userId));
|
|
|
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
+ Set<Integer> roles = userRoles.stream().mapToInt(SysUserRole::getRoleId).boxed().collect(Collectors.toSet());
|
|
|
+ log.info("roles:{}", roles);
|
|
|
+ if (!roles.contains(FINA_ROLE_CODE)) {
|
|
|
+ return R.failed("请联系管理员开通财务管理员权限");
|
|
|
+ }
|
|
|
|
|
|
String username = "13371737109";
|
|
|
|
|
|
// 获取用户信息判断,是否需要发送验证码
|
|
|
- SysUser sysUser = userService.getById(user.getId());
|
|
|
+ SysUser sysUser = userService.getById(userId);
|
|
|
log.info("是否需要发送验证码temp3:{}", sysUser.getTemp3());
|
|
|
boolean need = StrUtil.isBlank(sysUser.getTemp3());
|
|
|
Boolean smsSucc = mobileService.sendSmsCodeForFina(username, need);
|