|
@ -4,7 +4,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.security.Token;
|
|
|
import com.yihu.jw.entity.base.sms.SmsDO;
|
|
|
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
|
|
|
import com.yihu.jw.patient.dao.personal_info.PatientDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.service.personal_Info.PatientService;
|
|
|
import com.yihu.jw.patient.util.CommonUtils;
|
|
|
import com.yihu.jw.patient.util.ConstantUtils;
|
|
@ -24,11 +24,12 @@ import com.yihu.jw.util.security.MD5;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@ -47,21 +48,24 @@ import java.util.*;
|
|
|
@Api(value = "居民信息管理", description = "居民信息管理服务接口", tags = {"wlyy基础服务 - 居民信息管理服务接口"})
|
|
|
public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@Value("${sms.clientId}")
|
|
|
@Autowired
|
|
|
private PatientService patientService;
|
|
|
|
|
|
@Value("sms.clientId")
|
|
|
private String clientId;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseSmsGatewayService baseSmsGatewayService;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private PatientService patientService;
|
|
|
private BasePatientDao basePatientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private RSAService rsaService;
|
|
|
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseSmsService baseSmsService;
|
|
|
|
|
@ -86,67 +90,33 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
@ApiOperation("居民注册接口")
|
|
|
@RequestMapping(value = BaseRequestMapping.BasePatient.Regist, method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public Envelop regist(@ApiParam(value = "手机号", name = "mobile") @RequestParam(required = true)String mobile ,
|
|
|
public Envelop regist(@ApiParam(value = "手机号", name = "mobile") @RequestParam(required = true) String mobile,
|
|
|
@ApiParam(value = "验证码", name = "captcha") @RequestParam(value = "captcha", required = true) String captcha,
|
|
|
@ApiParam(value = "微信openId", name = "openid") @RequestParam(value = "openid", required = false) String openid,
|
|
|
@ApiParam(value = "密码", name = "password") @RequestParam(value = "password", required = false) String password) {
|
|
|
Envelop envelop = new Envelop();
|
|
|
|
|
|
boolean b = CommonUtils.isMobile(mobile);
|
|
|
if(!b){
|
|
|
if (!b) {
|
|
|
envelop.setMessage("手机号码格式不正确");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
//验证手机是否被注册
|
|
|
List<BasePatientDO> list = patientDao.findByMobileAndDel(mobile,"1");
|
|
|
if(list!=null && list.size()> 0){
|
|
|
List<BasePatientDO> list = basePatientDao.findByMobileAndDel(mobile, "1");
|
|
|
if (list != null && list.size() > 0) {
|
|
|
envelop.setMessage("该手机号已经注册!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}
|
|
|
// 对验证码进行校验
|
|
|
int res = baseSmsService.check(mobile, 0, captcha);
|
|
|
if(-2 == res){
|
|
|
envelop.setMessage("验证码已过期!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}else if(-1 == res){
|
|
|
envelop.setMessage("请输入正确的验证码!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}else if(0 == res){
|
|
|
envelop.setMessage("验证码无效!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
} else{
|
|
|
BasePatientDO patient = new BasePatientDO();
|
|
|
patient.setMobile(mobile);
|
|
|
if(StringUtils.isNotBlank(password)){
|
|
|
//增加密码
|
|
|
String salt = UUID.randomUUID().toString().replace("-", "");
|
|
|
patient.setSalt(salt);
|
|
|
password = rsaService.decryptString(password);
|
|
|
password = StringUtils.reverse(password);
|
|
|
if(password.length()<6 || password.length()>20){
|
|
|
envelop.setMessage("密码长度需为6-20位");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}
|
|
|
patient.setPassword(MD5.GetMD5Code(password + salt));
|
|
|
}
|
|
|
if(!"undefined".equals(openid) && StringUtils.isNotBlank(openid)){
|
|
|
patient.setOpenid(openid);
|
|
|
patient.setOpenidTime(new Date());
|
|
|
Map<String, Object> result = patientService.regis(mobile, captcha, password, openid);
|
|
|
if ("-1".equals(result.get("code"))) {
|
|
|
envelop.setStatus(-1);
|
|
|
envelop.setMessage(result.get("message") + "");
|
|
|
} else {
|
|
|
envelop.setStatus(200);
|
|
|
envelop.setMessage(result.get("message") + "");
|
|
|
}
|
|
|
patient.setDel("1");
|
|
|
patient.setPatientStatus("1");
|
|
|
patientService.save(patient);
|
|
|
envelop.setMessage("注册成功");
|
|
|
envelop.setStatus(200);
|
|
|
return envelop;
|
|
|
}
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -167,21 +137,21 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
Envelop envelop = new Envelop();
|
|
|
|
|
|
boolean b = CommonUtils.isMobile(mobile);
|
|
|
if(!b){
|
|
|
if (!b) {
|
|
|
envelop.setMessage("手机号码格式不正确");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
//验证手机是否被注册
|
|
|
List<BasePatientDO> list = patientDao.findByMobileAndDel(mobile,"1");
|
|
|
if(CollectionUtils.isEmpty(list)){
|
|
|
List<BasePatientDO> list = basePatientDao.findByMobileAndDel(mobile, "1");
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
envelop.setMessage("该手机未注册");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
if(list.size()> 1){
|
|
|
if (list.size() > 1) {
|
|
|
envelop.setMessage("该手机号存在多个账号,请联系管理员");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
@ -189,7 +159,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
BasePatientDO p = list.get(0);
|
|
|
//用于判断是否登陆成功,若登陆成功,且openId不为空,则更新openId
|
|
|
boolean isLogin = false;
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(password)){
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(password)) {
|
|
|
password = rsaService.decryptString(password);
|
|
|
password = org.apache.commons.lang3.StringUtils.reverse(password);
|
|
|
//生成MD5
|
|
@ -197,7 +167,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
if (loginPassword.equals(p.getPassword())) {
|
|
|
//使用密码登录成功
|
|
|
isLogin = true;
|
|
|
}else{
|
|
|
} else {
|
|
|
//使用密码登录失败
|
|
|
envelop.setMessage("密码错误");
|
|
|
envelop.setStatus(-1);
|
|
@ -206,15 +176,15 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
} else {
|
|
|
//验证码登陆
|
|
|
int res = baseSmsService.check(mobile, 4, captcha);
|
|
|
if(-2 == res){
|
|
|
if (-2 == res) {
|
|
|
envelop.setMessage("验证码已过期!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}else if(-1 == res){
|
|
|
} else if (-1 == res) {
|
|
|
envelop.setMessage("请输入正确的验证码!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
|
}else if(0 == res) {
|
|
|
} else if (0 == res) {
|
|
|
envelop.setMessage("验证码无效!");
|
|
|
envelop.setStatus(-1);
|
|
|
return envelop;
|
|
@ -223,10 +193,10 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
isLogin = true;
|
|
|
}
|
|
|
}
|
|
|
if(isLogin){
|
|
|
if(StringUtils.isNotBlank(openId) && !"undefined".equals(openId)){
|
|
|
if (isLogin) {
|
|
|
if (StringUtils.isNotBlank(openId) && !"undefined".equals(openId)) {
|
|
|
//更新openId
|
|
|
if(!openId.equals(p.getOpenid())){
|
|
|
if (!openId.equals(p.getOpenid())) {
|
|
|
patientService.updateOpenId(p.getId(), openId);
|
|
|
}
|
|
|
}
|
|
@ -250,10 +220,10 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
public Envelop create(
|
|
|
@ApiParam(name = "jsonData", value = "Json数据", required = true)
|
|
|
@RequestParam String jsonData) throws Exception {
|
|
|
String msg = patientService.createPatient(jsonData);
|
|
|
if(!StringUtils.equalsIgnoreCase(ConstantUtils.SUCCESS,msg)){
|
|
|
return success(msg);
|
|
|
}
|
|
|
String msg = patientService.createPatient(jsonData);
|
|
|
if (!StringUtils.equalsIgnoreCase(ConstantUtils.SUCCESS, msg)) {
|
|
|
return success(msg);
|
|
|
}
|
|
|
return failed(msg);
|
|
|
}
|
|
|
|
|
@ -272,7 +242,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "jsonData", value = "Json数据", required = true)
|
|
|
@RequestParam String jsonData) throws Exception {
|
|
|
String msg = patientService.updatePatient(jsonData);
|
|
|
if(!StringUtils.equalsIgnoreCase(ConstantUtils.SUCCESS,msg)){
|
|
|
if (!StringUtils.equalsIgnoreCase(ConstantUtils.SUCCESS, msg)) {
|
|
|
return failed(msg);
|
|
|
}
|
|
|
return success(msg);
|
|
@ -318,20 +288,48 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
return success(basePatients, BasePatientVO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.BasePatient.getBaseInfo)
|
|
|
@ApiOperation(value = "获取居民基础信息列表")
|
|
|
public ListEnvelop queryPatientBaseInfo(
|
|
|
@ApiParam(name = "nameOrIdcard", value = "居民姓名或身份证")
|
|
|
@RequestParam(value = "nameOrIdcard", required = false) String nameOrIdcard,
|
|
|
@ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
|
|
|
@RequestParam(value = "page") int page,
|
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
@RequestParam(value = "size") int size,
|
|
|
@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts", required = false) String sorts) throws Exception {
|
|
|
@GetMapping(value = BaseRequestMapping.BasePatient.iscompleted)
|
|
|
@ApiOperation(value = "判断身份信息是否完善,false-未完善,true-已完善")
|
|
|
public Envelop isCompleted(@ApiParam(name = "id", value = "居民id", required = true) @RequestParam String id) throws Exception {
|
|
|
return success(patientService.isCompleted(id));
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> basePatients = patientService.queryPatientBaseInfo(nameOrIdcard, page,size,sorts);
|
|
|
return success(basePatients);
|
|
|
@GetMapping(value = BaseRequestMapping.BasePatient.idcardOccupied)
|
|
|
@ApiOperation(value = "判断身份证是否被占用,false-未占用,true-已占用")
|
|
|
public Envelop idcardOccupied(@ApiParam(name = "id", value = "居民标识", required = true) @RequestParam String id,
|
|
|
@ApiParam(name = "idcard", value = "居民身份证号", required = true) @RequestParam String idcard) throws Exception {
|
|
|
return success(patientService.existsByIdcard(idcard, id));
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BasePatient.completeInfo)
|
|
|
@ApiOperation(value = "完善信息")
|
|
|
public Envelop completeInfo(@ApiParam(name = "jsonData", value = "jsonData数据", required = true) @RequestParam String jsonData,
|
|
|
@ApiParam(name = "photo", value = "头像", required = false) @RequestParam MultipartFile photo) throws Exception {
|
|
|
return success(patientService.completePatientDetails(photo, jsonData));
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BasePatient.updateMobile)
|
|
|
@ApiOperation(value = "修改手机号")
|
|
|
public Envelop updateMobile(@ApiParam(name = "id", value = "居民标识", required = true) @RequestParam String id,
|
|
|
@ApiParam(name = "newMobile", value = "新的手机号", required = true) @RequestParam String newMobile,
|
|
|
@ApiParam(name = "captcha", value = "验证码", required = true) @RequestParam String captcha) throws Exception {
|
|
|
return success(patientService.updateMobile(id, newMobile, captcha));
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BasePatient.resetPassword)
|
|
|
@ApiOperation(value = "设置密码")
|
|
|
public Envelop updatePasswd(@ApiParam(name = "id", value = "居民标识", required = true) @RequestParam String id,
|
|
|
@ApiParam(name = "password", value = "密码", required = true) @RequestParam String password) throws Exception {
|
|
|
return success(patientService.resetPassword(id, password));
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.BasePatient.getCompletedInfo)
|
|
|
@ApiOperation(value = "查询完善后信息详情")
|
|
|
public ObjEnvelop<BasePatientVO> getCompletedInfo(
|
|
|
@ApiParam(name = "id", value = "居民标识")
|
|
|
@RequestParam(value = "id", required = true) String id) throws Exception {
|
|
|
return success(patientService.getCompletedDetails(id), BasePatientVO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.BasePatient.sendCaptcha)
|
|
@ -341,7 +339,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
|
|
|
@RequestParam(value = "mobile", required = true) String mobile,
|
|
|
@ApiParam(name = "type", value = "短信验证码类型", required = true)
|
|
|
@RequestParam(value = "type") SmsTemplateDO.Type type) throws Exception {
|
|
|
SmsDO smsDO = baseSmsGatewayService.send(clientId, type,mobile);
|
|
|
SmsDO smsDO = baseSmsGatewayService.send(clientId, type, mobile);
|
|
|
return success(smsDO, SmsVO.class);
|
|
|
}
|
|
|
|