修改上传 多上传图片的bug,修改h端获取医生列表的接口
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import net.coobird.thumbnailator.Thumbnails; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import sun.misc.BASE64Decoder; |
| | | import sun.misc.BASE64Encoder; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.io.*; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | |
| | | @Slf4j |
| | | public abstract class AbstractIFileService extends ServiceImpl<FileMapper, FileInfo> implements IFileService { |
| | | private static final String FILE_SPLIT = "."; |
| | | private static Logger logger = LoggerFactory.getLogger(AbstractIFileService.class); |
| | | |
| | | @Override |
| | | public FileInfo upload(MultipartFile file) throws Exception { |
| | |
| | | @Override |
| | | public FileInfo uploadForThumbnails(MultipartFile file, String imgType) throws Exception { |
| | | FileInfo fileInfo=this.upload(file,imgType); |
| | | List<String> lassStr= Arrays.asList("png","bmp","dib","gif","jfif","jpe","jpeg","jpg","tif","tiff","ico"); |
| | | String suffix=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); |
| | | if(!lassStr.contains(suffix)){ |
| | | return null; |
| | | } |
| | | if (StringUtils.isNotBlank(fileInfo.getUrl())) { |
| | | //生成缩略图上传 |
| | | File nowFile= MultipartFileUtils.multipartFileToFile(file); |
| | | // File nowFile= MultipartFileUtils.multipartFileToFile(file); |
| | | // File nowFile= new File(file.getOriginalFilename()); |
| | | //暂存目录 发布后真实存在的磁盘目录 |
| | | String result = CommonConstant.TEMP_IMAGE_PATH; |
| | | //文件扩展名 |
| | | String suffix=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | String newFileName= RandomValueUtils.uuid()+suffix; |
| | | String newFileName= RandomValueUtils.uuid()+"."+suffix; |
| | | //生成缩略图 |
| | | Thumbnails.of(nowFile).size(CommonConstant.TH_IMG_WIDTH, CommonConstant.TH_IMG_HEIGHT).toFile(result+newFileName); |
| | | Thumbnails.of(file.getInputStream()).size(CommonConstant.TH_IMG_WIDTH, CommonConstant.TH_IMG_HEIGHT).toFile(result+newFileName); |
| | | File thuFile= new File(result+newFileName); |
| | | if (thuFile.exists()) { |
| | | //将生成的文件转换为流 |
| | | InputStream inputStream=new FileInputStream(new File(result+newFileName)); |
| | | InputStream inputStream=new FileInputStream(thuFile); |
| | | String folderByDate = DateUtil.formatDate(new Date()); |
| | | String filefloder=this.FilePath(imgType,folderByDate); |
| | | FileInfo newfileInfo=new FileInfo(); |
| | |
| | | //文件上传到oss |
| | | this.fileUpLoadOss(newfileInfo,filefloder+newFileName,inputStream); |
| | | inputStream.close(); |
| | | //删除暂存文件 |
| | | MultipartFileUtils.delteTempFile(thuFile); |
| | | // //删除暂存文件 |
| | | // MultipartFileUtils.delteTempFile(thuFile); |
| | | boolean delete = thuFile.delete(); |
| | | |
| | | // 将文件信息保存到数据库 |
| | | baseMapper.insert(newfileInfo); |
| | | fileInfo.setPath(newfileInfo.getUrl()); |
| | |
| | | private String userName; |
| | | private boolean defaultAuth; |
| | | private boolean enabled; |
| | | private boolean isDel; |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long roleId; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | List<HospitalDoctorListVo> hospitalDoctorList(@Param("hospitalId") Long hospitalId, @Param("departmentId") Long departmentId,@Param("roleId1") Long roleId1,@Param("roleId2") Long roleId2); |
| | | /** |
| | | * 获取医院科室下的所有有效的医生 and 已经删除的 |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @param roleId1 管理员医生角色id |
| | | * @param roleId2 普通医生角色id |
| | | * @return |
| | | */ |
| | | List<HospitalDoctorListVo> hospitalDoctorListAndDel(@Param("hospitalId") Long hospitalId, @Param("departmentId") Long departmentId,@Param("roleId1") Long roleId1,@Param("roleId2") Long roleId2); |
| | | } |
| | |
| | | * @param departmentId |
| | | * @return |
| | | */ |
| | | ResultBody hospitalDoctorList(Long hospitalId, Long departmentId); |
| | | ResultBody hospitalDoctorList(Long hospitalId, Long departmentId,Boolean isdel); |
| | | /** |
| | | * 获取医院科室下的所有有效的医生 |
| | | * @param userTel |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody hospitalDoctorList(Long hospitalId, Long departmentId) { |
| | | public ResultBody hospitalDoctorList(Long hospitalId, Long departmentId,Boolean isIncluddel) { |
| | | if (hospitalId > 0 && departmentId > 0) { |
| | | List<HospitalDoctorListVo> listVoList = baseMapper.hospitalDoctorList(hospitalId, departmentId,CommonConstant.HOSPITAL_DOCTOR_ID,CommonConstant.HOSPITAL_ADMIN_ID); |
| | | List<HospitalDoctorListVo> listVoList; |
| | | if(isIncluddel){ |
| | | listVoList= baseMapper.hospitalDoctorListAndDel(hospitalId, departmentId,CommonConstant.HOSPITAL_DOCTOR_ID,CommonConstant.HOSPITAL_ADMIN_ID); |
| | | }else { |
| | | listVoList=baseMapper.hospitalDoctorList(hospitalId, departmentId,CommonConstant.HOSPITAL_DOCTOR_ID,CommonConstant.HOSPITAL_ADMIN_ID); |
| | | } |
| | | return ResultBody.ok().data(listVoList); |
| | | } else { |
| | | return ResultBody.failed("医院数据有误"); |
| | |
| | | us.username, |
| | | us.default_auth, |
| | | us.enabled, |
| | | roleuser.role_id |
| | | roleuser.role_id, |
| | | dc.is_del |
| | | FROM |
| | | sys_doctor dc |
| | | LEFT JOIN sys_user us ON dc.user_id = us.id |
| | |
| | | where dc.is_del=0 and dc.enabled=1 and dc.hospital_id=1 and dc.department_id=1 and us.enabled=1 |
| | | and dc.hospital_id=#{hospitalId} and dc.department_id=#{departmentId} and (role_id=#{roleId1} or role_id=#{roleId2}) |
| | | </select> |
| | | <select id="hospitalDoctorListAndDel" parameterType="long" resultType="com.kidgrow.usercenter.vo.HospitalDoctorListVo"> |
| | | SELECT |
| | | dc.create_time, |
| | | dc.department_name, |
| | | dc.hospital_name, |
| | | dc.doctor_name, |
| | | dc.doctor_rank, |
| | | dc.doctor_tel, |
| | | dc.id, |
| | | dc.user_id, |
| | | dc.is_admin_user, |
| | | dc.doctor_state, |
| | | us.mobile, |
| | | us.username, |
| | | us.default_auth, |
| | | us.enabled, |
| | | roleuser.role_id, |
| | | dc.is_del |
| | | FROM |
| | | sys_doctor dc |
| | | LEFT JOIN sys_user us ON dc.user_id = us.id |
| | | LEFT JOIN sys_role_user roleuser |
| | | ON roleuser.user_id=us.id |
| | | where dc.enabled=1 and dc.hospital_id=1 and dc.department_id=1 and us.enabled=1 |
| | | and dc.hospital_id=#{hospitalId} and dc.department_id=#{departmentId} and (role_id=#{roleId1} or role_id=#{roleId2}) |
| | | </select> |
| | | </mapper> |
| | |
| | | */ |
| | | @ApiOperation(value = "用户查询列表") |
| | | @GetMapping("/users/HDoctorusers") |
| | | public ResultBody hospitalDoctorList(@RequestParam Long hospitalId, Long departmentId) { |
| | | public ResultBody hospitalDoctorList(@RequestParam Long hospitalId, Long departmentId,boolean isIncluddel) { |
| | | if (StringUtils.isNotBlank(hospitalId.toString()) && StringUtils.isNotBlank(departmentId.toString())) { |
| | | return appUserService.hospitalDoctorList(hospitalId, departmentId); |
| | | return appUserService.hospitalDoctorList(hospitalId, departmentId,isIncluddel); |
| | | } else { |
| | | return ResultBody.failed("查询参数有误"); |
| | | } |