|
@@ -4,15 +4,15 @@ package com.ebei.device.asset.weixin.contorller;
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
import com.ebei.device.asset.weixin.auth.AuthUtils;
|
|
|
+import com.ebei.device.asset.weixin.constant.Constants;
|
|
|
+import com.ebei.device.asset.weixin.model.entity.AssetTask;
|
|
|
import com.ebei.device.asset.weixin.model.entity.AssetTenantUser;
|
|
|
+import com.ebei.device.asset.weixin.model.vo.AssetTenantUserVO;
|
|
|
import com.ebei.device.asset.weixin.service.AssetTenantUserService;
|
|
|
import com.ebei.device.asset.weixin.service.UserSessionManager;
|
|
|
import com.ebei.device.asset.weixin.util.MD5;
|
|
|
import com.ebei.device.asset.weixin.util.ResponseEx;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -38,33 +38,26 @@ public class LoginController {
|
|
|
@Autowired
|
|
|
private UserSessionManager userSessionManager;
|
|
|
|
|
|
- @ApiOperation(value = "登陆校验", notes = "登陆校验")
|
|
|
- @ApiImplicitParams({ @ApiImplicitParam(name = "userAccount", value = "登录名", required = true, paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query") })
|
|
|
- @GetMapping("getCheckedLoginInfo")
|
|
|
- public ResponseEx<Object> getCheckedLoginInfo(@RequestParam String userAccount, @RequestParam String password) {
|
|
|
- return postCheckedLoginInfo(userAccount, password);
|
|
|
- }
|
|
|
|
|
|
@ApiOperation(value = "安全登陆校验", notes = "安全登陆校验")
|
|
|
- @ApiImplicitParams({ @ApiImplicitParam(name = "userAccount", value = "登录名", required = true, paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query") })
|
|
|
@PostMapping("postCheckedLoginInfo")
|
|
|
- public ResponseEx<Object> postCheckedLoginInfo(@RequestParam String userAccount, @RequestParam String password) {
|
|
|
+ public ResponseEx<Object> postCheckedLoginInfo(@RequestBody @ApiParam(name = "assetTenantUserVO", value = "{userAccount:111,pwd:111}", required = true) AssetTenantUserVO assetTenantUserVO) {
|
|
|
|
|
|
ResponseEx<Object> resultResponse = ResponseEx.createError("登录失败");
|
|
|
- if ((userAccount != null && password != null) && (!"".equals(userAccount) && !"".equals(password))) {
|
|
|
+
|
|
|
+ String userAccount = assetTenantUserVO.getUserAccount();
|
|
|
+ String pwd = assetTenantUserVO.getPwd();
|
|
|
+ if ((userAccount != null && assetTenantUserVO.getPwd() != null) && (!"".equals(assetTenantUserVO.getUserAccount()) && !"".equals(pwd))) {
|
|
|
Wrapper wrapper = new EntityWrapper(new AssetTenantUser(userAccount));
|
|
|
AssetTenantUser assetTenantUser = assetTenantUserService.selectOne(wrapper);
|
|
|
|
|
|
-
|
|
|
/*校验用户登录信息-------------------开始*/
|
|
|
boolean isOk = false;
|
|
|
if (null != assetTenantUser) {
|
|
|
- String pwd = assetTenantUser.getPwd();
|
|
|
- String md5comparePwd = new MD5().getMD5ofStr(password);
|
|
|
+ String pwdReal = assetTenantUser.getPwd();
|
|
|
+ String md5comparePwd = new MD5().getMD5ofStr(pwdReal);
|
|
|
if (null != pwd) {
|
|
|
- if (pwd.equals(password) || pwd.equals(md5comparePwd)) {
|
|
|
+ if (pwdReal.equals(pwd) || pwd.equals(md5comparePwd)) {
|
|
|
isOk = true;
|
|
|
}
|
|
|
}
|
|
@@ -122,30 +115,30 @@ public class LoginController {
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "修改密码", notes = "修改密码")
|
|
|
- @GetMapping("updatePassword")
|
|
|
- public ResponseEx<Object> updatePassword(@RequestParam String userAccount, @RequestParam String oldPassword, @RequestParam String newPassword) {
|
|
|
-
|
|
|
- AssetTenantUser assetTenantUser = new AssetTenantUser(userAccount);
|
|
|
+ @PostMapping("updatePassword")
|
|
|
+ public ResponseEx<Object> updatePassword(@RequestBody @ApiParam(name = "assetTenantUserVO", value = "{userAccount:111,pwd:111,newPwd:1111}", required = true)
|
|
|
+ AssetTenantUserVO assetTenantUserVO) {
|
|
|
+ AssetTenantUser assetTenantUser = new AssetTenantUser(assetTenantUserVO.getUserAccount());
|
|
|
Wrapper<AssetTenantUser> wrapper = new EntityWrapper<>(assetTenantUser);
|
|
|
+ wrapper.eq("user_account",assetTenantUserVO.getUserAccount());
|
|
|
+ wrapper.eq("state", Constants.FLAG_IS_YES);
|
|
|
assetTenantUser = assetTenantUserService.selectOne(wrapper);
|
|
|
boolean isOk = false;
|
|
|
String pwd = assetTenantUser.getPwd();
|
|
|
- String md5comparePwd = new MD5().getMD5ofStr(oldPassword);
|
|
|
+ String md5comparePwd = new MD5().getMD5ofStr(pwd);
|
|
|
if (null != pwd) {
|
|
|
- if (pwd.equals(oldPassword) || pwd.equals(md5comparePwd)) {
|
|
|
+ if (pwd.equals(assetTenantUserVO.getPwd()) || md5comparePwd.equals(assetTenantUserVO.getPwd())) {
|
|
|
isOk = true;
|
|
|
}
|
|
|
}
|
|
|
if (isOk){
|
|
|
userSessionManager.clearToken(assetTenantUser.getToken(),true);
|
|
|
-
|
|
|
- assetTenantUser.setPwd(newPassword);
|
|
|
+ assetTenantUser.setPwd(assetTenantUserVO.getNewPwd());
|
|
|
assetTenantUser.setToken(null);
|
|
|
assetTenantUserService.updateById(assetTenantUser);
|
|
|
-
|
|
|
return ResponseEx.createSuccess("修改成功");
|
|
|
}else {
|
|
|
- return ResponseEx.createError("登陆失败,用户名或密码错误!");
|
|
|
+ return ResponseEx.createError("修改密码失败,用户名或密码错误!");
|
|
|
}
|
|
|
|
|
|
}
|