|
|
|
|
@ -19,8 +19,15 @@ package org.springblade.modules.system.controller; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
|
import io.minio.GetObjectArgs; |
|
|
|
|
import io.minio.MinioClient; |
|
|
|
|
import io.minio.ObjectArgs; |
|
|
|
|
import io.minio.ObjectReadArgs; |
|
|
|
|
import io.minio.errors.*; |
|
|
|
|
import io.swagger.annotations.*; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springblade.common.cache.DictCache; |
|
|
|
|
import org.springblade.common.cache.UserCache; |
|
|
|
|
import org.springblade.common.constant.BusinessConstant; |
|
|
|
|
@ -29,6 +36,8 @@ import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.cache.utils.CacheUtil; |
|
|
|
|
import org.springblade.core.launch.constant.AppConstant; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.oss.MinioTemplate; |
|
|
|
|
import org.springblade.core.oss.OssTemplate; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.annotation.PreAuth; |
|
|
|
|
import org.springblade.core.secure.constant.AuthConstant; |
|
|
|
|
@ -38,6 +47,8 @@ import org.springblade.core.tool.constant.BladeConstant; |
|
|
|
|
import org.springblade.core.tool.constant.RoleConstant; |
|
|
|
|
import org.springblade.core.tool.support.Kv; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.modules.resource.builder.oss.OssBuilder; |
|
|
|
|
import org.springblade.modules.system.entity.Dept; |
|
|
|
|
import org.springblade.modules.system.entity.User; |
|
|
|
|
import org.springblade.modules.system.service.IDeptService; |
|
|
|
|
@ -46,7 +57,16 @@ import org.springblade.modules.system.wrapper.DeptWrapper; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.net.MalformedURLException; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.net.URLConnection; |
|
|
|
|
import java.security.InvalidKeyException; |
|
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
|
import java.util.Base64; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
@ -59,24 +79,97 @@ import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
|
|
|
|
*/ |
|
|
|
|
@NonDS |
|
|
|
|
@RestController |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/dept-hospital") |
|
|
|
|
@Api(value = "部门", tags = "部门") |
|
|
|
|
public class DeptHospitalController extends BladeController { |
|
|
|
|
|
|
|
|
|
private final IDeptService deptService; |
|
|
|
|
/** |
|
|
|
|
* minio config |
|
|
|
|
*/ |
|
|
|
|
private static final String endpoint = "http://127.0.0.1:9090"; |
|
|
|
|
/** |
|
|
|
|
* minio config |
|
|
|
|
*/ |
|
|
|
|
private static final String accessKey = "sCBy0KAcufwBzqXL"; |
|
|
|
|
/** |
|
|
|
|
* minio config |
|
|
|
|
*/ |
|
|
|
|
private static final String secretKey = "zgiZQbVrpOwwLyXLxKMGEl5XOYso65WX"; |
|
|
|
|
/** |
|
|
|
|
* minio config |
|
|
|
|
*/ |
|
|
|
|
private static final String bucketName = "hcu-cgs"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 列表-医院 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/list-hospital") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@ApiOperation(value = "列表-医院", notes = "列表-医院") |
|
|
|
|
public R<List<DeptVO>> listHospital() { |
|
|
|
|
List<Dept> list = deptService.list(Wrappers.<Dept>lambdaQuery() |
|
|
|
|
.eq(Dept::getDeptCategory, BusinessConstant.DEPT_CATEGORY_HOSPITAL) |
|
|
|
|
.orderByAsc(Dept::getSort)); |
|
|
|
|
return R.data(DeptWrapper.build().listNodeVO(list)); |
|
|
|
|
} |
|
|
|
|
@Resource |
|
|
|
|
private IDeptService deptService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Access Key: |
|
|
|
|
* sCBy0KAcufwBzqXL |
|
|
|
|
* Secret Key: |
|
|
|
|
* zgiZQbVrpOwwLyXLxKMGEl5XOYso65WX |
|
|
|
|
*/ |
|
|
|
|
private MinioClient minioClient; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 列表-医院 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/list-hospital") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@ApiOperation(value = "列表-医院", notes = "列表-医院") |
|
|
|
|
public R<List<DeptVO>> listHospital() { |
|
|
|
|
List<Dept> list = deptService.list(Wrappers.<Dept>lambdaQuery() |
|
|
|
|
.eq(Dept::getDeptCategory, BusinessConstant.DEPT_CATEGORY_HOSPITAL) |
|
|
|
|
.orderByAsc(Dept::getSort)); |
|
|
|
|
List<DeptVO> listVo = DeptWrapper.build().listNodeVO(list); |
|
|
|
|
for (DeptVO vo : listVo) { |
|
|
|
|
if (StringUtil.isNotBlank(vo.getImgUrl())) { |
|
|
|
|
// minio
|
|
|
|
|
// String domain = "http://www.qdscgs.com:9091";
|
|
|
|
|
// String domain = "http://127.0.0.1:9091";
|
|
|
|
|
String imgUrl = vo.getImgUrl(); |
|
|
|
|
// 替换/hcu-cgs/前缀
|
|
|
|
|
if (StringUtils.isNotBlank(imgUrl) && |
|
|
|
|
StringUtils.startsWith(imgUrl, "/hcu-cgs/")) { |
|
|
|
|
imgUrl = StringUtils.removeStart(imgUrl, "/hcu-cgs/"); |
|
|
|
|
} |
|
|
|
|
vo.setImgBase64(convertImgToBase64(imgUrl)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return R.data(listVo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 对图片进行base64编码。 |
|
|
|
|
* |
|
|
|
|
* @param imageUrl bucket中文件地址 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String convertImgToBase64(final String imageUrl) { |
|
|
|
|
if (minioClient == null) { |
|
|
|
|
minioClient = MinioClient.builder() |
|
|
|
|
.endpoint(endpoint) |
|
|
|
|
.credentials(accessKey, secretKey) |
|
|
|
|
.build(); |
|
|
|
|
} |
|
|
|
|
InputStream in = null; |
|
|
|
|
try { |
|
|
|
|
in = minioClient.getObject( |
|
|
|
|
GetObjectArgs.builder().bucket(bucketName).object(imageUrl).build() |
|
|
|
|
); |
|
|
|
|
byte[] imageBytes = IOUtils.toByteArray(in); |
|
|
|
|
Base64.Encoder encoder = Base64.getEncoder(); |
|
|
|
|
return encoder.encodeToString(imageBytes); |
|
|
|
|
} catch (IOException | ServerException | InsufficientDataException | |
|
|
|
|
ErrorResponseException | NoSuchAlgorithmException | InvalidKeyException | |
|
|
|
|
InvalidResponseException | XmlParserException | InternalException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
IOUtils.close(in); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|