|
|
@ -11,8 +11,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.nl.common.base.TableDataInfo; |
|
|
|
import org.nl.common.domain.query.PageQuery; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
|
import org.nl.common.logging.annotation.Log; |
|
|
|
import org.nl.common.utils.RedisUtils; |
|
|
|
import org.nl.common.utils.RsaUtils; |
|
|
|
import org.nl.common.utils.dto.CurrentUser; |
|
|
|
import org.nl.config.RsaProperties; |
|
|
@ -24,6 +28,7 @@ import org.nl.system.service.user.dao.SysUser; |
|
|
|
import org.nl.system.service.user.dto.SysUserDetail; |
|
|
|
import org.nl.system.service.user.dto.UserQuery; |
|
|
|
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; |
|
|
@ -48,7 +53,9 @@ public class MobileAuthorizationController { |
|
|
|
private ISysUserService userService; |
|
|
|
@Autowired |
|
|
|
private ISysRoleService roleService; |
|
|
|
@ApiOperation("登录授权") |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
@PostMapping(value = "/login") |
|
|
|
@SaIgnore |
|
|
|
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception { |
|
|
@ -67,7 +74,14 @@ public class MobileAuthorizationController { |
|
|
|
if (!userInfo.getIs_used()) { |
|
|
|
throw new BadRequestException("账号未激活"); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(authUser.getRegin_code())){ |
|
|
|
Object regin_code = redisUtils.get("JT_"+authUser.getUsername()); |
|
|
|
if (regin_code!=null){ |
|
|
|
throw new BadRequestException("当前设备工序已经登陆,无法继续选择"); |
|
|
|
}else { |
|
|
|
redisUtils.set("JT_"+authUser.getUsername(),authUser.getRegin_code()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 登录输入,登出删除
|
|
|
|
CurrentUser user = new CurrentUser(); |
|
|
|
user.setId(userInfo.getUser_id()); |
|
|
@ -105,4 +119,14 @@ public class MobileAuthorizationController { |
|
|
|
return ResponseEntity.ok(authInfo); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/loginOut") |
|
|
|
@SaIgnore |
|
|
|
@Log("PC登出") |
|
|
|
public ResponseEntity<Object> loginOut(@Validated @RequestBody AuthUserDto authUser){ |
|
|
|
// 密码解密 - 前端的加密规则: encrypt(根据实际更改)
|
|
|
|
redisUtils.del("JT_"+authUser.getUsername()); |
|
|
|
return new ResponseEntity(TableDataInfo.build(),HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|