parent
5073453f18
commit
b5c8486364
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.chushang.oss.constants;
|
||||||
|
|
||||||
|
public interface OssConstants {
|
||||||
|
String OSS_SERVICE = "oss-service";
|
||||||
|
String APPLICATION_CONTENT_PATH = "/oss";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.chushang.oss.feign;
|
||||||
|
|
||||||
|
import com.chushang.common.core.constant.SecurityConstants;
|
||||||
|
import com.chushang.common.core.web.AjaxResult;
|
||||||
|
import com.chushang.common.core.web.Result;
|
||||||
|
import com.chushang.oss.constants.OssConstants;
|
||||||
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(contextId = "ossFeign",
|
||||||
|
value = OssConstants.OSS_SERVICE,
|
||||||
|
path = OssConstants.APPLICATION_CONTENT_PATH + "/remote/file"
|
||||||
|
)
|
||||||
|
public interface RemoteOssService {
|
||||||
|
|
||||||
|
@PostMapping(value = "/upload")
|
||||||
|
Result<List<FileSourceVo>> uploadFile(@RequestParam(value = "files") MultipartFile[] files,
|
||||||
|
@RequestParam(value = "ocrType", required = false) String ocrType,
|
||||||
|
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
||||||
|
@RequestParam(value = "formats", required = false) String formats,
|
||||||
|
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import com.chushang.oss.entity.FileSourceInfo;
|
||||||
import com.chushang.oss.entity.dto.OcrDTO;
|
import com.chushang.oss.entity.dto.OcrDTO;
|
||||||
import com.chushang.oss.entity.vo.FileSourceVo;
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
import com.chushang.oss.enums.OcrTypeEnum;
|
import com.chushang.oss.enums.OcrTypeEnum;
|
||||||
|
import com.chushang.oss.remote.RemoteFileController;
|
||||||
import com.chushang.oss.service.FileSourceService;
|
import com.chushang.oss.service.FileSourceService;
|
||||||
import com.chushang.oss.service.OcrService;
|
import com.chushang.oss.service.OcrService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -31,9 +32,6 @@ public class FileController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
FileSourceService fileSourceService;
|
FileSourceService fileSourceService;
|
||||||
@Resource
|
|
||||||
OcrService ocrService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传
|
* 文件上传
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,24 +42,7 @@ public class FileController {
|
||||||
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
@RequestParam(value = "sealFlag", required = false, defaultValue= "false") Boolean sealFlag,
|
||||||
@RequestParam(value = "formats", required = false) String formats)
|
@RequestParam(value = "formats", required = false) String formats)
|
||||||
{
|
{
|
||||||
List<FileSourceVo> result = new ArrayList<>();
|
return AjaxResult.success(fileSourceService.addFile(files, ocrType, sealFlag, formats));
|
||||||
for (MultipartFile file : files) {
|
|
||||||
FileSourceVo info = fileSourceService.addFile(file, sealFlag, formats);
|
|
||||||
if (StrUtil.isNotEmpty(ocrType)) {
|
|
||||||
OcrDTO ocr = new OcrDTO();
|
|
||||||
OcrTypeEnum ocrTypeEnum = OcrTypeEnum.findByCode(ocrType);
|
|
||||||
if (ocrTypeEnum != OcrTypeEnum.NONE) {
|
|
||||||
ocr.setOcrType(ocrTypeEnum);
|
|
||||||
ocr.setImgPath(info.getFilePath());
|
|
||||||
Result<JSONObject> ocrInfo = ocrService.ocr(ocr);
|
|
||||||
if (ocrInfo.isSuccess()) {
|
|
||||||
info.setOcr(ocrInfo.getData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.add(info);
|
|
||||||
}
|
|
||||||
return AjaxResult.success(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value="/{fid}/preview")
|
@GetMapping(value="/{fid}/preview")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.chushang.oss.remote;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.chushang.common.core.web.AjaxResult;
|
||||||
|
import com.chushang.common.core.web.Result;
|
||||||
|
import com.chushang.common.log.annotation.SysLog;
|
||||||
|
import com.chushang.common.log.enums.BusinessType;
|
||||||
|
import com.chushang.oss.entity.dto.OcrDTO;
|
||||||
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
|
import com.chushang.oss.enums.OcrTypeEnum;
|
||||||
|
import com.chushang.oss.feign.RemoteOssService;
|
||||||
|
import com.chushang.oss.service.FileSourceService;
|
||||||
|
import com.chushang.oss.service.OcrService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/file/remote")
|
||||||
|
public class RemoteFileController implements RemoteOssService {
|
||||||
|
@Resource
|
||||||
|
FileSourceService fileSourceService;
|
||||||
|
@Override
|
||||||
|
@SysLog(value = "feign文件上传", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping(value = "/upload")
|
||||||
|
public Result<List<FileSourceVo>> uploadFile(MultipartFile[] files, String ocrType, Boolean sealFlag, String formats, String source) {
|
||||||
|
return Result.ok(fileSourceService.addFile(files, ocrType, sealFlag, formats));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -14,7 +16,9 @@ import com.chushang.common.core.util.IPUtils;
|
||||||
import com.chushang.common.core.util.ServletUtils;
|
import com.chushang.common.core.util.ServletUtils;
|
||||||
import com.chushang.common.mybatis.enums.Operator;
|
import com.chushang.common.mybatis.enums.Operator;
|
||||||
import com.chushang.oss.entity.FileSourceInfo;
|
import com.chushang.oss.entity.FileSourceInfo;
|
||||||
|
import com.chushang.oss.entity.dto.OcrDTO;
|
||||||
import com.chushang.oss.entity.vo.FileSourceVo;
|
import com.chushang.oss.entity.vo.FileSourceVo;
|
||||||
|
import com.chushang.oss.enums.OcrTypeEnum;
|
||||||
import com.chushang.oss.mapper.FileSourceMapper;
|
import com.chushang.oss.mapper.FileSourceMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
@ -31,6 +35,7 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,6 +52,8 @@ public class FileSourceService
|
||||||
OssService ossService;
|
OssService ossService;
|
||||||
@Resource
|
@Resource
|
||||||
RedissonClient redissonClient;
|
RedissonClient redissonClient;
|
||||||
|
@Resource
|
||||||
|
OcrService ocrService;
|
||||||
@Value("${config.oss.storage}")
|
@Value("${config.oss.storage}")
|
||||||
private String storage;
|
private String storage;
|
||||||
|
|
||||||
|
|
@ -63,7 +70,8 @@ public class FileSourceService
|
||||||
* @param sealFlag
|
* @param sealFlag
|
||||||
* @param formats
|
* @param formats
|
||||||
*/
|
*/
|
||||||
public FileSourceVo addFile(MultipartFile file, Boolean sealFlag, String formats) {
|
public FileSourceVo addFile(MultipartFile file, Boolean sealFlag, String formats)
|
||||||
|
{
|
||||||
String ip = IPUtils.clientIp(ServletUtils.getRequest());
|
String ip = IPUtils.clientIp(ServletUtils.getRequest());
|
||||||
String fid = generateFid();
|
String fid = generateFid();
|
||||||
String fName = file.getOriginalFilename();
|
String fName = file.getOriginalFilename();
|
||||||
|
|
@ -113,6 +121,24 @@ public class FileSourceService
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FileSourceVo> addFile(MultipartFile[] files,String ocrType, Boolean sealFlag, String formats){
|
||||||
|
List<FileSourceVo> result = new ArrayList<>();
|
||||||
|
for (MultipartFile file : files) {
|
||||||
|
FileSourceVo info = addFile(file, sealFlag, formats);
|
||||||
|
if (StrUtil.isNotEmpty(ocrType)) {
|
||||||
|
OcrDTO ocr = new OcrDTO();
|
||||||
|
OcrTypeEnum ocrTypeEnum = OcrTypeEnum.findByCode(ocrType);
|
||||||
|
if (ocrTypeEnum != OcrTypeEnum.NONE) {
|
||||||
|
ocr.setOcrType(ocrTypeEnum);
|
||||||
|
ocr.setImgPath(info.getFilePath());
|
||||||
|
JSONObject ocrInfo = ocrService.ocr(ocr);
|
||||||
|
info.setOcr(ocrInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.add(info);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void getFileStream(String fid, HttpServletResponse response, boolean convertText) {
|
public void getFileStream(String fid, HttpServletResponse response, boolean convertText) {
|
||||||
// 文件信息
|
// 文件信息
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ import com.chushang.common.core.web.Result;
|
||||||
import com.chushang.oss.entity.dto.OcrDTO;
|
import com.chushang.oss.entity.dto.OcrDTO;
|
||||||
|
|
||||||
public interface OcrService {
|
public interface OcrService {
|
||||||
Result<JSONObject> ocr(OcrDTO ocr);
|
JSONObject ocr(OcrDTO ocr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.chushang.oss.service.impl;
|
package com.chushang.oss.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.chushang.common.core.exception.ResultException;
|
||||||
import com.chushang.common.core.web.Result;
|
import com.chushang.common.core.web.Result;
|
||||||
import com.chushang.oss.entity.dto.OcrDTO;
|
import com.chushang.oss.entity.dto.OcrDTO;
|
||||||
import com.chushang.oss.service.OcrService;
|
import com.chushang.oss.service.OcrService;
|
||||||
|
|
@ -14,8 +15,8 @@ public class OcrServiceImpl implements OcrService {
|
||||||
* 尚未接入ocr
|
* 尚未接入ocr
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result<JSONObject> ocr(OcrDTO ocr) {
|
public JSONObject ocr(OcrDTO ocr) {
|
||||||
log.error("尚未接入ocr");
|
log.error("尚未接入ocr");
|
||||||
return Result.failed("尚未接入ocr");
|
throw new ResultException("尚未接入ocr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ package com.chushang.system.constants;
|
||||||
*/
|
*/
|
||||||
public interface SystemConstants {
|
public interface SystemConstants {
|
||||||
String SYSTEM_SERVICE = "system-service";
|
String SYSTEM_SERVICE = "system-service";
|
||||||
String APPLICATION_NAME = "/system";
|
String APPLICATION_CONTENT_PATH = "/system";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.chushang.system.feign;
|
|
||||||
|
|
||||||
import com.chushang.common.core.constant.SecurityConstants;
|
|
||||||
import com.chushang.datascope.entity.DataScopeEntity;
|
|
||||||
import com.chushang.system.constants.SystemConstants;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于数据权限 判断远程调用
|
|
||||||
*/
|
|
||||||
@FeignClient(contextId = "remoteDataScopeService",
|
|
||||||
value = SystemConstants.SYSTEM_SERVICE,
|
|
||||||
path = SystemConstants.APPLICATION_NAME + "/data/scope"
|
|
||||||
)
|
|
||||||
public interface RemoteDataScopeService {
|
|
||||||
|
|
||||||
@GetMapping(value = "/dept/list")
|
|
||||||
public List<String> listDeptIds(@RequestParam(value = "dataScope") DataScopeEntity dataScope,
|
|
||||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "remoteLoginInfoService",
|
@FeignClient(contextId = "remoteLoginInfoService",
|
||||||
value = SystemConstants.SYSTEM_SERVICE,
|
value = SystemConstants.SYSTEM_SERVICE,
|
||||||
path = SystemConstants.APPLICATION_NAME + "/log"
|
path = SystemConstants.APPLICATION_CONTENT_PATH + "/log/remote"
|
||||||
)
|
)
|
||||||
public interface RemoteLoginInfoService {
|
public interface RemoteLoginInfoService {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "remoteUserService",
|
@FeignClient(contextId = "remoteUserService",
|
||||||
value = SystemConstants.SYSTEM_SERVICE,
|
value = SystemConstants.SYSTEM_SERVICE,
|
||||||
path = SystemConstants.APPLICATION_NAME + "/user"
|
path = SystemConstants.APPLICATION_CONTENT_PATH + "/user/remote"
|
||||||
)
|
)
|
||||||
public interface RemoteUserService {
|
public interface RemoteUserService {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package com.chushang.system.remote;
|
|
||||||
|
|
||||||
import com.chushang.datascope.entity.DataScopeEntity;
|
|
||||||
import com.chushang.system.feign.RemoteDataScopeService;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "/data/scope")
|
|
||||||
public class RemoteDataScopeController implements RemoteDataScopeService {
|
|
||||||
/**
|
|
||||||
* 获取对应的部门数据
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@GetMapping(value ="/dept/list")
|
|
||||||
public List<String> listDeptIds(@RequestParam(value = "dataScope") DataScopeEntity dataScope, String source)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/log/login/info")
|
@RequestMapping(value = "/log/remote")
|
||||||
public class RemoteLoginInfoController implements RemoteLoginInfoService {
|
public class RemoteLoginInfoController implements RemoteLoginInfoService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -25,7 +25,7 @@ public class RemoteLoginInfoController implements RemoteLoginInfoService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@InnerAuth
|
@InnerAuth
|
||||||
@PostMapping
|
@PostMapping("/login/info")
|
||||||
public Result<Boolean> saveLoginInfo(@RequestBody SysLoginInfo sysLogininfo, String source) {
|
public Result<Boolean> saveLoginInfo(@RequestBody SysLoginInfo sysLogininfo, String source) {
|
||||||
return Result.ok(sysLoginInfoService.saveLoginInfo(sysLogininfo).isSuccess());
|
return Result.ok(sysLoginInfoService.saveLoginInfo(sysLogininfo).isSuccess());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/user")
|
@RequestMapping(value = "/user/remote")
|
||||||
public class RemoteUserController implements RemoteUserService {
|
public class RemoteUserController implements RemoteUserService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue