|
|
package com.bs.cm.controller;
|
|
|
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.bs.cm.domain.CmAttach;
|
|
|
import com.bs.cm.service.ICmAttachService;
|
|
|
import com.bs.common.annotation.Log;
|
|
|
import com.bs.common.core.controller.BaseController;
|
|
|
import com.bs.common.core.domain.AjaxResult;
|
|
|
import com.bs.common.core.page.TableDataInfo;
|
|
|
import com.bs.common.enums.BusinessType;
|
|
|
import com.bs.common.utils.poi.ExcelUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.xmlbeans.impl.validator.ValidatorUtil;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 附件信息Controller
|
|
|
*
|
|
|
* @author bs
|
|
|
* @date 2024-03-03
|
|
|
*/
|
|
|
@Api(tags = "附件信息")
|
|
|
@RestController
|
|
|
@RequestMapping("/cm/attach")
|
|
|
public class CmAttachController extends BaseController {
|
|
|
@Resource
|
|
|
private ICmAttachService cmAttachService;
|
|
|
|
|
|
/**
|
|
|
* 分页查询附件信息列表
|
|
|
*/
|
|
|
@ApiOperation("分页查询附件信息列表")
|
|
|
@GetMapping("/pageList")
|
|
|
public TableDataInfo pageList(CmAttach cmAttach) {
|
|
|
startPage();
|
|
|
LambdaQueryWrapper<CmAttach> queryWrapper = new LambdaQueryWrapper();
|
|
|
condition(queryWrapper, cmAttach);
|
|
|
List<CmAttach> list = cmAttachService.list(queryWrapper);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/api/file/upload")
|
|
|
@ApiOperation("文件上传")
|
|
|
@Log(title = "文件上传", businessType = BusinessType.OTHER)
|
|
|
// @RepeatSubmit 有点小问题 先注释
|
|
|
public AjaxResult upload(@RequestParam String fileId, CmAttach attach, @RequestParam("files") MultipartFile[] files) {
|
|
|
if (StringUtils.isBlank(fileId) || "null".equals(fileId)) {
|
|
|
return AjaxResult.error("fileId不能为空");
|
|
|
}
|
|
|
if (Validator.isEmpty(files)) {
|
|
|
return AjaxResult.error("上传文件不可为空!");
|
|
|
}
|
|
|
return AjaxResult.success(cmAttachService.uploadFileBatch(files, fileId)) ;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询附件信息列表
|
|
|
*/
|
|
|
@ApiOperation("查询附件信息列表")
|
|
|
@GetMapping("/list")
|
|
|
public AjaxResult list(CmAttach cmAttach) {
|
|
|
LambdaQueryWrapper<CmAttach> queryWrapper = new LambdaQueryWrapper();
|
|
|
condition(queryWrapper, cmAttach);
|
|
|
List<CmAttach> list = cmAttachService.list(queryWrapper);
|
|
|
return success(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出附件信息列表
|
|
|
*/
|
|
|
@ApiOperation("导出附件信息列表")
|
|
|
@Log(title = "附件信息导出", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
public void export(HttpServletResponse response, CmAttach cmAttach) {
|
|
|
LambdaQueryWrapper<CmAttach> queryWrapper = new LambdaQueryWrapper();
|
|
|
condition(queryWrapper, cmAttach);
|
|
|
List<CmAttach> list = cmAttachService.list(queryWrapper);
|
|
|
ExcelUtil<CmAttach> util = new ExcelUtil<CmAttach>(CmAttach.class);
|
|
|
util.exportExcel(response, list, "附件信息数据");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取附件信息详细信息
|
|
|
*/
|
|
|
@ApiOperation("获取附件信息详细信息")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return success(cmAttachService.getById(id));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增附件信息
|
|
|
*/
|
|
|
@ApiOperation("新增附件信息")
|
|
|
@Log(title = "附件信息新增", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody CmAttach cmAttach) {
|
|
|
return toAjax(cmAttachService.save(cmAttach));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改附件信息
|
|
|
*/
|
|
|
@ApiOperation("修改附件信息")
|
|
|
@Log(title = "附件信息修改", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody CmAttach cmAttach) {
|
|
|
return toAjax(cmAttachService.updateById(cmAttach));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除附件信息
|
|
|
*/
|
|
|
@ApiOperation("删除附件信息")
|
|
|
@Log(title = "附件信息删除", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
|
return toAjax(cmAttachService.removeBatchByIds(ids));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 条件设置
|
|
|
*/
|
|
|
private void condition(LambdaQueryWrapper<CmAttach> queryWrapper, CmAttach cmAttach) {
|
|
|
//用户id
|
|
|
if (Validator.isNotEmpty(cmAttach.getId())) {
|
|
|
queryWrapper.eq(CmAttach::getId, cmAttach.getId());
|
|
|
}
|
|
|
|
|
|
//文件组id
|
|
|
if (Validator.isNotEmpty(cmAttach.getFileId())) {
|
|
|
queryWrapper.eq(CmAttach::getFileId, cmAttach.getFileId());
|
|
|
}
|
|
|
|
|
|
//文件排序
|
|
|
if (Validator.isNotEmpty(cmAttach.getFileSort())) {
|
|
|
queryWrapper.eq(CmAttach::getFileSort, cmAttach.getFileSort());
|
|
|
}
|
|
|
|
|
|
//文件名称(编译后)
|
|
|
if (Validator.isNotEmpty(cmAttach.getAttachName())) {
|
|
|
queryWrapper.eq(CmAttach::getAttachName, cmAttach.getAttachName());
|
|
|
}
|
|
|
|
|
|
//文件类型
|
|
|
if (Validator.isNotEmpty(cmAttach.getAttachFileType())) {
|
|
|
queryWrapper.eq(CmAttach::getAttachFileType, cmAttach.getAttachFileType());
|
|
|
}
|
|
|
|
|
|
//文件编码类型
|
|
|
if (Validator.isNotEmpty(cmAttach.getAttachContentType())) {
|
|
|
queryWrapper.eq(CmAttach::getAttachContentType, cmAttach.getAttachContentType());
|
|
|
}
|
|
|
|
|
|
//文件大小
|
|
|
if (Validator.isNotEmpty(cmAttach.getAttachFileSize())) {
|
|
|
queryWrapper.eq(CmAttach::getAttachFileSize, cmAttach.getAttachFileSize());
|
|
|
}
|
|
|
|
|
|
//文件路径
|
|
|
if (Validator.isNotEmpty(cmAttach.getAttachFileUrl())) {
|
|
|
queryWrapper.eq(CmAttach::getAttachFileUrl, cmAttach.getAttachFileUrl());
|
|
|
}
|
|
|
|
|
|
//文件名(原始)
|
|
|
if (Validator.isNotEmpty(cmAttach.getOldName())) {
|
|
|
queryWrapper.eq(CmAttach::getOldName, cmAttach.getOldName());
|
|
|
}
|
|
|
|
|
|
//文件版本号
|
|
|
if (Validator.isNotEmpty(cmAttach.getVersionNo())) {
|
|
|
queryWrapper.eq(CmAttach::getVersionNo, cmAttach.getVersionNo());
|
|
|
}
|
|
|
|
|
|
//创建部门
|
|
|
if (Validator.isNotEmpty(cmAttach.getCreateDept())) {
|
|
|
queryWrapper.eq(CmAttach::getCreateDept, cmAttach.getCreateDept());
|
|
|
}
|
|
|
|
|
|
//创建人
|
|
|
if (Validator.isNotEmpty(cmAttach.getCreateBy())) {
|
|
|
queryWrapper.eq(CmAttach::getCreateBy, cmAttach.getCreateBy());
|
|
|
}
|
|
|
|
|
|
//创建时间
|
|
|
if (Validator.isNotEmpty(cmAttach.getCreateTime())) {
|
|
|
queryWrapper.eq(CmAttach::getCreateTime, cmAttach.getCreateTime());
|
|
|
}
|
|
|
|
|
|
//修改人
|
|
|
if (Validator.isNotEmpty(cmAttach.getUpdateBy())) {
|
|
|
queryWrapper.eq(CmAttach::getUpdateBy, cmAttach.getUpdateBy());
|
|
|
}
|
|
|
|
|
|
//修改时间
|
|
|
if (Validator.isNotEmpty(cmAttach.getUpdateTime())) {
|
|
|
queryWrapper.eq(CmAttach::getUpdateTime, cmAttach.getUpdateTime());
|
|
|
}
|
|
|
|
|
|
//备注
|
|
|
if (Validator.isNotEmpty(cmAttach.getRemark())) {
|
|
|
queryWrapper.eq(CmAttach::getRemark, cmAttach.getRemark());
|
|
|
}
|
|
|
|
|
|
//删除标志(0代表存在 2代表删除)
|
|
|
if (Validator.isNotEmpty(cmAttach.getDelFlag())) {
|
|
|
queryWrapper.eq(CmAttach::getDelFlag, cmAttach.getDelFlag());
|
|
|
}
|
|
|
|
|
|
//${column.columnComment}
|
|
|
if (Validator.isNotEmpty(cmAttach.getTenantId())) {
|
|
|
queryWrapper.eq(CmAttach::getTenantId, cmAttach.getTenantId());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|