|
@@ -1,448 +0,0 @@
|
|
|
-package com.tzy.web.controller.system;
|
|
|
|
|
-
|
|
|
|
|
-import com.tzy.common.annotation.Log;
|
|
|
|
|
-import com.tzy.common.constant.Constants;
|
|
|
|
|
-import com.tzy.common.constant.UserConstants;
|
|
|
|
|
-import com.tzy.common.core.controller.BaseController;
|
|
|
|
|
-import com.tzy.common.core.domain.AjaxResult;
|
|
|
|
|
-import com.tzy.common.core.domain.MsgResult;
|
|
|
|
|
-import com.tzy.common.core.domain.entity.SysRole;
|
|
|
|
|
-import com.tzy.common.core.domain.entity.SysUser;
|
|
|
|
|
-import com.tzy.common.core.page.TableDataInfo;
|
|
|
|
|
-import com.tzy.common.enums.BusinessType;
|
|
|
|
|
-import com.tzy.common.exception.BusinessException;
|
|
|
|
|
-import com.tzy.common.utils.ShiroUtils;
|
|
|
|
|
-import com.tzy.common.utils.StringUtils;
|
|
|
|
|
-import com.tzy.common.utils.poi.ExcelUtil;
|
|
|
|
|
-import com.tzy.framework.shiro.service.SysPasswordService;
|
|
|
|
|
-import com.tzy.framework.shiro.util.AuthorizationUtils;
|
|
|
|
|
-import com.tzy.framework.util.RedisUtils;
|
|
|
|
|
-import com.tzy.system.domain.UserInfoModel;
|
|
|
|
|
-import com.tzy.system.service.ISysPostService;
|
|
|
|
|
-import com.tzy.system.service.ISysRoleService;
|
|
|
|
|
-import com.tzy.system.service.ISysUserService;
|
|
|
|
|
-import com.warrenstrange.googleauth.GoogleAuthenticator;
|
|
|
|
|
-import com.warrenstrange.googleauth.GoogleAuthenticatorKey;
|
|
|
|
|
-import com.warrenstrange.googleauth.GoogleAuthenticatorQRGenerator;
|
|
|
|
|
-import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
-
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 用户信息
|
|
|
|
|
- *
|
|
|
|
|
- * @author zheng
|
|
|
|
|
- */
|
|
|
|
|
-@Controller
|
|
|
|
|
-@RequestMapping("/system/user")
|
|
|
|
|
-public class SysUserController extends BaseController
|
|
|
|
|
-{
|
|
|
|
|
- private String prefix = "system/user";
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private ISysUserService userService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private ISysRoleService roleService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private ISysPostService postService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private SysPasswordService passwordService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private GoogleAuthenticator gAuth;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private RedisUtils redisUtils;
|
|
|
|
|
-
|
|
|
|
|
- @RequiresPermissions("system:user:view")
|
|
|
|
|
- @GetMapping()
|
|
|
|
|
- public String user()
|
|
|
|
|
- {
|
|
|
|
|
- return prefix + "/userInfos";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/ExistAccount")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String ExistAccount() {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- return "true";
|
|
|
|
|
- }
|
|
|
|
|
- catch(Exception ex ) {
|
|
|
|
|
- return "false";
|
|
|
|
|
- }
|
|
|
|
|
- finally{
|
|
|
|
|
- //切回主数据源
|
|
|
|
|
- //DynamicDataSourceContextHolder.clearDataSource();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- @RequiresPermissions("system:user:list")
|
|
|
|
|
- @PostMapping("/list")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public TableDataInfo list(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- startPage();
|
|
|
|
|
- String custNo = ShiroUtils.getLoginCustNo();
|
|
|
|
|
- user.setCustNo(custNo);
|
|
|
|
|
- List<SysUser> list = userService.selectUserList(user);
|
|
|
|
|
- return getDataTable(list);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
|
|
|
|
- @RequiresPermissions("system:user:export")
|
|
|
|
|
- @PostMapping("/export")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public MsgResult export(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- List<SysUser> list = userService.selectUserList(user);
|
|
|
|
|
- ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
|
|
- return util.exportExcel(list, "用户数据");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
|
|
|
|
- @RequiresPermissions("system:user:import")
|
|
|
|
|
- @PostMapping("/importData")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
|
|
|
|
- {
|
|
|
|
|
- ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
|
|
- List<SysUser> userList = util.importExcel(file.getInputStream());
|
|
|
|
|
- String operName = ShiroUtils.getSysUser().getLoginName();
|
|
|
|
|
- String message = userService.importUser(userList, updateSupport, operName);
|
|
|
|
|
- return AjaxResult.success(message);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequiresPermissions("system:user:view")
|
|
|
|
|
- @GetMapping("/importTemplate")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public MsgResult importTemplate()
|
|
|
|
|
- {
|
|
|
|
|
- ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
|
|
- return util.importTemplateExcel("用户数据");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 新增用户
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/add")
|
|
|
|
|
- public String add(ModelMap mmap)
|
|
|
|
|
- {
|
|
|
|
|
- mmap.put("roles", roleService.selectRoleAll().stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
|
|
|
- mmap.put("posts", postService.selectPostAll());
|
|
|
|
|
- return prefix + "/add";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 新增保存用户
|
|
|
|
|
- */
|
|
|
|
|
- @RequiresPermissions("system:user:add")
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.INSERT)
|
|
|
|
|
- @PostMapping("/addSave")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public MsgResult addSave(@Validated SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- //设置公司编号
|
|
|
|
|
- String custNo = ShiroUtils.getLoginCustNo();
|
|
|
|
|
- String branchNo=ShiroUtils.getLoginBranchNo();
|
|
|
|
|
- user.setCustNo(custNo);
|
|
|
|
|
- user.setBranchNo(branchNo);
|
|
|
|
|
- //设置初始密码
|
|
|
|
|
- user.setPassword("123");
|
|
|
|
|
- if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
|
|
|
|
|
- {
|
|
|
|
|
- return errorMsg("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
|
|
|
|
|
- }
|
|
|
|
|
- else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
|
|
|
|
- && UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
|
|
|
|
- {
|
|
|
|
|
- return errorMsg("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
|
|
|
|
- }
|
|
|
|
|
- else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
|
|
- && UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
|
|
|
|
- {
|
|
|
|
|
- return errorMsg("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
|
|
|
|
- }
|
|
|
|
|
- user.setSalt(ShiroUtils.randomSalt());
|
|
|
|
|
- user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
|
|
|
|
- user.setCreateBy(ShiroUtils.getLoginName());
|
|
|
|
|
- return toReturn(userService.insertUser(user));
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception Ex) {
|
|
|
|
|
- return errorMsg("系统异常:"+Ex.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改用户
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/edit/{userId}")
|
|
|
|
|
- public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
|
|
|
|
|
- {
|
|
|
|
|
- SysUser user = ShiroUtils.getSysUser();
|
|
|
|
|
- List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
|
|
|
|
- mmap.put("user", userService.selectUserById(userId));
|
|
|
|
|
- mmap.put("roles", SysUser.isAdmin(user.getIsSuper()) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
|
|
|
- // mmap.put("posts", postService.selectPostsByUserId(userId));
|
|
|
|
|
- return prefix + "/edit";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改保存用户
|
|
|
|
|
- */
|
|
|
|
|
- @RequiresPermissions("system:user:edit")
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
|
|
- @PostMapping("/editSave")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public MsgResult editSave(@Validated SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- userService.checkUserAllowed(user);
|
|
|
|
|
- if (StringUtils.isNotEmpty(user.getPhonenumber())
|
|
|
|
|
- && UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
|
|
|
|
- {
|
|
|
|
|
- return errorMsg("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
|
|
|
|
- }
|
|
|
|
|
- else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
|
|
- && UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
|
|
|
|
- {
|
|
|
|
|
- return errorMsg("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
|
|
|
|
- }
|
|
|
|
|
- user.setUpdateBy(ShiroUtils.getLoginName());
|
|
|
|
|
- AuthorizationUtils.clearAllCachedAuthorizationInfo();
|
|
|
|
|
- return toReturn(userService.updateUser(user));
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception Ex) {
|
|
|
|
|
- return errorMsg("系统异常:"+Ex.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequiresPermissions("system:user:resetPwd")
|
|
|
|
|
- @GetMapping("/resetPwd/{userId}")
|
|
|
|
|
- public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
|
|
|
|
|
- {
|
|
|
|
|
- mmap.put("user", userService.selectUserById(userId));
|
|
|
|
|
- return prefix + "/resetPwd";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequiresPermissions("system:user:resetPwd")
|
|
|
|
|
- @Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
|
|
|
|
- @PostMapping("/resetPwd")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public MsgResult resetPwdSave(SysUser user) {
|
|
|
|
|
- userService.checkUserAllowed(user);
|
|
|
|
|
- user.setSalt(ShiroUtils.randomSalt());
|
|
|
|
|
- user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
|
|
|
|
- if (userService.resetUserPwd(user) > 0) {
|
|
|
|
|
- redisUtils.hset(Constants.EXPIRE_SESSION_USER_KEY,user.getLoginName(),new Date().getTime());
|
|
|
|
|
- if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue()) {
|
|
|
|
|
- ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
|
|
|
|
- }
|
|
|
|
|
- return toReturn(1);
|
|
|
|
|
- }
|
|
|
|
|
- return errorMsg("密码重置失败!");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 进入授权角色页
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/authRole/{userId}")
|
|
|
|
|
- public String authRole(@PathVariable("userId") Long userId, ModelMap mmap)
|
|
|
|
|
- {
|
|
|
|
|
- SysUser user = userService.selectUserById(userId);
|
|
|
|
|
- user.setFasData(null);
|
|
|
|
|
- // 获取用户所属的角色列表
|
|
|
|
|
- List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
|
|
|
|
- mmap.put("user", user);
|
|
|
|
|
- mmap.put("roles", SysUser.isAdmin(user.getIsSuper()) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
|
|
|
- return prefix + "/authRole";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 用户授权角色
|
|
|
|
|
- */
|
|
|
|
|
- @RequiresPermissions("system:user:add")
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.GRANT)
|
|
|
|
|
- @PostMapping("/authRole/insertAuthRole")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
|
|
|
|
- {
|
|
|
|
|
- userService.insertUserAuth(userId, roleIds);
|
|
|
|
|
- AuthorizationUtils.clearAllCachedAuthorizationInfo();
|
|
|
|
|
- return success();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequiresPermissions("system:user:remove")
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.DELETE)
|
|
|
|
|
- @PostMapping("/remove")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public MsgResult remove(String ids)
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- return toReturn(userService.deleteUserByIds(ids));
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception e)
|
|
|
|
|
- {
|
|
|
|
|
- return errorMsg("系统异常:"+e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 校验用户名
|
|
|
|
|
- */
|
|
|
|
|
- @PostMapping("/checkLoginNameUnique")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String checkLoginNameUnique(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- return userService.checkLoginNameUnique(user.getLoginName());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 校验手机号码
|
|
|
|
|
- */
|
|
|
|
|
- @PostMapping("/checkPhoneUnique")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String checkPhoneUnique(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- return userService.checkPhoneUnique(user);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 校验email邮箱
|
|
|
|
|
- */
|
|
|
|
|
- @PostMapping("/checkEmailUnique")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String checkEmailUnique(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- return userService.checkEmailUnique(user);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 用户状态修改
|
|
|
|
|
- */
|
|
|
|
|
- @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
|
|
- @RequiresPermissions("system:user:edit")
|
|
|
|
|
- @PostMapping("/changeStatus")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public AjaxResult changeStatus(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
- userService.checkUserAllowed(user);
|
|
|
|
|
- return toAjax(userService.changeStatus(user));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * (用户人员下拉)下拉列表的数据
|
|
|
|
|
- *
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/GetUserDropdownList")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public HashMap<String, Object> GetReceiverDropdownList(@RequestParam Map<String, Object> params) {
|
|
|
|
|
- try {
|
|
|
|
|
- List userDownInfoList = new ArrayList();
|
|
|
|
|
- HashMap<String, Object> reponse = new HashMap<>();
|
|
|
|
|
- String keyword = params.containsKey("keyword") ? params.get("keyword").toString() : "";
|
|
|
|
|
- String search = params.containsKey("search") ? params.get("search").toString() : "";
|
|
|
|
|
- String branchNo = ShiroUtils.getSysUser().getBranchNo();
|
|
|
|
|
- String custNo = ShiroUtils.getSysUser().getCustNo();
|
|
|
|
|
- List<UserInfoModel> list = userService.selectUserDropdownList(keyword, branchNo, custNo);
|
|
|
|
|
- if (!list.isEmpty()) {
|
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
- UserInfoModel userdowninfo = list.get(i);
|
|
|
|
|
- Map<String, Object> map = new LinkedHashMap();
|
|
|
|
|
- if(!search.equals("") && search.equals("user_name")){
|
|
|
|
|
- map.put("localBy", userdowninfo.getUserName());
|
|
|
|
|
- map.put("localId", userdowninfo.getUserId());
|
|
|
|
|
- }
|
|
|
|
|
- userDownInfoList.add(map);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- reponse.put("value", userDownInfoList);
|
|
|
|
|
- reponse.put("message", "");
|
|
|
|
|
- reponse.put("code", 200);
|
|
|
|
|
- reponse.put("redirect", "");
|
|
|
|
|
- return reponse;
|
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
|
- ex.printStackTrace();
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 用户绑定动态码的二维码
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public AjaxResult generate(){
|
|
|
|
|
- String username = ShiroUtils.getSysUser().getLoginName();
|
|
|
|
|
- if(StringUtils.isEmpty(username)){
|
|
|
|
|
- throw new BusinessException("请登陆!!!");
|
|
|
|
|
- }
|
|
|
|
|
- GoogleAuthenticatorKey key = gAuth.createCredentials(username);
|
|
|
|
|
- String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthTotpURL("HOBBY STOCKS", username, key);
|
|
|
|
|
- return AjaxResult.success(Constants.LOGIN_SUCCESS,otpAuthURL);
|
|
|
|
|
- }
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改用户
|
|
|
|
|
- */
|
|
|
|
|
- @Log(title = "修改用户绑定", businessType = BusinessType.UPDATE)
|
|
|
|
|
- @RequiresPermissions("system:user:edit")
|
|
|
|
|
- @GetMapping("/generate/{userId}")
|
|
|
|
|
- public String generate(@PathVariable("userId") Long userId, ModelMap mmap)
|
|
|
|
|
- {
|
|
|
|
|
- SysUser user = userService.selectUserById(userId);
|
|
|
|
|
- if(null != user && 1 == user.getFasAuth() ){
|
|
|
|
|
- mmap.put("status", false);
|
|
|
|
|
- mmap.put("statusMsg", "您已经绑定!");
|
|
|
|
|
- }else if(null != user){
|
|
|
|
|
- GoogleAuthenticatorKey key = gAuth.createCredentials(user.getLoginName());
|
|
|
|
|
- String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthTotpURL("HOBBY STOCKS", user.getLoginName(), key);
|
|
|
|
|
- redisUtils.set("fas_auth_"+user.getLoginName(),true,30*60);//30分钟失效
|
|
|
|
|
- mmap.put("status", true);
|
|
|
|
|
- mmap.put("statusMsg", otpAuthURL);
|
|
|
|
|
- } else {
|
|
|
|
|
- mmap.put("status", false);
|
|
|
|
|
- mmap.put("statusMsg", "请重新登陆后在绑定!");
|
|
|
|
|
- }
|
|
|
|
|
- user.setFasData(null);
|
|
|
|
|
- mmap.put("user", user);
|
|
|
|
|
- return prefix + "/fasAuth";
|
|
|
|
|
- }
|
|
|
|
|
- /**
|
|
|
|
|
- * 用户验证
|
|
|
|
|
- * @param userId
|
|
|
|
|
- * @param code
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @Log(title = "用户验证", businessType = BusinessType.UPDATE)
|
|
|
|
|
- @RequiresPermissions("system:user:edit")
|
|
|
|
|
- @PostMapping("/validate")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public AjaxResult validateKey(@RequestParam Long userId,@RequestParam Integer code) {
|
|
|
|
|
- SysUser user = userService.selectUserById(userId);
|
|
|
|
|
- logger.info("用户验证 用户信息 {} ,name {}",user,user.getLoginName());
|
|
|
|
|
- boolean b = gAuth.authorizeUser(user.getLoginName(), code);
|
|
|
|
|
- logger.info("用户验证 code {} ,check:{}",code,b);
|
|
|
|
|
- int i = 0;
|
|
|
|
|
- if(b){
|
|
|
|
|
- user.setFasAuth(1);
|
|
|
|
|
- i = userService.bindingOpt(user);
|
|
|
|
|
- }
|
|
|
|
|
- return toAjax(i);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|