opt:出库完成相关逻辑修改。
This commit is contained in:
@@ -8,9 +8,9 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.RsaUtils;
|
||||
import org.nl.common.utils.dto.CurrentUser;
|
||||
@@ -21,6 +21,7 @@ import org.nl.system.service.secutiry.dto.AuthUserDto;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
@@ -38,14 +40,46 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/mobile/auth")
|
||||
@RequestMapping("/api/bigScreenScreen")
|
||||
public class MobileAuthorizationController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@PostMapping(value = "/login")
|
||||
@PostMapping("/login")
|
||||
@SaIgnore
|
||||
//("手持登陆验证")
|
||||
public ResponseEntity<Object> handLogin(@RequestBody Map<String, String> whereJson) {
|
||||
SysUser userInfo = userService.getOne(new QueryWrapper<SysUser>().eq("username", whereJson.get("user")));
|
||||
if (userInfo == null || !userInfo.getPassword().equals(SaSecureUtil.md5BySalt(RsaUtils.decryptByPrivateKey(RsaUtils.KEY, whereJson.get("password")), "salt"))) { // 这里需要密码加密
|
||||
throw new BadRequestException("账号或密码错误");
|
||||
}
|
||||
if (!userInfo.getIs_used()) {
|
||||
throw new BadRequestException("账号未激活");
|
||||
}
|
||||
List<String> permissionList = roleService.getPermissionList((JSONObject) JSON.toJSON(userInfo));
|
||||
// 登录输入,登出删除
|
||||
CurrentUser user = new CurrentUser();
|
||||
user.setId(userInfo.getUser_id());
|
||||
user.setUsername(userInfo.getUsername());
|
||||
user.setPresonName((userInfo.getPerson_name()));
|
||||
user.setUser(userInfo);
|
||||
user.setPermissions(permissionList);
|
||||
// SaLoginModel 配置登录相关参数
|
||||
StpUtil.login(userInfo.getUser_id(), new SaLoginModel()
|
||||
.setDevice("PC") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
|
||||
.setExtra("loginInfo", JSONObject.toJSONString(user)) // Token挂载的扩展参数 (此方法只有在集成jwt插件时才会生效)
|
||||
);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("token", StpUtil.getTokenValue());
|
||||
result.put("roles", permissionList);
|
||||
result.put("user", user);
|
||||
return new ResponseEntity<>(TableDataInfo.buildJson(result), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/userLogin")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
String salt = "salt";
|
||||
|
||||
@@ -30,8 +30,7 @@ public class AuthUserDto {
|
||||
|
||||
|
||||
private String username;
|
||||
|
||||
|
||||
private String user;
|
||||
private String password;
|
||||
|
||||
private String code;
|
||||
|
||||
Reference in New Issue
Block a user