소스 검색

注册新增密码

esb 8 년 전
부모
커밋
f37cbd0cce

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -52,6 +52,6 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
	@Query(" select p from Patient p,SignFamily s where p.code=s.patient and s.status > 0 ")
	List<Patient> findAllSignPatient();
	@Query(" select p from Patient p where p.password is null and p.idcard is not null ")
	@Query(" select p from Patient p ")
	List<Patient> findAllIdCardPatientAndNoPassword();
}

+ 14 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.MD5;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -205,7 +206,13 @@ public class WechatController extends WeixinBaseController {
     */
    @RequestMapping(value = "regist")
    @ResponseBody
    public String regist(String name, String idcard, String ssc, String mobile, String captcha, String openid) {
    public String regist(String name,
                         String idcard,
                         String ssc,
                         String mobile,
                         String captcha,
                         String openid,
                         String password) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空!");
@ -282,6 +289,12 @@ public class WechatController extends WeixinBaseController {
            patient.setName(name);
            patient.setIdcard(idcard);
            patient.setMobile(mobile);
            //增加密码
            String salt= UUID.randomUUID().toString().replace("-","");
            patient.setSalt(salt);
            password = RSAUtils.getInstance(patientService).decryptString(password);
            patient.setPassword(MD5.GetMD5Code(password+salt));
			patient.setSsc(ssc);
            patient.setOpenid(openid);
            JSONObject json = patientService.register(patient, openid, 3);

+ 27 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -1,11 +1,14 @@
package com.yihu.wlyy.web.data;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.util.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.UUID;
@ -21,14 +24,34 @@ public class DataHandingService {
    private DoctorDao doctorDao;
    @Transactional
    public String producePatientAndDoctorPasswor() {
    public String producePatientAndDoctorPassword() {
        int patientCount=0;
        int doctorCount=0;
        List<Patient> patients= patientDao.findAllIdCardPatientAndNoPassword();
        for (Patient patient:patients){
            String idCard= patient.getIdcard();
            if(!StringUtils.isEmpty(patient.getPassword())){
                continue;
            }
            String phone= patient.getPhone();
            String password=phone.substring(5);
            String salt= UUID.randomUUID().toString().replace("-","");
            patient.setSalt(salt);
            patient.setPassword(MD5.GetMD5Code(password+salt));
            patientCount++;
        }
        List<Doctor> doctors= doctorDao.findAllDoctors();
        for (Doctor doctor:doctors){
            if(!StringUtils.isEmpty(doctor.getPassword())){
                continue;
            }
            String phone= doctor.getMobile();
            String password=phone.substring(5);
            String salt= UUID.randomUUID().toString().replace("-","");
            doctor.setSalt(salt);
            doctor.setPassword(MD5.GetMD5Code(password+salt));
            doctorCount++;
        }
        return null;
        return "更新患者:"+patientCount+",更新医生:"+doctorCount;
    }
}

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -62,11 +62,11 @@ public class DataHandlingController extends BaseController {
     * 生成医生和患者表中有身份的用户的密码
     * @return
     */
    @RequestMapping(value = "producePatientAndDoctorPasswor")
    @RequestMapping(value = "producePatientAndDoctorPassword")
    @ResponseBody
    public String producePatientAndDoctorPasswor() {
        try {
            return write(200, dataHandingService.producePatientAndDoctorPasswor());
            return write(200, dataHandingService.producePatientAndDoctorPassword());
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());