perf:代码结构调整
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package com.tiesheng.web.controller.comm;
|
||||
|
||||
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.IdDTO;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigEnum;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
|
||||
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
|
||||
import com.tiesheng.web.service.CoreConfigService;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/comm/web")
|
||||
public class CommWebController {
|
||||
|
||||
@Autowired
|
||||
CoreLogService coreLogService;
|
||||
@Autowired
|
||||
CoreConfigService coreConfigService;
|
||||
|
||||
/**
|
||||
* 系统配置列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/system/page")
|
||||
@TokenIgnore
|
||||
public ApiResp<List<CoreConfigSystem>> systemPage(String keyword) {
|
||||
|
||||
Validator.validateNotEmpty(keyword, "请上传关键字");
|
||||
|
||||
QueryWrapper<CoreConfigSystem> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
queryWrapper.likeRight("config_key", keyword);
|
||||
queryWrapper.orderByAsc("config_key");
|
||||
List<CoreConfigSystem> list = coreConfigService.list(queryWrapper);
|
||||
|
||||
return ApiResp.respOK(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取枚举列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/enum/list")
|
||||
@TokenIgnore
|
||||
public ApiResp<List<CoreConfigEnum>> enumList(EnumTypeDTO dto) {
|
||||
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_deleted", 0);
|
||||
queryWrapper.eq("type", dto.getType());
|
||||
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
||||
|
||||
return ApiResp.respOK(selectList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过程日志详情
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/process/detail")
|
||||
@TokenIgnore
|
||||
public ApiResp<ProcessDetailVo> processPage(@Valid IdDTO dto) {
|
||||
ProcessDetailVo processDetail = coreLogService.getProcessDetail(dto.getId());
|
||||
return ApiResp.respOK(processDetail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.tiesheng.web.controller.comm;
|
||||
|
||||
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import com.tiesheng.web.config.template.ToolTemplateHandler;
|
||||
import com.tiesheng.web.pojos.dto.*;
|
||||
import com.tiesheng.web.pojos.vo.TemplateInfoVO;
|
||||
import com.tiesheng.web.pojos.vo.PicVerifyVo;
|
||||
import com.tiesheng.web.service.FileUploadService;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @author hao
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tool")
|
||||
public class ToolController {
|
||||
|
||||
@Autowired
|
||||
TsCacheService tsCacheService;
|
||||
@Autowired
|
||||
FileUploadService fileUploadService;
|
||||
@Autowired
|
||||
List<ToolTemplateHandler> templateHandlerList;
|
||||
|
||||
|
||||
/**
|
||||
* 图片验证码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@GetMapping("/code/image")
|
||||
public ApiResp<PicVerifyVo> picVerifyV2(ImageCodeDTO dto) {
|
||||
|
||||
LineCaptcha lineCaptcha = dto.lineCaptcha();
|
||||
PicVerifyVo vo = new PicVerifyVo();
|
||||
vo.setBase64(lineCaptcha.getImageBase64Data());
|
||||
vo.setKey(IdUtil.simpleUUID());
|
||||
tsCacheService.put(vo.getKey(), lineCaptcha.getCode());
|
||||
|
||||
return ApiResp.respOK(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传整个文件
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/whole_upload")
|
||||
public ApiResp<String> fileWholeUpload(@RequestParam("file") MultipartFile file) {
|
||||
String filePath = fileUploadService.saveMultipartFile(file);
|
||||
return ApiResp.respOK(filePath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传超大文件,建议超过20M的使用这个方法
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping(value = "/file/chunk_start")
|
||||
public ApiResp<String> fileChunkStart(@RequestBody ChunkStartDTO dto) {
|
||||
fileUploadService.chunkStart(dto.getFileExt());
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验文件块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_check")
|
||||
public ApiResp<Boolean> fileChunkCheck(@RequestBody ChunkCheckDTO dto) {
|
||||
boolean exist = fileUploadService.chunkCheck(dto.getFileMd5(), dto.getChunk());
|
||||
return ApiResp.respOK(exist);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_upload")
|
||||
public ApiResp<String> fileChunkUpload(@RequestParam("file") MultipartFile file, String fileMd5, Integer chunk) {
|
||||
fileUploadService.chunkUpload(file, fileMd5, chunk);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 合并文件
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_merge")
|
||||
public ApiResp<String> fileChunkMerge(@RequestBody ChunkMergeDTO dto) {
|
||||
String path = fileUploadService.chunkMerge(dto.getFileMd5(), dto.getFileExt());
|
||||
return ApiResp.respOK(path);
|
||||
}
|
||||
|
||||
|
||||
@TokenIgnore
|
||||
@GetMapping("/template/info")
|
||||
public ApiResp<TemplateInfoVO> templateInfo(TemplateInfoDTO dto) {
|
||||
|
||||
List<ToolTemplateHandler> collect = templateHandlerList.stream()
|
||||
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("没有找到对应的模版");
|
||||
}
|
||||
|
||||
ToolTemplateHandler toolTemplateHandler = collect.get(0);
|
||||
|
||||
TemplateInfoVO template = new TemplateInfoVO();
|
||||
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
||||
template.setParams(toolTemplateHandler.getParms(dto.getParams()));
|
||||
template.setTemplateId(toolTemplateHandler.getTeamplateId());
|
||||
|
||||
return ApiResp.respOK(template);
|
||||
}
|
||||
|
||||
@TokenIgnore
|
||||
@PostMapping("/template/deal")
|
||||
public ApiResp<String> templateDeal(@RequestBody TemplateDealDTO dto) {
|
||||
|
||||
List<ToolTemplateHandler> collect = templateHandlerList.stream().
|
||||
filter(it -> Objects.equals(it.getTeamplateId(), dto.getTemplateId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("模版ID不存在");
|
||||
}
|
||||
|
||||
return ApiResp.respOK(collect.get(0).handler(dto));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user