liubing 4 gadi atpakaļ
vecāks
revīzija
8c774ffa85

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -136,4 +136,21 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = BaseRequestMapping.BasePatient.updatePatientPw)
    @ApiOperation(value = "修改居民账号密码")
    public Envelop updateDoctorPw(@ApiParam(name = "id", value = "居民ID")
                                  @RequestParam(value = "id", required = true)String id,
                                  @ApiParam(name = "pw", value = "密码")
                                  @RequestParam(value = "pw", required = true)String pw,
                                  @ApiParam(name = "orgPw", value = "原密码")
                                  @RequestParam(value = "orgPw", required = false)String orgPw)throws Exception{
        Boolean isSuccess = patientService.updatePatientPw(id,pw,orgPw);
        if (isSuccess){
            return success(isSuccess);
        }else {
            return failed("修改失败,请检查原密码是否正确");
        }
    }
}

+ 19 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -16,6 +16,8 @@ import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
@ -187,4 +189,21 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        }
        patientLabelDao.save(labelDOList);
    }
    public Boolean updatePatientPw(String id,String pw,String orgPw){
        BasePatientDO patientDO = patientDao.findOne(id);
        String orgPwMd5 = MD5.md5Hex(orgPw + "{" + patientDO.getSalt() + "}");
        if(!orgPwMd5.equals(patientDO.getPassword())){
            return false;
        }
        String salt = randomString(5);
        patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        patientDO.setSalt(salt);
        patientDao.save(patientDO);
        /*//设置更新时间
        saveDoctorPwlimitDate(id);*/
        return true;
    }
}