|
@@ -17,29 +17,48 @@
|
|
|
|
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
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.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.core.util.R;
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
|
|
+import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
|
+import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author hnqz
|
|
* @author hnqz
|
|
* @date 2018/11/14
|
|
* @date 2018/11/14
|
|
* <p>
|
|
* <p>
|
|
* 手机验证码
|
|
* 手机验证码
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@RestController
|
|
@RestController
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
@RequestMapping("/mobile")
|
|
@RequestMapping("/mobile")
|
|
@Api(value = "mobile", tags = "手机管理模块")
|
|
@Api(value = "mobile", tags = "手机管理模块")
|
|
public class MobileController {
|
|
public class MobileController {
|
|
|
|
|
|
|
|
+ private static final Integer FINA_ROLE_CODE = 7;
|
|
|
|
+
|
|
private final MobileService mobileService;
|
|
private final MobileService mobileService;
|
|
|
|
+ private final SysUserService userService;
|
|
|
|
+ private final SysUserRoleService userRoleService;
|
|
|
|
|
|
@Inner(value = false)
|
|
@Inner(value = false)
|
|
@GetMapping("/{mobile}")
|
|
@GetMapping("/{mobile}")
|
|
@@ -54,4 +73,31 @@ public class MobileController {
|
|
return mobileService.sendSmsCodePc(mobile);
|
|
return mobileService.sendSmsCodePc(mobile);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 财务管理员发送验证码
|
|
|
|
+ *
|
|
|
|
+ * @return 发送结果
|
|
|
|
+ */
|
|
|
|
+ @Inner(value = false)
|
|
|
|
+ @GetMapping("/for-fina")
|
|
|
|
+ public R<?> sendSmsCodeForFina(@RequestParam(value = "userId") Integer userId) {
|
|
|
|
+
|
|
|
|
+ List<SysUserRole> userRoles = userRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userId));
|
|
|
|
+
|
|
|
|
+ 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("请联系管理员开通财务管理员权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取用户信息判断,是否需要发送验证码
|
|
|
|
+ SysUser sysUser = userService.getById(userId);
|
|
|
|
+ log.info("是否需要发送验证码temp3:{}", sysUser.getTemp3());
|
|
|
|
+ boolean need = StrUtil.isBlank(sysUser.getTemp3());
|
|
|
|
+ String username = need ? sysUser.getUsername() : sysUser.getTemp3();
|
|
|
|
+ Boolean smsSucc = mobileService.sendSmsCodeForFina(username, need);
|
|
|
|
+ return R.ok(smsSucc, smsSucc ? "成功" : "失败");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|