소스 검색

Merge remote-tracking branch 'origin/master'

hill9868 6 년 전
부모
커밋
0500885c7f

+ 42 - 0
.gitignore

@ -0,0 +1,42 @@
#project files
ehr.ipr
ehr.iws
ehr.ids
*.html
*.iml
*/target/*
*/*/target/*
.idea/*
# ---> Java
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*#
# thrift generate code
commons-thrift-services/src/main/java/com/yihu/ehr/adaption
commons-thrift-services/src/main/java/com/yihu/ehr/app
commons-thrift-services/src/main/java/com/yihu/ehr/browser
commons-thrift-services/src/main/java/com/yihu/ehr/data/domain
commons-thrift-services/src/main/java/com/yihu/ehr/dict
commons-thrift-services/src/main/java/com/yihu/ehr/geography
commons-thrift-services/src/main/java/com/yihu/ehr/hadoop
commons-thrift-services/src/main/java/com/yihu/ehr/lang
commons-thrift-services/src/main/java/com/yihu/ehr/org
commons-thrift-services/src/main/java/com/yihu/ehr/pack
commons-thrift-services/src/main/java/com/yihu/ehr/patient
commons-thrift-services/src/main/java/com/yihu/ehr/profile
commons-thrift-services/src/main/java/com/yihu/ehr/resolve
commons-thrift-services/src/main/java/com/yihu/ehr/resource
commons-thrift-services/src/main/java/com/yihu/ehr/security
commons-thrift-services/src/main/java/com/yihu/ehr/std
commons-thrift-services/src/main/java/com/yihu/ehr/user

+ 23 - 3
src/main/java/com.yihu.ehr/basic/fileresource/controller/FileResourceEndPoint.java

@ -7,6 +7,7 @@ import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.fastdfs.FastDFSUtil;
import com.yihu.ehr.util.id.BizObject;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -105,11 +106,11 @@ public class FileResourceEndPoint extends EnvelopRestEndPoint {
            @ApiParam(name = "mime", value = "所有者", required = true)
            @RequestParam(value = "mime", required = false) String mime) throws Exception {
        List<FileResource> fileResources;
        if (StringUtils.isEmpty(mime))
        if (StringUtils.isEmpty(mime)) {
            fileResources = fileResourceManager.findByObjectId(objectId);
        else
        }else {
            fileResources = fileResourceManager.findByObjectIdAndMime(objectId, mime);
        }
        List<String> filesStrs = new ArrayList<>();
        for (FileResource fileResource : fileResources) {
            String storagePath = fileResource.getStoragePath();
@ -172,4 +173,23 @@ public class FileResourceEndPoint extends EnvelopRestEndPoint {
        return realPath;
    }
    @ApiOperation(value = "根据文件ID,获取文件")
    @RequestMapping(value = "/file/getFileStorage", method = RequestMethod.GET)
    public Envelop getFileStorage(
            @ApiParam(name = "fileId", value = "文件ID", required = true)
            @RequestParam(value = "fileId") String fileId) throws Exception {
        Envelop envelop =new Envelop();
        String s = java.net.URLDecoder.decode(fileId, "UTF-8");
        String path = fileResourceManager.getStoragePathById(s);
        if(StringUtils.isNotEmpty(path)){
            String groupName = path.split(":")[0];
            String remoteFileName = path.split(":")[1];
            byte[] bytes = fastDFSUtil.download(groupName, remoteFileName);
            String fileStream = new String(Base64.getEncoder().encode(bytes));
            envelop.setObj(fileStream);
        }
        envelop.setSuccessFlg(true);
        return envelop;
    }
}

+ 6 - 3
src/main/java/com.yihu.ehr/basic/fileresource/service/XFileResourceRepository.java

@ -1,6 +1,8 @@
package com.yihu.ehr.basic.fileresource.service;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
@ -9,12 +11,13 @@ import java.util.List;
 * @created 2016.05.12 8:53
 */
public interface XFileResourceRepository extends PagingAndSortingRepository<FileResource, String> {
    List<FileResource> findByObjectId(String objectId);
    @Query("select fileResource from FileResource fileResource where fileResource.objectId = :objectId")
    List<FileResource> findByObjectId(@Param("objectId")String objectId);
    List<FileResource> findByStoragePath(String storagePath);
    List<FileResource> findByObjectIdAndMime(String objectId, String mime);
    @Query("select fileResource from FileResource fileResource where fileResource.objectId = :objectId and fileResource.mime = :mime ")
    List<FileResource> findByObjectIdAndMime(@Param ("objectId")String objectId, @Param ("mime")String mime);
    FileResource findById(String id);
}

+ 71 - 2
src/main/java/com.yihu.ehr/basic/user/controller/DoctorEndPoint.java

@ -1,6 +1,8 @@
package com.yihu.ehr.basic.user.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.basic.fileresource.service.FileResource;
import com.yihu.ehr.basic.fileresource.service.XFileResourceRepository;
import com.yihu.ehr.basic.getui.ConstantUtil;
import com.yihu.ehr.basic.org.model.OrgDept;
import com.yihu.ehr.basic.org.model.OrgMemberRelation;
@ -16,10 +18,13 @@ import com.yihu.ehr.basic.user.service.DoctorService;
import com.yihu.ehr.basic.user.service.RoleUserService;
import com.yihu.ehr.basic.user.service.RolesService;
import com.yihu.ehr.basic.user.service.UserService;
import com.yihu.ehr.basic.util.IdcardValidator;
import com.yihu.ehr.commons.constants.BasicServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.entity.patient.DemographicInfo;
import com.yihu.ehr.model.common.Result;
import com.yihu.ehr.model.org.MOrgDeptJson;
import com.yihu.ehr.model.user.MDoctor;
import com.yihu.ehr.util.datetime.DateUtil;
@ -76,6 +81,13 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
    private RolesService rolesService;
    @Autowired
    private RoleUserService roleUserService;
    @Autowired
    private IdcardValidator idcardValidator;
    @Autowired
    private XFileResourceRepository resourceRepository;
    @Value("${fast-dfs.public-server}")
    private String fastDfsPublicServers;
    @RequestMapping(value = ServiceApi.Doctors.Doctors, method = RequestMethod.GET)
    @ApiOperation(value = "获取医生列表", notes = "根据查询条件获取医生列表在前端表格展示")
@ -133,6 +145,9 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
        Organization organization = orgService.getOrgById(mOrgDeptJson.getOrgId());
        OrgDept orgDept = orgDeptService.searchBydeptId(Integer.parseInt(mOrgDeptJson.getDeptIds().split(",")[0]));
        Doctors doctor = toEntity(doctoJsonData, Doctors.class);
        if (!idcardValidator.isValidatedAllIdcard(doctor.getIdCardNo())){
            return null;
        }
        doctor.setStatus("1");
        doctor.setPyCode(PinyinUtil.getPinYinHeadChar(doctor.getName(), false));
        doctor.setOrgId(organization.getId().toString());
@ -258,6 +273,7 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
            user.setRealName(doctors.getName());
            user.setGender(doctors.getSex());
            user.setTelephone(doctors.getPhone());
            user.setImgRemotePath(doctors.getPhoto());
            userManager.save(user);
        }
        //修改居民
@ -557,7 +573,7 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
            @RequestParam(value = "workPortal", required = false) String workPortal) throws Exception {
        Doctors doctors = doctorService.getDoctor(id);
        if (!StringUtils.isEmpty(photo)) {
            doctors.setPhoto(photo);
            doctors.setPhoto(saveImgFileSource(photo));
        }
        if (!StringUtils.isEmpty(skill)) {
            doctors.setSkill(skill);
@ -576,7 +592,9 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
            user.setImgRemotePath(doctors.getPhoto());
            userManager.save(user);
        }
        return success(convertToModel(doctors, MDoctor.class));
        MDoctor doctorModel = convertToModel(doctors, MDoctor.class);
        doctorModel.setPhoto(photo);
        return success(doctorModel);
    }
@ -589,4 +607,55 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
        MDoctor doctorModel = convertToModel(doctors, MDoctor.class);
        return doctorModel;
    }
    /**
     * 健康上饶app,前端单独调用头像上传接口,将头像的路径传到后端。后端需要将路径保存到fileResource表中,再将id存到用户表
     * http://172.19.103.52:80/group1/M00/26/AF/rBFuWFr5BkWAZfYmAAAeqtdiKIY039.png
     *
     * @param path
     * @return
     */
    public String saveImgFileSource(String path) throws Exception {
        //获取用户头像,保存至file_resource
        FileResource fileResource = new FileResource();
        fileResource.setId(getObjectId(BizObject.FileResource));
        //获取groupName
        String[] str = path.split("/");
        String groupName = str[3];
        String remoteFileName = path.substring(path.indexOf(groupName)+ groupName.length()+1);
        //保存到resource表中
        fileResource.setStoragePath(groupName + ":" + remoteFileName);
        fileResource.setCreateDate(new Date());
        fileResource.setMime("user");
        fileResource.setObjectId("");
        return resourceRepository.save(fileResource).getId();
    }
    @RequestMapping(value = BasicServiceApi.Doctors.GetDoctorById, method = RequestMethod.GET)
    @ApiOperation(value = "补充健康上饶-根据id获取获取医生信息--因为头像的获取方式与基础信息管理不同,基础信息管理在app-admin处理了图片路径")
    public MDoctor GetDoctorById(
            @ApiParam(name = "doctor_id", value = "", defaultValue = "")
            @PathVariable(value = "doctor_id") Long doctorId) throws Exception{
        Doctors doctors = doctorService.getDoctor(doctorId);
        if(null!=doctors&&!StringUtils.isEmpty(doctors.getPhoto())){
          doctors.setPhoto(getImgPathByFileResource(doctors.getPhoto()));
        }
        MDoctor doctorModel = convertToModel(doctors, MDoctor.class);
        return doctorModel;
    }
    /**
     * 健康上饶app,根据fileResourceId获取图片路径
     *
     * @param fileResourceId
     * @return
     */
    public String getImgPathByFileResource(String fileResourceId) throws Exception {
        FileResource fileResource = resourceRepository.findById(fileResourceId);
        String path = null == fileResource ? "" : fileResource.getStoragePath();
        if (!StringUtils.isEmpty(path)) {
            return fastDfsPublicServers + "/" + path.replace(":", "/");
        }
        return "";
    }
}

+ 162 - 10
src/main/java/com.yihu.ehr/basic/user/controller/UserEndPoint.java

@ -3,6 +3,8 @@ package com.yihu.ehr.basic.user.controller;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.ehr.basic.dict.service.SystemDictEntryService;
import com.yihu.ehr.basic.fileresource.service.FileResource;
import com.yihu.ehr.basic.fileresource.service.XFileResourceRepository;
import com.yihu.ehr.basic.getui.ConstantUtil;
import com.yihu.ehr.basic.org.model.OrgMemberRelation;
import com.yihu.ehr.basic.org.service.OrgMemberRelationService;
@ -13,6 +15,7 @@ import com.yihu.ehr.basic.user.entity.Roles;
import com.yihu.ehr.basic.user.entity.UserTypeRoles;
import com.yihu.ehr.basic.user.service.RoleUserService;
import com.yihu.ehr.basic.user.service.RolesService;
import com.yihu.ehr.commons.constants.BasicServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.basic.user.entity.Doctors;
import com.yihu.ehr.basic.user.entity.User;
@ -47,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.activation.MimetypesFileTypeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@ -75,6 +79,10 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    private String orgcode;
    @Value("${jksr-app.registerRoleClientId}")
    public String registerRoleClientId;
    @Value("${fast-dfs.public-server}")
    private String fastDfsPublicServers;
    @Autowired
    private UserService userService;
    @Autowired
@ -97,6 +105,8 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    private OrgMemberRelationService relationService;
    @Autowired
    private XUserTypeRolesRepository xUserTypeRolesRepository;
    @Autowired
    private XFileResourceRepository resourceRepository;
    @RequestMapping(value = ServiceApi.Users.Users, method = RequestMethod.GET)
    @ApiOperation(value = "获取用户列表", notes = "根据查询条件获取用户列表在前端表格展示")
@ -178,6 +188,11 @@ public class UserEndPoint extends EnvelopRestEndPoint {
        if (dict != null) {
            user.setDType(userType);
        }
        String imgPath = user.getImgRemotePath();
        if (!StringUtils.isEmpty(imgPath) && imageCheck(imgPath)) {
            //公众健康-个人设置传的是路径
            user.setImgRemotePath(saveImgFileSource(imgPath));
        }
        userService.saveUser(user);
        //同时修改医生表及用户表信息
        Doctors doctors = doctorService.getByIdCardNo(user.getIdCardNo());
@ -186,6 +201,7 @@ public class UserEndPoint extends EnvelopRestEndPoint {
            doctors.setPyCode(PinyinUtil.getPinYinHeadChar(user.getRealName(), false));
            doctors.setSex(user.getGender());
            doctors.setPhone(user.getTelephone());
            doctors.setPhoto(user.getImgRemotePath());
            doctorService.save(doctors);
        }
        DemographicInfo demographicInfo = demographicService.getDemographicInfoByIdCardNo(user.getIdCardNo());
@ -197,7 +213,9 @@ public class UserEndPoint extends EnvelopRestEndPoint {
            demographicInfo.setBirthday(DateUtil.strToDate(user.getBirthday()));
            demographicService.save(demographicInfo);
        }
        return convertToModel(user, MUser.class);
        MUser mUser =convertToModel(user, MUser.class);
        mUser.setImgRemotePath(imgPath);
        return mUser;
    }
    @RequestMapping(value = ServiceApi.Users.UserAdmin, method = RequestMethod.GET)
@ -235,15 +253,13 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    public MUser getUserByLoginCode(
            @ApiParam(name = "user_name", value = "登录账号", defaultValue = "")
            @PathVariable(value = "user_name") String userName) {
        //User user = userManager.getUserByUserName(userName);
        //TODO 可根据帐户,手机号,身份证号登陆接口新增
        // 帐户:手机号,身份证号,登录账号
        List<User> users = userService.getUserForLogin(userName);
        if (users != null) {
            if (users.size() == 1) {
                MUser mUser = new MUser();
                List<OrgMemberRelation> memberRelations = orgMemberRelationService.findByField("userId", users.get(0).getId());
                mUser = convertToModel(users.get(0), MUser.class);
                mUser = convertToModel(users.get(0), MUser.class);
                if (memberRelations != null && memberRelations.size() > 0) {
                    mUser.setPosition(memberRelations.get(0).getDutyName());
                    mUser.setDepartment(memberRelations.get(0).getDeptName());
@ -532,6 +548,16 @@ public class UserEndPoint extends EnvelopRestEndPoint {
            }
        }
        userService.saveUser(user);
        //将基础信息同步到医生表
        Doctors doctors = doctorService.getByIdCardNo(user.getIdCardNo());
        if (!StringUtils.isEmpty(doctors)) {
            doctors.setName(user.getRealName());
            doctors.setPyCode(PinyinUtil.getPinYinHeadChar(user.getRealName(), false));
            doctors.setSex(user.getGender());
            doctors.setPhone(user.getTelephone());
            doctors.setPhoto(user.getImgRemotePath());
            doctorService.save(doctors);
        }
        return convertToModel(user, MUser.class);
    }
@ -681,6 +707,7 @@ public class UserEndPoint extends EnvelopRestEndPoint {
            doctor.setPyCode(PinyinUtil.getPinYinHeadChar(detailModel.getRealName(), false));
            doctor.setSex(detailModel.getGender());
            doctor.setPhone(detailModel.getTelephone());
            doctor.setPhoto(detailModel.getImgRemotePath());
        }
        DemographicInfo demographicInfo = demographicService.getDemographicInfoByIdCardNo(detailModel.getIdCardNo());
        if (demographicInfo != null) {
@ -906,10 +933,10 @@ public class UserEndPoint extends EnvelopRestEndPoint {
        for (String rgAppId : appIds) {
            //根据用户类型、应用id判断是否关联角色,
            List<UserTypeRoles> list = xUserTypeRolesRepository.ListUserTypeRolesByTypeIdAndClientId(Integer.valueOf(ConstantUtil.PATIENTUSERTYPEID), rgAppId);
            if(null!=list && list.size()>0){
            if (null != list && list.size() > 0) {
                //卫生人员初始化授权
                userService.initializationAuthorization(Integer.valueOf(ConstantUtil.PATIENTUSERTYPEID),userId);
            }else{
                userService.initializationAuthorization(Integer.valueOf(ConstantUtil.PATIENTUSERTYPEID), userId);
            } else {
                // orgcode卫计委机构编码-PDY026797 添加居民的时候 默认 加到卫计委-居民角色中
                List<Roles> rolesList = rolesService.findByCodeAndAppIdAndOrgCode(Arrays.asList(new String[]{orgcode}), rgAppId, "Patient");
                Roles roles = new Roles();
@ -1120,11 +1147,11 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    @ApiOperation(value = "根据用户类型id,用户id进行初始化授权")
    public Envelop initializationAuthorization(
            @ApiParam(name = "userTypeId", value = "用户类型id", defaultValue = "")
            @RequestParam(value = "userTypeId",required =true) int userTypeId,
            @RequestParam(value = "userTypeId", required = true) int userTypeId,
            @ApiParam(name = "userId", value = "用户id", defaultValue = "")
            @RequestParam(value = "userId",required =true) String userId) {
            @RequestParam(value = "userId", required = true) String userId) {
        Envelop envelop = new Envelop();
        boolean authorrizationFlag= userService.initializationAuthorization(userTypeId,userId);
        boolean authorrizationFlag = userService.initializationAuthorization(userTypeId, userId);
        if (authorrizationFlag) {
            envelop.setSuccessFlg(true);
        } else {
@ -1134,4 +1161,129 @@ public class UserEndPoint extends EnvelopRestEndPoint {
        return envelop;
    }
    @RequestMapping(value = BasicServiceApi.Users.GetUserByLoginCode, method = RequestMethod.GET)
    @ApiOperation(value = "政府服务平台-根据登录账号获取当前用户", notes = "政府服务平台-根据登陆用户名及密码验证用户(一个人可属于多个机构)")
    public Envelop getUserInfoByLoginCode(
            @ApiParam(name = "userName", value = "登录账号", defaultValue = "")
            @PathVariable(value = "userName") String userName) {
        Envelop envelop = new Envelop();
        try {
            // 帐户:手机号,身份证号,登录账号
            List<User> users = userService.getUserForLogin(userName);
            if (users != null) {
                User user = users.get(0);
                String path = getImgPathByFileResource(users.get(0).getImgRemotePath());
                user.setImgRemotePath(path);
                envelop.setObj(users);
                if (users.size() == 1) {
                    List<OrgMemberRelation> memberRelations = orgMemberRelationService.findByField("userId", users.get(0).getId());
                    envelop.setSuccessFlg(true);
                    envelop.setDetailModelList(memberRelations);
                } else {
                    envelop.setSuccessFlg(false);
                    envelop.setErrorMsg("账号重复,请联系管理员!");
                }
            } else {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("该账号不存在,请确认或联系管理员!");
            }
        } catch (Exception e) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg(e.getMessage());
            e.printStackTrace();
        }
        return envelop;
    }
    @RequestMapping(value = BasicServiceApi.Users.UpdateUserByUsers, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "健康上饶app-修改用户", notes = "因为头像的获取方式与基础信息管理不同,基础信息管理在app-admin处理了图片路径")
    public MUser updateUserByUsers(
            @ApiParam(name = "user_json_data", value = "", defaultValue = "")
            @RequestBody String userJsonData) throws Exception {
        User user = toEntity(userJsonData, User.class);
        String userType = user.getUserType();
        SystemDictEntry dict = dictEntryService.getDictEntry(15, userType);
        if (dict != null) {
            user.setDType(userType);
        }
        //获取用户头像,保存至file_resource
        if (null != user.getImgRemotePath() && !StringUtils.isEmpty(user.getImgRemotePath())) {
            user.setImgRemotePath(saveImgFileSource(user.getImgRemotePath()));
        }
        userService.saveUser(user);
        //同时修改医生表及用户表信息
        Doctors doctors = doctorService.getByIdCardNo(user.getIdCardNo());
        if (!StringUtils.isEmpty(doctors)) {
            doctors.setName(user.getRealName());
            doctors.setPyCode(PinyinUtil.getPinYinHeadChar(user.getRealName(), false));
            doctors.setSex(user.getGender());
            doctors.setPhone(user.getTelephone());
            doctors.setPhoto(user.getImgRemotePath());
            doctorService.save(doctors);
        }
        DemographicInfo demographicInfo = demographicService.getDemographicInfoByIdCardNo(user.getIdCardNo());
        if (!StringUtils.isEmpty(demographicInfo)) {
            demographicInfo.setName(user.getRealName());
            demographicInfo.setTelephoneNo("{\"联系电话\":\"" + user.getTelephone() + "\"}");
            demographicInfo.setGender(user.getGender());
            demographicInfo.setMartialStatus(user.getMartialStatus());
            demographicInfo.setBirthday(DateUtil.strToDate(user.getBirthday()));
            demographicService.save(demographicInfo);
        }
        return convertToModel(user, MUser.class);
    }
    /**
     * 健康上饶app,前端单独调用头像上传接口,将头像的路径传到后端。后端需要将路径保存到fileResource表中,再将id存到用户表
     * http://172.19.103.52:80/group1/M00/26/AF/rBFuWFr5BkWAZfYmAAAeqtdiKIY039.png
     *
     * @param path
     * @return
     */
    public String saveImgFileSource(String path) throws Exception {
        //获取用户头像,保存至file_resource
        FileResource fileResource = new FileResource();
        fileResource.setId(getObjectId(BizObject.FileResource));
        //获取groupName
        String[] str = path.split("/");
        String groupName = str[3];
        String remoteFileName = path.substring(path.indexOf(groupName)+ groupName.length()+1);
        //保存到resource表中
        fileResource.setStoragePath(groupName + ":" + remoteFileName);
        fileResource.setCreateDate(new Date());
        fileResource.setMime("user");
        fileResource.setObjectId("");
        return resourceRepository.save(fileResource).getId();
    }
    /**
     * 健康上饶app,根据fileResourceId获取图片路径
     *
     * @param fileResourceId
     * @return
     */
    public String getImgPathByFileResource(String fileResourceId) throws Exception {
        FileResource fileResource = resourceRepository.findById(fileResourceId);
        String path = null == fileResource ? "" : fileResource.getStoragePath();
        if (!StringUtils.isEmpty(path)) {
            return fastDfsPublicServers + "/" + path.replace(":", "/");
        }
        return "";
    }
    /**
     * 判断是否为图片
     * @param imgPath
     * @return
     */
    public boolean imageCheck(String imgPath) throws Exception {
        MimetypesFileTypeMap   mtftp = new MimetypesFileTypeMap();
        mtftp.addMimeTypes("image png tif jpg jpeg bmp");
        String mimetype= mtftp.getContentType(imgPath);
        String type = mimetype.split("/")[0];
        return type.equals("image");
    }
}

+ 85 - 0
src/main/java/com.yihu.ehr/commons/constants/BasicServiceApi.java

@ -0,0 +1,85 @@
package com.yihu.ehr.commons.constants;
/**
 * 微服务REST API. 此处定义的URL可用于服务对外提供的地址及HTTP客户端请求地址.
 * URL定义遵循健康档案平台REST规范.
 *
 * @author zdm
 * @version 1.0
 * @created 2018.09.05 15:04
 */
public class BasicServiceApi {
    public static class Users {
        //存在于私有库-start
        public static final String Users = "/users";
        public static final String UsersOfApp = "/usersOfApp";
        public static final String User = "/users/{user_name}";
        public static final String UserExistence = "/users/{user_name}/existence";
        public static final String UserVerification = "/users/verification";
        public static final String UserAdmin = "/users/admin/{user_id}";
        public static final String UserAdminPassword = "/users/admin/{user_id}/password";
        public static final String UserAdminPasswordReset = "/users/admin/{user_id}/password_reset";
        public static final String UserAdminKey = "/users/admin/{user_id}/key";
        public static final String UserAdminContact = "/users/admin/{user_id}/contact";
        public static final String UserIdCardNoExistence = "/user/id_card_no/existence";
        public static final String UserEmailNoExistence = "/user/email/existence";
        public static final String UserTelephoneNoExistence = "/user/telephone/existence";
        public static final String UserPhoneExistence = "/user/phone/existence";
        public static final String UserOnePhoneExistence = "/user/onePhone/existence";
        public static final String UserEmailExistence = "/user/email/existence";
        public static final String UseridCardNoExistence = "/user/idCardNo/existence";
        public static final String UserByIdCardNo = "/user/idCardNo/userByIdCardNo";
        public static final String UpdateSystemUser = "/updateSystemUser";
        public static final String GetOrgAndDeptRelation = "/users/getOrgAndDeptRelation";
        public static final String InitializeSystemUser = "/users/initialize";
        public static final String UsersByTel = "/users/tel";
        public static final String H5Handshake = "/users/h5/handshake";
        public static final String UsersOfAppPhoneExistence = "/usersOfApp/user/onePhone/existence";
        public static final String GetUserOfUsersOfApp = "/usersOfApp/users/getUserOfUsersOfApp";
        public static final String GetUserInfoAndRolesByUserIdOrCode = "/users/orgDeptMember/getUserInfoAndRolesByUserIdOrCode";
        public static final String Save = "/users/save";
        public static final String Update = "/users/update";
        public static final String Check = "/users/check";
        public static final String ChangePassword = "/users/changePassword";
        public static final String DistributeSecurityKey = "/users/distributeSecurityKey";
        public static final String GetSecurityKey = "/users/getSecurityKey";
        public static final String changePasswordByTelephone = "/usersOfApp/users/changePasswordByTelephone";
        public static final String changePasswordByOldPassword = "/users/changePasswordByOldPassword";
        public static final String updateUserTelePhone = "/users/updateTelephone";
        public static final String initializationAuthorization = "/users/initializationAuthorization";
        //存在于私有库-end
        //basic服务拆分之后追加
        public static final String GetUserByLoginCode = "/users/GetUserByLoginCode/{userName}";
        public static final String UpdateUserByUsers = "/users/UpdateUserByUsers";
    }
    public static class Doctors {
        //私有库已存在-start
        public static final String Doctors = "/doctors";
        public static final String DoctorsExistence = "/doctors/{doctor_code}/existence";
        public static final String DoctorAdmin = "/doctors/admin/{doctor_id}";
        public static final String DoctorByIdCardNo = "/doctor/{idCardNo}";
        public static final String DoctorPhoneExistence = "/doctor/phone/existence";
        public static final String DoctorBatch = "/doctor/batch";
        public static final String DoctorOnePhoneExistence = "/doctor/onePhone/existence";
        public static final String DoctorEmailExistence = "/doctor/email/existence";
        public static final String DoctorsIdCardNoExistence = "/doctors/{doctor_idCardNo}/CardNoExist";
        public static final String DoctoridCardNoExistence = "/doctor/idCardNo/existence";
        public static final String DoctorOnlyUpdateD = "/doctors/updateOnlyDoctor";
        public Doctors() {
        }
        //私有库已存在
        //basic服务拆分之后追加
        public static final String GetDoctorById = "/doctors/GetDoctorById/{doctor_id}";
    }
}