소스 검색

医生表与用户表的头像同步

zdm 6 년 전
부모
커밋
9a9c947803

+ 34 - 1
src/main/java/com.yihu.ehr/basic/user/controller/DoctorEndPoint.java

@ -19,6 +19,7 @@ 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;
@ -85,6 +86,8 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private XFileResourceRepository resourceRepository;
    @Value("${fast-dfs.public-server}")
    private String fastDfsPublicServers;
    @RequestMapping(value = ServiceApi.Doctors.Doctors, method = RequestMethod.GET)
    @ApiOperation(value = "获取医生列表", notes = "根据查询条件获取医生列表在前端表格展示")
@ -589,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);
    }
@ -625,4 +630,32 @@ public class DoctorEndPoint extends EnvelopRestEndPoint {
        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 "";
    }
}

+ 22 - 1
src/main/java/com.yihu.ehr/basic/user/controller/UserEndPoint.java

@ -50,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.*;
@ -187,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());
@ -207,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)
@ -1265,4 +1273,17 @@ public class UserEndPoint extends EnvelopRestEndPoint {
        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");
    }
}

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

@ -58,4 +58,28 @@ public class BasicServiceApi {
    }
    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}";
    }
}