Commit 264e7e4d7fa19b53e6ecad7732b6338ff4e3e5dd

Authored by shiyang
1 parent 72534067fc
Exists in master

PC、小程序密码登录加密处理

Showing 2 changed files with 14 additions and 2 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/DoctorController.java View file @ 264e7e4
... ... @@ -16,6 +16,7 @@
16 16 import com.lyms.talkonlineweb.util.StringUtil;
17 17 import lombok.extern.log4j.Log4j2;
18 18 import org.springframework.beans.factory.annotation.Autowired;
  19 +import org.springframework.util.DigestUtils;
19 20 import org.springframework.util.StringUtils;
20 21 import org.springframework.validation.BindingResult;
21 22 import org.springframework.validation.annotation.Validated;
... ... @@ -146,7 +147,9 @@
146 147  
147 148 return baseResponse;
148 149 }
149   -
  150 + if(StringUtil.isNotEmpty(doctor.getDpasswd())) {
  151 + doctor.setDpasswd(DigestUtils.md5DigestAsHex(doctor.getDpasswd().getBytes()));
  152 + }
150 153 boolean f=lymsDoctorService.saveOrUpdate(doctor);
151 154 lymsLogsCrud(doctor,did);
152 155 baseResponse.setErrorcode(f==true?0:1);
... ... @@ -181,6 +184,9 @@
181 184 @PostMapping("loginDoctor")
182 185 public BaseResponse loginDoctor(@RequestBody LymsDoctor doctor){
183 186 BaseResponse baseResponse=new BaseResponse();
  187 + if(StringUtil.isNotEmpty(doctor.getDpasswd())){
  188 + doctor.setDpasswd(DigestUtils.md5DigestAsHex(doctor.getDpasswd().getBytes()));
  189 + }
184 190 List<LymsDoctor> dLst=lymsDoctorService.list(Wrappers.query(doctor));
185 191 baseResponse.setErrorcode(1);
186 192 if (dLst.size()>0) {
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java View file @ 264e7e4
... ... @@ -251,6 +251,9 @@
251 251 boolean f=false;
252 252 if(Objects.nonNull(patient.getId()) ){
253 253 patient.setUpdatedtime(new Date());
  254 + if(StringUtil.isNotEmpty(patient.getPpasswd())) {
  255 + patient.setPpasswd(DigestUtils.md5DigestAsHex(patient.getPpasswd().getBytes()));
  256 + }
254 257 f=lymsPatientService.saveOrUpdate(patient);
255 258 }
256 259 baseResponse.setErrorcode(f==true?0:1);
... ... @@ -894,7 +897,7 @@
894 897 public BaseResponse updatePatientPassword(@RequestBody LymsPatient patient){
895 898 BaseResponse baseResponse=new BaseResponse();
896 899 if(1==patient.getType()){//1 重置密码
897   - patient.setPpasswd(Constant.COMMON_PASSWD);
  900 + patient.setPpasswd(DigestUtils.md5DigestAsHex(Constant.COMMON_PASSWD.getBytes()));
898 901 }
899 902 boolean f=lymsPatientService.updateById(patient);
900 903 baseResponse.setErrorcode(f==true?0:1);
... ... @@ -919,6 +922,9 @@
919 922 LymsPatient patient2 = lymsPatientService.getOne(Wrappers.query(tmpP).eq("idno", patient.getIdno()));
920 923 if (patient2 == null) {
921 924 patient.setCreatedtime(new Date());
  925 + if(StringUtil.isNotEmpty(patient.getPpasswd())){
  926 + patient.setPpasswd(DigestUtils.md5DigestAsHex(patient.getPpasswd().getBytes()));
  927 + }
922 928 boolean f = lymsPatientService.save(patient);
923 929 baseResponse.setErrorcode(0);
924 930 baseResponse.setErrormsg("注册成功!");