esb %!s(int64=8) %!d(string=hai) anos
pai
achega
6dbedd691a

+ 4 - 87
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -215,90 +215,6 @@ public class LoginController extends BaseController {
        }
    }
    /**
     * 患者登录接口
     *
     * @param mobile  手机号
     * @param captcha 短信验证码
     * @param idcard  身份证号
     * @param password 密码
     * @return
     */
    @RequestMapping(value = "patient")
    @ResponseBody
    public String patient(
           @RequestParam(required = false) String mobile,
           @RequestParam(required = false) String captcha,
           @RequestParam(required = false) String idcard,
           @RequestParam(required = false) String password) {
        try {
            if (StringUtils.isEmpty(getIMEI())) {
                return error(-1, "获取手机IMEI码失败!");
            }
            //身份证登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                Patient patient= patientService.findByMobile(mobile);
                if(patient==null){
                    return error(-1, "该身份证未注册!");
                }
                String loginPassword= MD5.GetMD5Code(password+patient.getSalt());
                if(loginPassword.equals(patient.getPassword())){
                    Token token = tokenService.newToken(patient.getCode(), getIMEI(), 1);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", patient.getId());
                    map.put("uid", patient.getCode());
                    map.put("name", URLEncoder.encode(patient.getName(), "UTF-8"));
                    map.put("token", token.getToken());
                    map.put("photo", patient.getPhoto());
                    return write(200, "登录成功", "data", map);
                }else{
                    return error(-1, "密码错误,登录失败");
                }
            }
            //短信登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
                // 对验证码进行校验
                int res = smsService.check(mobile, 4, captcha);
                switch (res) {
                    case -2:
                        return error(-1, "验证码已过期!");
                    case -1:
                        return error(-1, "请输入正确的验证码!");
                    case 0:
                        return error(-1, "验证码无效!");
                }
                // password = URLDecoder.decode(password, "UTF-8");
                // password = StringUtils.reverse(password);
                // idcard = RSAUtils.getInstance(doctorService).decryptString(idcard);
                // idcard = URLDecoder.decode(idcard, "UTF-8");
                // idcard = StringUtils.reverse(idcard);
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    return error(-1, "该手机号暂未注册帐号,请确认后重新输入!");
                } else if (patient.getStatus() == 0) {
                    return error(-1, "该手机号已被禁止使用!");
                } else if (patient.getStatus() == 2) {
                    return error(-1, "该帐号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”");
                } else {
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(patient.getCode(), getIMEI(), 1);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", patient.getId());
                    map.put("uid", patient.getCode());
                    map.put("name", URLEncoder.encode(patient.getName(), "UTF-8"));
                    map.put("token", token.getToken());
                    map.put("photo", patient.getPhoto());
                    return write(200, "登录成功", "data", map);
                }
            }
            return error(-1, "登录信息不完整,请重新输入!");
        } catch (Exception e) {
            error(e);
            return error(-1, "系统异常,登录失败");
        }
    }
    /**
     * 忘记密码
     *
@ -347,7 +263,6 @@ public class LoginController extends BaseController {
                if (doctor == null) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=MD5.GetMD5Code(password+doctor.getSalt());
                    doctor.setPassword(password);
@ -356,11 +271,13 @@ public class LoginController extends BaseController {
                }
            } else {
                // 患者端
                Patient patient = patientService.findByIdcard(idcard);
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    patient.setPassword(newpwd);
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=MD5.GetMD5Code(password+patient.getSalt());
                    patient.setPassword(password);
                    patientService.updatePatientPwd(patient);
                    return success("操作成功!");
                }