Parcourir la source

新增修改密码

esb il y a 8 ans
Parent
commit
a8ccbfad66

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

@ -51,4 +51,7 @@ 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 ")
	List<Patient> findAllIdCardPatientAndNoPassword();
}

+ 17 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -30,6 +30,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientSickDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -730,4 +731,20 @@ public class DoctorInfoService extends BaseService {
        return 1;
    }
    @Transactional
    public void updatePassword(String newPassword1, String newPassword2, String oldPassword, String doctorCode) throws Exception{
        if(!newPassword1.equals(newPassword2)){
           throw new Exception("新密码不一致");
        }
        if(!newPassword1.equals(oldPassword)){
            throw new Exception("新旧密码一致");
        }
        Doctor doctor=doctorDao.findByCode(doctorCode);
        String oldPasswordTemp= MD5.GetMD5Code(oldPassword+doctor.getSalt());
        if(!oldPasswordTemp.equals(doctor.getPassword())){
            throw new Exception("旧密码错误");
        }
        String newPassword1Temp= MD5.GetMD5Code(newPassword1+doctor.getSalt());
        doctor.setPassword(newPassword1Temp);
    }
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -21,6 +21,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -180,4 +181,21 @@ public class PatientInfoService extends BaseService {
			throw  new Exception("手机号已经被注册");
		}
	}
	@Transactional
	public void updatePassword(String newPassword1, String newPassword2, String oldPassword, String patientCode) throws Exception{
		if(!newPassword1.equals(newPassword2)){
			throw new Exception("新密码不一致");
		}
		if(!newPassword1.equals(oldPassword)){
			throw new Exception("新旧密码一致");
		}
		Patient patient=patientDao.findByCode(patientCode);
		String oldPasswordTemp= MD5.GetMD5Code(oldPassword+patient.getSalt());
		if(!oldPasswordTemp.equals(patient.getPassword())){
			throw new Exception("旧密码错误");
		}
		String newPassword1Temp= MD5.GetMD5Code(newPassword1+patient.getSalt());
		patient.setPassword(newPassword1Temp);
	}
}

+ 34 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -0,0 +1,34 @@
package com.yihu.wlyy.web.data;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
/**
 * Created by Administrator on 2016.10.17.
 */
@Service
public class DataHandingService {
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Transactional
    public String producePatientAndDoctorPasswor() {
        int patientCount=0;
        List<Patient> patients= patientDao.findAllIdCardPatientAndNoPassword();
        for (Patient patient:patients){
            String idCard= patient.getIdcard();
            String salt= UUID.randomUUID().toString().replace("-","");
        }
        return null;
    }
}

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

@ -27,6 +27,8 @@ public class DataHandlingController extends BaseController {
    private FamilyContractService familyContractService;
    @Autowired
    private ConsultTeamService consultTeamService;
    @Autowired
    private DataHandingService dataHandingService;
    /**
     * 生成签约表中的行政团队的code
     */
@ -55,4 +57,19 @@ public class DataHandlingController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /**
     * 生成医生和患者表中有身份的用户的密码
     * @return
     */
    @RequestMapping(value = "producePatientAndDoctorPasswor")
    @ResponseBody
    public String producePatientAndDoctorPasswor() {
        try {
            return write(200, dataHandingService.producePatientAndDoctorPasswor());
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 24 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -1493,4 +1493,28 @@ public class DoctorController extends BaseController {
            return error(-1, "手机号更新失败");
        }
    }
    /**
     * 修改密码
     * @param newPassword1 新密码1
     * @param newPassword2 新密码2
     * @param oldPassword 旧密码
     * @param doctorCode 医生code
     * @return
     */
    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST )
    @ResponseBody
    public String updatePassword(String newPassword1,
                                           String newPassword2,
                                           String oldPassword,
                                           String doctorCode) {
        try {
            doctorInfoService.updatePassword(newPassword1, newPassword2, oldPassword,doctorCode);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/family/DoctorFamilyController.java

@ -33,7 +33,7 @@ public class DoctorFamilyController extends WeixinBaseController{
            JSONArray patients = familyService.getfamilyMember(patientCode,idcard,doctorCode);
            return write(200, "查询成功", "list", patients);
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }

+ 25 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -11,6 +11,7 @@ import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -19,6 +20,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -678,4 +680,27 @@ public class PatientController extends WeixinBaseController {
            return error(-1, "手机号更新失败");
        }
    }
    /**
     *  修改密码
     * @param newPassword1 新密码1
     * @param newPassword2 新密码2
     * @param oldPassword 旧密码
     * @param patientCode 患者code
     * @return
     */
    @RequestMapping(value = "/updatePassword",method = RequestMethod.POST)
    @ResponseBody
    public String updatePassword(String newPassword1,
                                 String newPassword2,
                                 String oldPassword,
                                 String patientCode) {
        try {
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword,patientCode);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}