Browse Source

CA认证修改密码

liuwenbin 7 years ago
parent
commit
f55c7a06f9

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java

@ -66,6 +66,7 @@ public class Doctor extends IdEntity {
    private Double evaluateScore;//评分
    private String checkPassword;   //审方密码
    private String checkSalt;       //审方密码的盐
    public Double getEvaluateScore() {
        return evaluateScore;
@ -405,4 +406,12 @@ public class Doctor extends IdEntity {
    public void setCheckPassword(String checkPassword) {
        this.checkPassword = checkPassword;
    }
    public String getCheckSalt() {
        return checkSalt;
    }
    public void setCheckSalt(String checkSalt) {
        this.checkSalt = checkSalt;
    }
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java

@ -154,4 +154,8 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
    @Query(value = "SELECT d.* from wlyy_admin_team a,wlyy_doctor d WHERE a.id = ?1 and a.leader_code = d.`code` ORDER BY d.id LIMIT 1",nativeQuery = true)
    Doctor findByAdminTeamId(Long adminTeamId);
    @Modifying
    @Query("update Doctor set checkPassword = ?2 ,checkSalt = ?3  where code = ?1")
    int updateCheckPassword(String code, String checkPassword, String checkSalt);
}

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

@ -47,9 +47,12 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.security.utils.Digests;
import org.springside.modules.utils.Encodes;
import java.util.*;
@ -1262,4 +1265,18 @@ public class DoctorInfoService extends BaseService {
            }
        }
    }
    /**
     * 审方密码设置
     * @param passwoed
     * @return
     */
    @Transactional
    public void setCheckPassword(Doctor doctor,String passwoed){
        byte[] salt = Digests.generateSalt(8);
        doctor.setCheckSalt(Encodes.encodeHex(salt));
        byte[] hashPassword = Digests.sha1(passwoed.getBytes(), salt, 1024);
        doctor.setCheckPassword(Encodes.encodeHex(hashPassword));
    }
}

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

@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springside.modules.security.utils.Digests;
import org.springside.modules.utils.Encodes;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
@ -1886,5 +1887,59 @@ public class DoctorController extends BaseController {
            return invalidUserException(e, -1, "查询失败");
        }
    }
    /**
     * 设置审方密码
     * @param password
     * @return
     */
    @RequestMapping(value = "/setCheckPassword", method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public String setCheckPassword(@RequestParam String password){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            if (doctor == null) {
                return error(-1, "密码设置失败!");
            }
            doctorInfoService.setCheckPassword(doctor,password);
            return write(200, "密码设置成功");
        }catch (Exception e){
            error(e);
            return invalidUserException(e, -1, "密码设置失败");
        }
    }
    /**
     * 修改审方密码
     * @param oldPassword
     * @param newPassword
     * @return
     */
    @ObserverRequired
    @ResponseBody
    @RequestMapping(value = "/updateCheckPassword", method = RequestMethod.POST)
    public String updateCheckPassword(@RequestParam String oldPassword,@RequestParam String newPassword){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            if (doctor == null) {
                return error(-1, "修改审方密码失败!");
            } else {
                String encodePWD = EncodesUtil.entryptPassword(Encodes.decodeHex(doctor.getCheckSalt()), oldPassword);
                if (StringUtils.equals(doctor.getCheckPassword(), encodePWD)) {
                    doctorInfoService.setCheckPassword(doctor,newPassword);
                    return write(200, "密码设置成功");
                } else {
                    return error(-1, "修改失败:审方旧密码错误!");
                }
            }
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "修改失败!");
        }
    }
}

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -111,7 +111,7 @@ public class PatientPrescriptionController extends WeixinBaseController {
            @RequestParam(value = "page",required = true) Integer page,
            @RequestParam(value = "pagesize",required = true) Integer pagesize) {
        //getUID()
        JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,"915cc456-5b1d-11e6-8344-fa163e8aee56",status,page,pagesize);
        JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,getUID(),status,page,pagesize);
        System.out.println(result.toString());
        return result.toString();
    }
@ -125,8 +125,8 @@ public class PatientPrescriptionController extends WeixinBaseController {
    //@ObserverRequired
    public String whetherHaveCode() {
        JSONObject json = new JSONObject();
        String patientCode = getRepUID();
        int count = prescriptionDispensaryCodeService.dispensaryCodeCount(patientCode);
//        String patientCode = getUID();
        int count = prescriptionDispensaryCodeService.dispensaryCodeCount(getUID());
        if (count > 0) {
            json.put("data", true);
            return json.toString();