|
@ -1,19 +1,33 @@
|
|
package com.yihu.wlyy.web.gateway.controller;
|
|
package com.yihu.wlyy.web.gateway.controller;
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
|
import com.yihu.wlyy.entity.login.LoginLog;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
|
import com.yihu.wlyy.entity.security.Token;
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
|
import com.yihu.wlyy.service.common.account.RoleService;
|
|
|
|
import com.yihu.wlyy.service.common.account.TokenService;
|
|
|
|
import com.yihu.wlyy.service.common.login.LoginLogService;
|
|
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
|
import com.yihu.wlyy.util.RSAUtils;
|
|
import com.yihu.wlyy.web.gateway.vo.DoctorModel;
|
|
import com.yihu.wlyy.web.gateway.vo.DoctorModel;
|
|
import com.yihu.wlyy.web.gateway.vo.PatientModel;
|
|
import com.yihu.wlyy.web.gateway.vo.PatientModel;
|
|
|
|
import com.yihu.wlyy.web.gateway.vo.base.BaseResultModel;
|
|
import com.yihu.wlyy.web.gateway.vo.base.ResultOneModel;
|
|
import com.yihu.wlyy.web.gateway.vo.base.ResultOneModel;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by chenweida on 2017/8/17.
|
|
* Created by chenweida on 2017/8/17.
|
|
*/
|
|
*/
|
|
@ -25,6 +39,13 @@ public class GcUserController {
|
|
private DoctorService doctorService;
|
|
private DoctorService doctorService;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientService patientService;
|
|
private PatientService patientService;
|
|
|
|
@Autowired
|
|
|
|
private TokenService tokenService;
|
|
|
|
@Autowired
|
|
|
|
private LoginLogService loginLogService;
|
|
|
|
@Autowired
|
|
|
|
private RoleService roleService;
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/doctor", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/doctor", method = RequestMethod.GET)
|
|
@ApiOperation("根据医生code查询医生信息")
|
|
@ApiOperation("根据医生code查询医生信息")
|
|
@ -48,5 +69,38 @@ public class GcUserController {
|
|
return new ResultOneModel(patientModel);
|
|
return new ResultOneModel(patientModel);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 医生登录接口
|
|
|
|
*
|
|
|
|
* @param account 手机号或者身份证号
|
|
|
|
* @param password 密码
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "doctorLogin", method = RequestMethod.POST)
|
|
|
|
@ApiOperation("医生端登陆")
|
|
|
|
public BaseResultModel doctor(
|
|
|
|
@ApiParam(name = "password", value = "密码", required = true) @RequestParam(required = true, value = "password") String password,
|
|
|
|
@ApiParam(name = "account", value = "账号", required = true) @RequestParam(required = true, value = "account") String account) {
|
|
|
|
Doctor doctor = doctorService.findbyIdCard(account);
|
|
|
|
if (doctor == null) {
|
|
|
|
doctor = doctorService.findDoctorByMobile(account);
|
|
|
|
}
|
|
|
|
//账号不存在
|
|
|
|
if (doctor == null) {
|
|
|
|
return new BaseResultModel(BaseResultModel.codeEm.login_account_error.getCode(), BaseResultModel.codeEm.login_account_error.getMessage());
|
|
|
|
}
|
|
|
|
//密码错误
|
|
|
|
if (!doctor.getPassword().equals(MD5.GetMD5Code(password + doctor.getSalt()))) {
|
|
|
|
return new BaseResultModel(BaseResultModel.codeEm.login_password_error.getCode(), BaseResultModel.codeEm.login_password_error.getMessage());
|
|
|
|
}
|
|
|
|
Token token = tokenService.findDoctorToken(doctor.getCode());
|
|
|
|
//判断是否存在token
|
|
|
|
if (token!=null){
|
|
|
|
//如果token存在直接返回现有的token
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|