Browse Source

Merge branch 'dev' of LiTaohong/wlyy2.0 into dev

LiTaohong 6 years ago
parent
commit
84bccfd697

+ 71 - 60
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -1,20 +1,19 @@
package com.yihu.jw.file_upload;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.exception.business.file_upload.*;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.csource.common.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLDecoder;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
@ -27,12 +26,6 @@ public class FileUploadService {
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
//    @Autowired
//    private ErrorCodeUtil errorCodeUtil;
    /**
     * 文件流上传图片
     * @param inputStream
@ -40,27 +33,28 @@ public class FileUploadService {
     * @return
     * @throws Exception
     */
    public JSONObject uploadImg(InputStream inputStream, String originalFileName,long fileSize) throws Exception{
        JSONObject result = new JSONObject();
    public UploadVO uploadImg(InputStream inputStream, String originalFileName,long fileSize,String fastdfs_file_url) throws NoSuchAlgorithmException, IOException, MyException {
        // 得到文件的完整名称  xxx.txt
        if(StringUtils.isBlank(originalFileName) || null == inputStream){
            result.put("msg","图片文件名或图片文件流不可为空!");
            result.put("response", ConstantUtils.FAIL);
            return result;
        if( null == inputStream){
            throw new FileInputStreamEmptyException("图片文件流不可为空!");
        }
        if(StringUtils.isBlank(originalFileName)){
            throw new FileNameEmptyException("图片文件名不可为空!");
        }
        if(StringUtils.isBlank(fastdfs_file_url)){
            throw new FastfdsFileURLEmptyException("fastdfs url不可为空!");
        }
        //得到文件类型
        String fileType = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"jpg,jpeg,png".contains(fileType)){
            result.put("msg","图片文件格式不正确,请上传jpg,jpeg,png等任一格式!");
            result.put("response", ConstantUtils.FAIL);
            return result;
            throw new FileWrongFormatException("图片文件格式不正确,请上传jpg,jpeg,png等任一格式!");
        }
        long max = 5*1024*1024;
        if(fileSize > max){
            result.put("msg","图片文件过大,请不要超过5M!");
            result.put("response", ConstantUtils.FAIL);
            return result;
            throw new FileTooLargeSizeException("图片文件过大,请不要超过5M!");
        }
        String fileName = originalFileName.substring(0, originalFileName.lastIndexOf("."));
@ -72,82 +66,99 @@ public class FileUploadService {
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        result.put("response", ConstantUtils.SUCCESS);
        return result;
        return uploadVO;
    }
/*
    *//**
     /*
     * 文件流上传附件
     * @param file
     * @return
     * @throws Exception
     *//*
    public ObjEnvelop<UploadVO> uploadAttachment(MultipartFile file) throws Exception{
     */
    public UploadVO uploadAttachment(InputStream inputStream, String originalFileName,long fileSize,String fastdfs_file_url) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String fullName = file.getOriginalFilename();
        if(StringUtils.isBlank(fullName)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FAIL_UPLOAD_FORMAT), ObjEnvelop.class);
        if( null == inputStream){
            throw new FileInputStreamEmptyException("附件文件流不可为空!");
        }
        if(StringUtils.isBlank(originalFileName)){
            throw new FileNameEmptyException("图片文件名不可为空!");
        }
        if(StringUtils.isBlank(fastdfs_file_url)){
            throw new FastfdsFileURLEmptyException("fastdfs url不可为空!");
        }
        //得到文件类型
        String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
        String fileType = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"doc、docx、pdf、xls、xlsx、jpg、jpeg、png".contains(fileType)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FAIL_UPLOAD_FORMAT), ObjEnvelop.class);
            throw new FileWrongFormatException("附件文件格式不正确,请上传doc、docx、pdf、xls、xlsx、jpg、jpeg、png等任一格式!");
        }
        long size = file.getSize();
        long max = 5*1024*1024;
        if(size>max){
            String msg = String.format(BaseErrorCode.FileUpload.FAIL_FILE_SIZE, 5);
            return failed(msg, ObjEnvelop.class);
        if(fileSize > max){
            throw new FileTooLargeSizeException("附件文件过大,请不要超过5M!");
        }
        String fileName = fullName.substring(0, fullName.lastIndexOf("."));
        String fileName = originalFileName.substring(0, originalFileName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
        ObjectNode objectNode = fastDFSHelper.upload(inputStream, fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        return success("上传成功", uploadVO);
        return uploadVO;
    }
    *//**
    /*
     * 文件流上传文件
     * @param file
     * @return
     * @throws Exception
     *//*
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String fullName = file.getOriginalFilename();
     */
    public UploadVO uploadStream(InputStream inputStream, String originalFileName,String fastdfs_file_url) throws Exception{
        if( null == inputStream){
            throw new FileInputStreamEmptyException("文件内容不可为空!");
        }
        if(StringUtils.isBlank(originalFileName)){
            throw new FileNameEmptyException("文件名不可为空!");
        }
        if(StringUtils.isBlank(fastdfs_file_url)){
            throw new FastfdsFileURLEmptyException("fastdfs url不可为空!");
        }
        //得到文件类型
        String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
        String fileName = fullName.substring(0, fullName.lastIndexOf("."));
        String fileType = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase();
        String fileName = originalFileName.substring(0, originalFileName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
        ObjectNode objectNode = fastDFSHelper.upload(inputStream, fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        return success("上传成功", uploadVO);
        return uploadVO;
    }
    *//**
    /*
     * base64上传图片
     * @param jsonData
     * @param jsonData,头像转化后的输入流
     * @return
     * @throws Exception
     *//*
    public ObjEnvelop<UploadVO> uploadImages(@ApiParam(name = "jsonData", value = "头像转化后的输入流")
                                             @RequestBody String jsonData) throws Exception {
        if(jsonData == null){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FILE_NULL), ObjEnvelop.class);
     */
    public UploadVO uploadImages(String jsonData,String fastdfs_file_url) throws Exception {
        if(StringUtils.isBlank(jsonData)){
            throw new FileInputStreamEmptyException("图片的base64文件文件流不可为空!");
        }
        if(StringUtils.isBlank(fastdfs_file_url)){
            throw new FastfdsFileURLEmptyException("fastdfs url不可为空!");
        }
        String date = URLDecoder.decode(jsonData,"UTF-8");
        String[] fileStreams = date.split(",");
@ -174,8 +185,8 @@ public class FileUploadService {
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        //返回文件路径
        return success("上传成功", uploadVO);
    }*/
        return uploadVO;
    }
}

+ 9 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/file_upload/FastfdsFileURLEmptyException.java

@ -0,0 +1,9 @@
package com.yihu.jw.exception.business.file_upload;
public class FastfdsFileURLEmptyException extends RuntimeException {
    public FastfdsFileURLEmptyException(String msg){
        super(msg);
    }
}

+ 9 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/file_upload/FileInputStreamEmptyException.java

@ -0,0 +1,9 @@
package com.yihu.jw.exception.business.file_upload;
public class FileInputStreamEmptyException extends RuntimeException {
    public FileInputStreamEmptyException(String msg){
        super(msg);
    }
}

+ 9 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/file_upload/FileNameEmptyException.java

@ -0,0 +1,9 @@
package com.yihu.jw.exception.business.file_upload;
public class FileNameEmptyException extends RuntimeException {
    public FileNameEmptyException(String msg){
        super(msg);
    }
}

+ 9 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/file_upload/FileTooLargeSizeException.java

@ -0,0 +1,9 @@
package com.yihu.jw.exception.business.file_upload;
public class FileTooLargeSizeException extends RuntimeException {
    public FileTooLargeSizeException(String msg){
        super(msg);
    }
    
}

+ 9 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/file_upload/FileWrongFormatException.java

@ -0,0 +1,9 @@
package com.yihu.jw.exception.business.file_upload;
public class FileWrongFormatException extends RuntimeException {
    public FileWrongFormatException(String msg){
        super(msg);
    }
    
}

+ 11 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/patient/CapthcaInvalidException.java

@ -0,0 +1,11 @@
package com.yihu.jw.exception.business.patient;
/**
 * 居民不存在
 */
public class CapthcaInvalidException extends RuntimeException{
    public CapthcaInvalidException(String msg){
        super(msg);
    }
}

+ 11 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/business/patient/NotFoundPatientException.java

@ -0,0 +1,11 @@
package com.yihu.jw.exception.business.patient;
/**
 * 居民不存在
 */
public class NotFoundPatientException extends RuntimeException{
    public NotFoundPatientException(String msg){
        super(msg);
    }
}

+ 13 - 97
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -31,44 +32,19 @@ import java.util.Base64;
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
public class FileUploadController extends EnvelopRestEndpoint {
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    FileUploadService fileUploadService;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
    public ObjEnvelop<UploadVO> uploadImg(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String fullName = file.getOriginalFilename();
        if(StringUtils.isBlank(fullName)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FAIL_UPLOAD_FORMAT), ObjEnvelop.class);
        }
        //得到文件类型
        String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"jpg,jpeg,png".contains(fileType)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FAIL_UPLOAD_FORMAT), ObjEnvelop.class);
        }
        long size = file.getSize();
        long max = 5*1024*1024;
        if(size>max){
            String msg = String.format(BaseErrorCode.FileUpload.FAIL_FILE_SIZE, 5);
            return failed(msg, ObjEnvelop.class);
        }
        String fileName = fullName.substring(0, fullName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadImg(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
@ -77,53 +53,20 @@ public class FileUploadController extends EnvelopRestEndpoint {
    @ApiOperation(value = "文件流上传附件", notes = "文件流上传附件")
    public ObjEnvelop<UploadVO> uploadAttachment(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String fullName = file.getOriginalFilename();
        if(StringUtils.isBlank(fullName)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FAIL_UPLOAD_FORMAT), ObjEnvelop.class);
        }
        //得到文件类型
        String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"doc、docx、pdf、xls、xlsx、jpg、jpeg、png".contains(fileType)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FAIL_UPLOAD_FORMAT), ObjEnvelop.class);
        }
        long size = file.getSize();
        long max = 5*1024*1024;
        if(size>max){
            String msg = String.format(BaseErrorCode.FileUpload.FAIL_FILE_SIZE, 5);
            return failed(msg, ObjEnvelop.class);
        }
        String fileName = fullName.substring(0, fullName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadAttachment(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
        @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String fullName = file.getOriginalFilename();
        //得到文件类型
        String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
        String fileName = fullName.substring(0, fullName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
@ -131,34 +74,7 @@ public class FileUploadController extends EnvelopRestEndpoint {
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")
    public ObjEnvelop<UploadVO> uploadImages(@ApiParam(name = "jsonData", value = "头像转化后的输入流")
                                                 @RequestBody String jsonData) throws Exception {
        if(jsonData == null){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.FileUpload.FILE_NULL), ObjEnvelop.class);
        }
        String date = URLDecoder.decode(jsonData,"UTF-8");
        String[] fileStreams = date.split(",");
        String is = URLDecoder.decode(fileStreams[1],"UTF-8").replace(" ","+");
        byte[] in = Base64.getDecoder().decode(is);
        String pictureName = fileStreams[0].substring(0,fileStreams[0].length()-1);
        String fileExtension = pictureName.substring(pictureName.lastIndexOf(".") + 1).toLowerCase();
        String description = null;
        if ((pictureName != null) && (pictureName.length() > 0)) {
            int dot = pictureName.lastIndexOf('.');
            if ((dot > -1) && (dot < (pictureName.length()))) {
                description = pictureName.substring(0, dot);
            }
        }
        InputStream inputStream = new ByteArrayInputStream(in);
        ObjectNode objectNode = fastDFSHelper.upload(inputStream, "png", "");
        String groupName = objectNode.get("groupName").toString();
        String remoteFileName = objectNode.get("remoteFileName").toString();
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(remoteFileName);
        uploadVO.setFileType(groupName);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        //返回文件路径
        UploadVO uploadVO = fileUploadService.uploadImages(jsonData,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }

+ 32 - 33
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/personal_Info/PatientService.java

@ -1,7 +1,10 @@
package com.yihu.jw.patient.service.personal_Info;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Preconditions;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.exception.business.patient.CapthcaInvalidException;
import com.yihu.jw.exception.business.patient.NotFoundPatientException;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.patient.dao.personal_info.PatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.patient.util.ConstantUtils;
@ -10,6 +13,7 @@ import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * 居民信息服务
@ -24,29 +28,25 @@ public class PatientService extends BasePatientService {
    @Autowired
    private BaseSmsService baseSmsService;
    @Autowired
    private FileUploadService fileUploadService;
    /**
     * 设置登录密码
     * @param id
     * @param password
     */
    public JSONObject setPassword(String id, String password){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(password) || StringUtils.isEmpty(password)){
            result.put("msg","密码不能为空!");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
    public String setPassword(String id, String password){
        Preconditions.checkNotNull(id);
        Preconditions.checkNotNull(password);
        BasePatientDO patient = patientDao.findOne(id);
        if(null == patient){
            result.put("msg","当前居民不存在:【 " + id + "】");
            result.put("response", ConstantUtils.FAIL);
            return result;
            throw new NotFoundPatientException("当前居民不存在:【 " + id + "】");
        }
        patient.setSalt(randomString(5));
        password = patient.getIdcard().substring(0, 5);
        patient.setPassword(MD5.md5Hex(password + "{" + patient.getSalt() + "}"));
        result.put("response",ConstantUtils.SUCCESS);
        return result;
        return ConstantUtils.SUCCESS;
    }
@ -56,18 +56,17 @@ public class PatientService extends BasePatientService {
     * @param newPassword
     * @return
     */
    public JSONObject resetPassword(String id,String newPassword,String captcha){
        JSONObject result = new JSONObject();
    @Transactional(rollbackFor = Exception.class)
    public String resetPassword(String id,String newPassword){
        Preconditions.checkNotNull(id);
        Preconditions.checkNotNull(newPassword);
        BasePatientDO patient = patientDao.findOne(id);
        if(null == patient){
            result.put("msg","当前居民不存在:【 " + id + "】");
            result.put("response", ConstantUtils.FAIL);
            return result;
            throw new NotFoundPatientException("当前居民不存在:【 " + id + "】");
        }
        patient.setSalt(randomString(5));
        patient.setPassword(MD5.md5Hex(newPassword + "{" + patient.getSalt() + "}"));
        result.put("response",ConstantUtils.SUCCESS);
        return result;
        return ConstantUtils.SUCCESS;
    }
    /**
@ -76,28 +75,28 @@ public class PatientService extends BasePatientService {
     * @param newMobile
     * @return
     */
    public JSONObject updateMobile(String id,String newMobile,String captcha){
        JSONObject result = new JSONObject();
    @Transactional(rollbackFor = Exception.class)
    public BasePatientDO updateMobile(String id,String newMobile,String captcha){
        Preconditions.checkNotNull(id);
        Preconditions.checkNotNull(newMobile);
        Preconditions.checkNotNull(captcha);
        BasePatientDO patient = patientDao.findOne(id);
        if(null == patient){
            result.put("msg","当前居民不存在:【 " + id + "】");
            result.put("response", ConstantUtils.FAIL);
            return result;
            throw new NotFoundPatientException("当前居民不存在:【 " + id + "】");
        }
        if(StringUtils.endsWithIgnoreCase(patient.getMobile(),newMobile)){
            result.put("response",ConstantUtils.SUCCESS);
            return result;
            return patient;
        }
        if(baseSmsService.verifyCaptcha(captcha)){
            patient.setMobile(newMobile);
            this.save(patient);
        }else{
            result.put("msg","验证码不正确或过期!");
            result.put("response", ConstantUtils.FAIL);
            return result;
            throw new CapthcaInvalidException("验证码不正确或过期!");
        }
        result.put("response",ConstantUtils.SUCCESS);
        return result;
        return patient;
    }
//    public JSONObject completePatientDetails(){}
    public BasePatientDO completePatientDetails(BasePatientDO patientDO){
        return patientDO;
    }
}