Browse Source

登录接口版本恢复

zsf 1 year ago
parent
commit
446ad92395
1 changed files with 69 additions and 284 deletions
  1. 69 284
      src/main/java/com/rf/psychological/user/rest/SystemController.java

+ 69 - 284
src/main/java/com/rf/psychological/user/rest/SystemController.java

@@ -4,23 +4,16 @@ import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.rf.psychological.base.rest.BaseController;
-import com.rf.psychological.dao.model.AnswerEntity;
-import com.rf.psychological.dao.model.DimensionEntity;
 import com.rf.psychological.enums.UserRole;
-import com.rf.psychological.enums.UserStatus;
 import com.rf.psychological.group.dao.model.GroupEntity;
 import com.rf.psychological.group.service.GroupInfoService;
+import com.rf.psychological.user.dao.model.UserEntity;
+import com.rf.psychological.enums.UserStatus;
 import com.rf.psychological.institution.model.InstitutionEntity;
 import com.rf.psychological.institution.service.InstitutionService;
-import com.rf.psychological.module.index.service.IndexService;
-import com.rf.psychological.scale.dao.model.ScaleEntity;
-import com.rf.psychological.scale.dao.model.ScaleMarksEntity;
-import com.rf.psychological.scale.dao.model.SubjectEntity;
-import com.rf.psychological.scale.service.*;
+import com.rf.psychological.opLog.annotation.OperationLogAnnotation;
 import com.rf.psychological.security.AesEncryptUtils;
-import com.rf.psychological.security.DESede;
 import com.rf.psychological.security.SafetyProcess;
-import com.rf.psychological.user.dao.model.UserEntity;
 import com.rf.psychological.user.service.SystemService;
 import com.rf.psychological.user.service.UserService;
 import com.rf.psychological.utils.Constant;
@@ -28,19 +21,16 @@ import com.rf.psychological.utils.JWTUtil;
 import com.rf.psychological.utils.Result;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.event.SpringApplicationEvent;
 import org.springframework.core.env.Environment;
-import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.util.DigestUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 
-import java.util.concurrent.TimeUnit;
-
 import static cn.hutool.core.date.DatePattern.PURE_DATETIME_PATTERN;
 
 /**
@@ -48,7 +38,6 @@ import static cn.hutool.core.date.DatePattern.PURE_DATETIME_PATTERN;
  * @Author: zsf
  * @Date: 2022/7/4
  */
-@Slf4j
 @RestController
 @RequestMapping("/system")
 @Api(tags = "后台首页、登录、版本等接口")
@@ -74,8 +63,7 @@ public class SystemController extends BaseController {
     @Autowired
     private Environment env;
 
-    @Autowired
-    private StringRedisTemplate redisTemplate;
+
     @GetMapping("/getVersion")
     @SafetyProcess
     public Result getSystemVersion(){
@@ -90,7 +78,8 @@ public class SystemController extends BaseController {
      * @return
      */
     @PostMapping("/registerUser")
-    @ApiOperation(value = "用户注册",notes = "json字符串形式传参(加密),data参数包括:data:注册用户基本信息《birthday:生日,gender:性别,password:密码,roleType:角色,institutionNo:机构编号,phone:账号或电话》,authCode:验证码(公网版必填)")
+    @ApiOperation(value = "用户注册",notes = "json字符串形式传参(加密),data参数包括:data:注册用户基本信息《birthday:生日,gender:性别,password:密码,roleType:角色,institutionNo:机构编号,phone:账号或电话》,authCode:验证码(公网版必填)," +
+            "verification:验证信息《beginTime:时间,authCode:验证码,phone:电话》")
     @SafetyProcess
     public Result registerUser(@RequestBody String jsonParam){
         try {
@@ -98,6 +87,7 @@ public class SystemController extends BaseController {
             JSONObject jsonData = JSONObject.parseObject(data);
             JSONObject jsonUserEntity =jsonData.getJSONObject("data");
             UserEntity userEntity = jsonUserEntity.toJavaObject(UserEntity.class);
+            userEntity.setModel(Constant.DEFAULT_VALUE_ZERO);
             String institutionNo = userEntity.getInstitutionNo();
             if (StringUtils.isEmpty(institutionNo)){
                 return fail("","机构编号不能为空");
@@ -118,37 +108,26 @@ public class SystemController extends BaseController {
             //区分是否需要验证码
             if (Constant.WEB_INSTITUTION_CODE.equals(userEntity.getInstitutionNo())){
                 String authCode = jsonData.getString("authCode");
-                if (StringUtils.isEmpty(authCode)){
-                    return fail("","验证码不能为空");
+                JSONObject jsonVerification = jsonData.getJSONObject("verification");
+                String jsonPhone = jsonVerification.getString("phone");
+                String jsonAuthCode = jsonVerification.getString("authCode");
+                String jsonBeginTime = jsonVerification.getString("beginTime");
+                if (StringUtils.isEmpty(jsonBeginTime)  || StringUtils.isEmpty(jsonAuthCode) ) {
+                    return fail("", "请重新获取验证码");
                 }
-                String phone = userEntity.getPhone();
-//                JSONObject jsonVerification = jsonData.getJSONObject("verification");
-//                String jsonPhone = jsonVerification.getString("phone");
-//                String jsonAuthCode = jsonVerification.getString("authCode");
-//                String jsonBeginTime = jsonVerification.getString("beginTime");
-//                if (StringUtils.isEmpty(jsonBeginTime)  || StringUtils.isEmpty(jsonAuthCode) ) {
-//                    return fail("", "请重新获取验证码");
-//                }
                 //计算时间差---分钟
                 //int diff = DateUtil.getDistanceByUnit(DateUtil.parseDate(jsonBeginTime,DateUtil.ACCURACY_PATTERN_MINUTE), DateUtil.getCurrentDate(), 2);
-//                long diff = DateUtil.between(DateUtil.date(), DateUtil.parse(jsonBeginTime,PURE_DATETIME_PATTERN), DateUnit.MINUTE);
-//                if (diff < 0 || diff > 5) {
-//                    return fail("", "验证码已失效");
-//                }
-                String temp = redisTemplate.opsForValue().get("AUTH_CODE_"+phone);
-                if(StringUtils.isBlank(temp)){
-                    return fail("请重新获取验证码");
+                long diff = DateUtil.between(DateUtil.date(), DateUtil.parse(jsonBeginTime,PURE_DATETIME_PATTERN), DateUnit.MINUTE);
+                if (diff < 0 || diff > 5) {
+                    return fail("", "验证码已失效");
                 }
-                if (!temp.equals(authCode)) {
+                if (!jsonAuthCode.equals(authCode) || !jsonPhone.equals(userEntity.getPhone()) ) {
                     return fail("", "验证码错误");
                 }
                 userEntity.setUserStatus(UserStatus.PASS.getType());
             }
             UserEntity userInfo = this.userService.findPhoneAndInstitutionNoAndRoleType(userEntity.getPhone(), userEntity.getInstitutionNo(),userEntity.getRoleType());
             if (userInfo == null) {
-                if (Constant.LAN_INSTITUTION_CODE.equals(userEntity.getInstitutionNo())){
-                    userEntity.setUserStatus(Constant.USER_STATUS_NORMAL);
-                }
                 userEntity.setPassword(DigestUtils.md5DigestAsHex(userEntity.getPassword().getBytes()));
                 this.userService.save(userEntity);
                 return success();
@@ -161,213 +140,80 @@ public class SystemController extends BaseController {
         }
     }
     @SafetyProcess
-    @ApiOperation(value = "系统登录接口",notes = "data参数包括:phone:账号, password:密码,institutionNo:机构编号,roleType:用户角色,authCode:密码,verification:验证信息《beginTime:时间,authCode:验证码,phone:电话》")
+    @ApiOperation(value = "系统登录接口",notes = "data参数包括:phone:账号, password:密码,institutionNo:机构编号,roleType:用户角色")
     @PostMapping("/login")
     public Result login(HttpServletRequest request, @RequestBody String jsonParams){
         try {
             JSONObject jsonObject =JSONObject.parseObject( AesEncryptUtils.decrypt(JSONObject.parseObject(jsonParams).getString("data")));
-            log.info("jsonObject: " + jsonObject.toString());
-            if (!jsonObject.containsKey("institutionNo") || !jsonObject.containsKey("roleType") ||  StringUtils.isEmpty(jsonObject.getString("institutionNo")) || StringUtils.isEmpty( jsonObject.getString("roleType") )) {
-                return fail("", "机构编号和用户角色不能为空");
+            if (!jsonObject.containsKey("phone") || !jsonObject.containsKey("password") || !jsonObject.containsKey("institutionNo")|| !jsonObject.containsKey("roleType")) {
+                return fail("", "账号或密码或所属机构不能为空");
             }
+            String password = jsonObject.getString("password");
+            String phone = jsonObject.getString("phone");
             String institutionNo = jsonObject.getString("institutionNo");
             String roleType = jsonObject.getString("roleType");
-
-
-            if (!jsonObject.containsKey("phone") || StringUtils.isEmpty(jsonObject.getString("phone")) ) {
-                return fail("", "账号不能为空");
-            }
-            String phone = jsonObject.getString("phone");
-            log.info("phone: " + phone);
-            //判断机构编号是否存在
-            InstitutionEntity institutionEntity = this.institutionService.findByInstitutionNo(institutionNo);
-            log.info("institutionEntity: " + institutionEntity);
-            if (institutionEntity == null) {
-                return fail("", "机构编号不存在!");
+            if (StringUtils.isEmpty(password) || StringUtils.isEmpty( phone )) {
+                return fail("", "账号或密码不能为空");
             }
             UserEntity userEntity = this.userService.findPhoneAndInstitutionNoAndRoleType(phone, institutionNo,roleType);
+            if (userEntity == null) {
+                return fail(null, "机构编号或账号错误");
+            }
+            String userStatus = userEntity.getUserStatus();
 
-            log.info("userEntity: " + userEntity);
-            //如果是公网版并且验证码登录
-            if (Constant.WEB_INSTITUTION_CODE.equals(institutionNo) && jsonObject.containsKey("authCode")){
-                if (userEntity == null) {
-                    return fail(null, "用户不存在");
-                }
-                String authCode = jsonObject.getString("authCode");
-                if (StringUtils.isEmpty(authCode)){
-                    return fail("","验证码不能为空");
-                }
-                String temp = redisTemplate.opsForValue().get("AUTH_CODE_" + phone);
-                if(StringUtils.isBlank(temp)){
-                    return fail("", "验证码已失效");
-                }
-                if (temp.equals(authCode)) {
-                    //生成token
-                    userEntity.setPassword(null);
-                    String token = JWTUtil.getTokenByUserInfo(userEntity);
-                    // 创建返回的json对象
-                    JSONObject resultJson = new JSONObject();
-                    resultJson.put("user", userEntity);
-                    resultJson.put("type", userEntity.getRoleType());
-                    resultJson.put("token", token);
-                    request.getSession().setAttribute("user", userEntity);
-                    return success(resultJson);
-                } else {
-                    return fail("", "验证码错误");
-                }
-            }else if ("lan".equals(profileValue)){
-                if (!jsonObject.containsKey("password") || StringUtils.isEmpty(  jsonObject.getString("password") )) {
-                    return fail("", "密码不能为空");
-                }
-                String password = jsonObject.getString("password");
-                if (userEntity == null) {
-                    if (Constant.LAN_INSTITUTION_CODE.equals(institutionNo)){
-                        return fail(null, "账号或密码错误");
-                    }
-                    return fail(null, "账号错误");
-                }
-                String userStatus = userEntity.getUserStatus();
-                if (UserStatus.AUDIT.getType().equals(userStatus)||UserStatus.UPDATE.getType().equals(userStatus)){
-                    return fail(null, "用户未审核,请联系管理员");
-                }
-                if (userEntity.getPassword().equals(password)) {
-                    //生成token
-                    userEntity.setPassword(null);
-                    String token = JWTUtil.getTokenByUserInfo(userEntity);
-                    // 创建返回的json对象
-                    JSONObject resultJson = new JSONObject();
-                    resultJson.put("user", userEntity);
-                    resultJson.put("type", userEntity.getRoleType());
-                    resultJson.put("token", token);
-                    request.getSession().setAttribute("user", userEntity);
-                    return success(resultJson);
-                } else {
-                    return fail(null, "账号或密码错误");
-                }
-            }else {
-                if (!jsonObject.containsKey("password") || StringUtils.isEmpty(  jsonObject.getString("password") )) {
-                    return fail("", "密码不能为空");
-                }
-                String password = jsonObject.getString("password");
-                if (userEntity == null) {
-                    if (Constant.LAN_INSTITUTION_CODE.equals(institutionNo)){
-                        return fail(null, "账号或密码错误");
-                    }
-                    return fail(null, "机构编号或账号错误");
-                }
-                String userStatus = userEntity.getUserStatus();
-                if (UserStatus.AUDIT.getType().equals(userStatus)||UserStatus.UPDATE.getType().equals(userStatus)){
-                    return fail(null, "用户未审核,请联系管理员");
-                }
-                if (userEntity.getPassword().equals(password)) {
-                    //生成token
-                    userEntity.setPassword(null);
-                    String redisToken = redisTemplate.opsForValue().get("session:"+userEntity.getInstitutionNo()+":"+userEntity.getPhone()+":"+userEntity.getRoleType());
-                    String token = redisToken;
-
-                    //验证token是否有效
-                    try {
-                        JWTUtil.verify(token);
-                    }catch (Exception e){
-                        e.printStackTrace();
-                        token = JWTUtil.getTokenByUserInfo(userEntity);
-                        redisTemplate.opsForValue().set("session:"+userEntity.getInstitutionNo()+":"+userEntity.getPhone()+":"+userEntity.getRoleType(),token,5, TimeUnit.DAYS);
-                    }
-
-                    // 创建返回的json对象
-                    JSONObject resultJson = new JSONObject();
-                    resultJson.put("user", userEntity);
-                    resultJson.put("type", userEntity.getRoleType());
-                    resultJson.put("token", token);
-                    request.getSession().setAttribute("user", userEntity);
-                    return success(resultJson);
-                } else {
-                    return fail(null, "账号或密码错误");
-                }
+            if (UserStatus.AUDIT.getType().equals(userStatus)||UserStatus.UPDATE.getType().equals(userStatus)){
+                return fail(null, "用户未审核,请联系管理员");
             }
+            if (userEntity.getPassword().equals(password)) {
 
+                //生成token
+                userEntity.setPassword(null);
+                String token = JWTUtil.getTokenByUserInfo(userEntity);
+                // 创建返回的json对象
+                JSONObject resultJson = new JSONObject();
+                resultJson.put("user", userEntity);
+                resultJson.put("type", userEntity.getRoleType());
+                resultJson.put("token", token);
+                request.getSession().setAttribute("user", userEntity);
+                return success(resultJson);
+            } else {
+                return fail(null, "账号或密码错误");
+            }
         }catch (Exception e){
             e.printStackTrace();
             return fail();
         }
     }
 
-
     @SafetyProcess
-    @ApiOperation(value = "系统登录接口",notes = "data参数包括:phone:账号,institutionNo:机构编号,roleType:用户角色,authCode:密码,verification:验证信息《beginTime:时间,authCode:验证码,phone:电话》")
-    @PostMapping("/loginH5")
-    public Result loginH5(HttpServletRequest request, @RequestBody String jsonParams){
+    @ApiOperation(value = "管理员登录接口",notes = "data参数包括:phone:账号, password:密码")
+    @PostMapping("/adminLogin")
+    public Result adminLogin(HttpServletRequest request,@RequestBody String jsonParams){
         try {
             JSONObject jsonObject =JSONObject.parseObject( AesEncryptUtils.decrypt(JSONObject.parseObject(jsonParams).getString("data")));
-            log.info("jsonObject: " + jsonObject.toString());
-            if (!jsonObject.containsKey("institutionNo") || !jsonObject.containsKey("roleType") ||  StringUtils.isEmpty(jsonObject.getString("institutionNo")) || StringUtils.isEmpty( jsonObject.getString("roleType") )) {
-                return fail("", "机构编号和用户角色不能为空");
-            }
-            String institutionNo = jsonObject.getString("institutionNo");
-            String roleType = jsonObject.getString("roleType");
-            if (!jsonObject.containsKey("phone") || StringUtils.isEmpty(jsonObject.getString("phone")) ) {
-                return fail("", "账号不能为空");
+            if (!jsonObject.containsKey("phone") || !jsonObject.containsKey("password") ) {
+                return fail("", "账号或密码不能为空");
             }
+            String password = jsonObject.getString("password");
             String phone = jsonObject.getString("phone");
-            log.info("phone: " + phone);
-            //判断机构编号是否存在
-            InstitutionEntity institutionEntity = this.institutionService.findByInstitutionNo(institutionNo);
-            log.info("institutionEntity: " + institutionEntity);
-            if (institutionEntity == null) {
-                return fail("", "机构编号不存在!");
+            String roleType = jsonObject.getString("roleType");
+            if (StringUtils.isEmpty(password) || StringUtils.isEmpty( phone )) {
+                return fail("", "账号或密码不能为空");
             }
-            UserEntity userEntity = this.userService.findPhoneAndInstitutionNoAndRoleType(phone, institutionNo,roleType);
-            log.info("userEntity: " + userEntity);
-            //如果是公网版并且验证码登录
+            UserEntity userEntity = this.userService.findByPhoneAndPassword(phone, password,roleType);
             if (userEntity == null) {
-                userEntity = new UserEntity();
-                userEntity.setPassword(DigestUtils.md5DigestAsHex(Constant.DEFAULT_PASSWORD.getBytes()));
-                userEntity.setGId(this.groupInfoService.findGroupByInstitutionNoAndName(Constant.WEB_INSTITUTION_CODE,Constant.DEFAULT_GROUP_NAME).getId());
-                userEntity.setInstitutionName(Constant.WEB_INSTITUTION_NAME);
-                userEntity.setInstitutionNo(Constant.WEB_INSTITUTION_CODE);
-                userEntity.setUserStatus(Constant.USER_STATUS_NORMAL);
-                userEntity.setBirthday("-");
-                userEntity.setGender("-");
-                userEntity.setPetName(phone);
-                userEntity.setProfession("-");
-                userEntity.setPhone(phone);
-                userEntity.setRoleType(UserRole.COMMON.getType());
-                userEntity = this.userService.save(userEntity);
-            }
-            String authCode = jsonObject.getString("authCode");
-            if (StringUtils.isEmpty(authCode)){
-                return fail("","验证码不能为空");
-            }
-
-            String temp = redisTemplate.opsForValue().get("AUTH_CODE_" + phone);
-            if(StringUtils.isBlank(temp)){
-                return fail("", "验证码已失效");
-            }
-            if (temp.equals(authCode)) {
-                //生成token
-               // userEntity.setPassword(null);
-               // String token = JWTUtil.getTokenByUserInfo(userEntity);
-                //生成token
-                userEntity.setPassword(null);
-                String redisToken = redisTemplate.opsForValue().get("session:"+userEntity.getInstitutionNo()+":"+userEntity.getPhone()+":"+userEntity.getRoleType());
-                String token = redisToken;
-                try {
-                    JWTUtil.verify(token);
-                }catch (Exception e){
-                    e.printStackTrace();
-                    token = JWTUtil.getTokenByUserInfo(userEntity);
-                    redisTemplate.opsForValue().set("session:"+userEntity.getInstitutionNo()+":"+userEntity.getPhone()+":"+userEntity.getRoleType(),token,5, TimeUnit.DAYS);
-                }
-                // 创建返回的json对象
-                JSONObject resultJson = new JSONObject();
-                resultJson.put("user", userEntity);
-                resultJson.put("type", userEntity.getRoleType());
-                resultJson.put("token", token);
-                request.getSession().setAttribute("user", userEntity);
-                return success(resultJson);
-            } else {
-                return fail("", "验证码错误");
+                return fail(null, "账号或密码错误");
             }
+            //生成token
+            userEntity.setPassword(null);
+            String token = JWTUtil.getTokenByUserInfo(userEntity);
+            // 创建返回的json对象
+            JSONObject resultJson = new JSONObject();
+            resultJson.put("user", userEntity);
+            resultJson.put("type", userEntity.getRoleType());
+            resultJson.put("token", token);
+            request.getSession().setAttribute("user", userEntity);
+            return success(resultJson);
         }catch (Exception e){
             e.printStackTrace();
             return fail();
@@ -400,32 +246,7 @@ public class SystemController extends BaseController {
                 return fail("", "请先注册");
             }
             userEntity.setPassword(password);
-            //区分公网版和非公网版
-            if (Constant.WEB_INSTITUTION_CODE.equals(institutionNo)){
-                String authCode = dataParam.getString("authCode");
-                JSONObject jsonVerification = dataParam.getJSONObject("verification");
-                String jsonPhone = jsonVerification.getString("phone");
-                String jsonAuthCode = jsonVerification.getString("authCode");
-                String jsonBeginTime = jsonVerification.getString("beginTime");
-                if (StringUtils.isEmpty(jsonBeginTime ) || StringUtils.isEmpty(jsonAuthCode) ) {
-                    return fail("", "请重新获取验证码");
-                }
-                //计算时间差---分钟
-                //int diff = DateUtil.getDistanceByUnit(DateUtil.parseDate(jsonBeginTime), DateUtil.getCurrentDate(), 2);
-                long diff = DateUtil.between(DateUtil.date(), DateUtil.parse(jsonBeginTime,PURE_DATETIME_PATTERN), DateUnit.MINUTE);
-                if (diff < 0 || diff > 5) {
-                    return fail("", "验证码已失效");
-                }
-                if (jsonAuthCode.equals(authCode) && jsonPhone.equals(phone)) {
-                   // this.userService.updatePassword(phone, password, institutionNo,roleType);
-                    this.userService.save(userEntity);
-                } else {
-                    return fail("", "验证码错误");
-                }
-            }else {
-                this.userService.save(userEntity);
-               // this.userService.updatePassword(phone, password, institutionNo,roleType);
-            }
+            this.userService.save(userEntity);
             return success();
         }catch (Exception e){
             e.printStackTrace();
@@ -433,40 +254,6 @@ public class SystemController extends BaseController {
         }
     }
 
-    /**
-     * 登出
-     * @param jsonParam 参数
-     * @desc
-     * @return
-     */
-    @SafetyProcess
-    @ApiOperation(value = "登出",notes = "json字符串形式传参(加密),data参数包括:institutionNo:机构编号,phone:账号或电话,roleType:用户角色" )
-    @PostMapping("/logout")
-    public Result logout(@RequestBody String jsonParam){
-        try {
-            JSONObject dataParam = JSONObject.parseObject(AesEncryptUtils.decrypt(JSONObject.parseObject(jsonParam).getString("data")));
-            String phone = dataParam.getString("phone");
-            String institutionNo = dataParam.getString("institutionNo");
-            String roleType = dataParam.getString("roleType");
-            if ( StringUtils.isEmpty( phone)   || StringUtils.isEmpty( institutionNo ) ) {
-                return fail("", "请按要求填写所需信息");
-            }
-            //首先校验用户是否存在
-            UserEntity userEntity = userService.findPhoneAndInstitutionNoAndRoleType(phone,institutionNo,roleType);
-            if (userEntity == null){
-                return fail(null,"用户不存在");
-            }
-            if ("lan".equals(profileValue)){
-                return success();
-            }
-            boolean result = redisTemplate.delete("session:"+institutionNo+":"+phone+":"+roleType);
-            return success(result);
-        }catch (Exception e){
-            e.printStackTrace();
-            return fail();
-        }
-    }
-
     /**
      * 修改密码
      * @param jsonParam 待修改用户密码参数
@@ -478,12 +265,10 @@ public class SystemController extends BaseController {
     public Result updatePassword(@RequestBody String jsonParam){
         try {
             JSONObject jsonObject = JSONObject.parseObject(AesEncryptUtils.decrypt(JSONObject.parseObject(jsonParam).getString("data")));
-            if(!jsonObject.containsKey("id")|| StringUtils.isEmpty(jsonObject.getString("id"))) {
+            if(!jsonObject.containsKey("id")|| StringUtils.isEmpty(jsonObject.getString("id")))
                 return failBadRequest(null,"用户id不能为空!");
-            }
-            if(!jsonObject.containsKey("password")|| StringUtils.isEmpty(jsonObject.getString("password"))) {
+            if(!jsonObject.containsKey("password")|| StringUtils.isEmpty(jsonObject.getString("password")))
                 return failBadRequest(null,"登录密码不能为空!");
-            }
             String password =  jsonObject.getString("password");
             String oldPassword = jsonObject.getString("oldPassword");
             String id = jsonObject.getString("id");