会计附件
parent
5f1f752dc9
commit
5e495796bb
@ -0,0 +1,49 @@
|
|||||||
|
-- ----------------------------
|
||||||
|
-- 会计附件表 for accounting_attachment
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `accounting_attachment`;
|
||||||
|
CREATE TABLE `accounting_attachment` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`voucher_id` bigint(20) NOT NULL COMMENT '凭证id 一个凭证对应多个附件',
|
||||||
|
`voucher_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '凭证号',
|
||||||
|
`business_id` bigint(20) NULL DEFAULT NULL COMMENT '业务id',
|
||||||
|
`business_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务类型',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制单人',
|
||||||
|
`creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`company_id` bigint(20) NULL DEFAULT NULL COMMENT '业务实体id',
|
||||||
|
`company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务实体',
|
||||||
|
`suffix` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件后缀',
|
||||||
|
`file_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件地址',
|
||||||
|
`file_ap` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '绝对路径',
|
||||||
|
`flow_id` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '流程号',
|
||||||
|
`user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
|
||||||
|
`deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除',
|
||||||
|
`note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要',
|
||||||
|
`dept_id` bigint(20) NULL DEFAULT NULL COMMENT '所属部门id',
|
||||||
|
`dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属部门',
|
||||||
|
`tenant_id` bigint(20) NOT NULL COMMENT '租户编号 一个集团/总公司对应一个租户',
|
||||||
|
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
`attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段1',
|
||||||
|
`attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段2',
|
||||||
|
`attr3` int(11) NULL DEFAULT NULL COMMENT '预留字段3',
|
||||||
|
`attr4` int(11) NULL DEFAULT NULL COMMENT '预留字段4',
|
||||||
|
`flow_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'OA/ERP流程编号',
|
||||||
|
`file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名',
|
||||||
|
`file_size` int(11) NULL DEFAULT NULL COMMENT '文件大小',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会计附件表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
|
-- 插入菜单
|
||||||
|
SELECT `id` INTO @menuId FROM `system_menu` WHERE `name`='会计档案';
|
||||||
|
INSERT INTO `lyr-one`.`system_menu` (`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('会计附件管理', '', 2, 0, @menuId, 'attachment', '', 'accounting/attachment/index', 'Attachment', 0, b'1', b'1', b'1', '', '2023-10-07 16:36:16', '', '2023-10-07 16:36:16', b'0');
|
||||||
|
SET @menuId2 = LAST_INSERT_ID();
|
||||||
|
INSERT INTO `lyr-one`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '会计附件查询', 'accounting:attachment:query', 3, 1, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-07 16:36:16', '', '2023-10-07 16:36:16', b'0');
|
||||||
|
INSERT INTO `lyr-one`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '会计附件创建', 'accounting:attachment:create', 3, 2, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-07 16:36:16', '', '2023-10-07 16:36:16', b'0');
|
||||||
|
INSERT INTO `lyr-one`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '会计附件更新', 'accounting:attachment:update', 3, 3, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-07 16:36:16', '', '2023-10-07 16:36:16', b'0');
|
||||||
|
INSERT INTO `lyr-one`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '会计附件删除', 'accounting:attachment:delete', 3, 4, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-07 16:36:16', '', '2023-10-07 16:36:16', b'0');
|
||||||
|
INSERT INTO `lyr-one`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '会计附件导出', 'accounting:attachment:export', 3, 5, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-07 16:36:16', '', '2023-10-07 16:36:16', b'0');
|
@ -0,0 +1,122 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.attachment;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||||
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.convert.attachment.AttachmentConvert;
|
||||||
|
import cn.iocoder.yudao.module.accounting.service.attachment.AttachmentService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 会计附件")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/accounting/attachment")
|
||||||
|
@Validated
|
||||||
|
public class AttachmentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AttachmentService attachmentService;
|
||||||
|
@Resource
|
||||||
|
private FileService fileService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建会计附件")
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:create')")
|
||||||
|
public CommonResult<Long> createAttachment(@Valid @RequestBody AttachmentCreateReqVO createReqVO) {
|
||||||
|
return success(attachmentService.createAttachment(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
@Operation(summary = "上传会计附件")
|
||||||
|
@Parameter(name = "multipartFile", description = "文件", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:other:create')")
|
||||||
|
public CommonResult<FileDO> upload(@RequestParam("multipartFile") MultipartFile multipartFile) throws IOException {
|
||||||
|
String fileUrl = fileService.createFile(multipartFile.getOriginalFilename(), null, IoUtil.readBytes(multipartFile.getInputStream()));
|
||||||
|
FilePageReqVO pageReqVO = new FilePageReqVO();
|
||||||
|
String lastSegment = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
|
||||||
|
pageReqVO.setPath(lastSegment);
|
||||||
|
PageResult<FileDO> filePage = fileService.getFilePage(pageReqVO);
|
||||||
|
return success(filePage.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新会计附件")
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:update')")
|
||||||
|
public CommonResult<Boolean> updateAttachment(@Valid @RequestBody AttachmentUpdateReqVO updateReqVO) {
|
||||||
|
attachmentService.updateAttachment(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除会计附件")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:delete')")
|
||||||
|
public CommonResult<Boolean> deleteAttachment(@RequestParam("id") Long id) {
|
||||||
|
attachmentService.deleteAttachment(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得会计附件")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:query')")
|
||||||
|
public CommonResult<AttachmentRespVO> getAttachment(@RequestParam("id") Long id) {
|
||||||
|
AttachmentDO attachment = attachmentService.getAttachment(id);
|
||||||
|
return success(AttachmentConvert.INSTANCE.convert(attachment));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "获得会计附件列表")
|
||||||
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:query')")
|
||||||
|
public CommonResult<List<AttachmentRespVO>> getAttachmentList(@RequestParam("ids") Collection<Long> ids) {
|
||||||
|
List<AttachmentDO> list = attachmentService.getAttachmentList(ids);
|
||||||
|
return success(AttachmentConvert.INSTANCE.convertList(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得会计附件分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:query')")
|
||||||
|
public CommonResult<PageResult<AttachmentRespVO>> getAttachmentPage(@Valid AttachmentPageReqVO pageVO) {
|
||||||
|
PageResult<AttachmentDO> pageResult = attachmentService.getAttachmentPage(pageVO);
|
||||||
|
return success(AttachmentConvert.INSTANCE.convertPage(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出会计附件 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('accounting:attachment:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportAttachmentExcel(@Valid AttachmentExportReqVO exportReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
List<AttachmentDO> list = attachmentService.getAttachmentList(exportReqVO);
|
||||||
|
// 导出 Excel
|
||||||
|
List<AttachmentExcelVO> datas = AttachmentConvert.INSTANCE.convertList02(list);
|
||||||
|
ExcelUtils.write(response, "会计附件.xls", "数据", AttachmentExcelVO.class, datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 会计附件创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AttachmentCreateReqVO extends AttachmentBaseVO {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计附件 Excel VO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AttachmentExcelVO {
|
||||||
|
|
||||||
|
@ExcelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ExcelProperty("凭证id 一个凭证对应多个附件")
|
||||||
|
private Long voucherId;
|
||||||
|
|
||||||
|
@ExcelProperty("凭证号")
|
||||||
|
private String voucherNum;
|
||||||
|
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ExcelProperty("制单人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@ExcelProperty("业务实体id")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@ExcelProperty("业务实体")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@ExcelProperty("文件后缀")
|
||||||
|
private String suffix;
|
||||||
|
|
||||||
|
@ExcelProperty("文件地址")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
@ExcelProperty("绝对路径")
|
||||||
|
private String fileAp;
|
||||||
|
|
||||||
|
@ExcelProperty("流程号")
|
||||||
|
private String flowId;
|
||||||
|
|
||||||
|
@ExcelProperty("用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ExcelProperty("OA/ERP流程编号")
|
||||||
|
private String flowCode;
|
||||||
|
|
||||||
|
@ExcelProperty("文件名")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@ExcelProperty("文件大小")
|
||||||
|
private Integer fileSize;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 会计附件分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AttachmentPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "凭证id 一个凭证对应多个附件", example = "1755")
|
||||||
|
private Long voucherId;
|
||||||
|
|
||||||
|
@Schema(description = "凭证号")
|
||||||
|
private String voucherNum;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
@Schema(description = "制单人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@Schema(description = "业务实体id", example = "19777")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@Schema(description = "业务实体")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@Schema(description = "文件后缀")
|
||||||
|
private String suffix;
|
||||||
|
|
||||||
|
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
@Schema(description = "绝对路径")
|
||||||
|
private String fileAp;
|
||||||
|
|
||||||
|
@Schema(description = "流程号", example = "8773")
|
||||||
|
private String flowId;
|
||||||
|
|
||||||
|
@Schema(description = "用户id", example = "26419")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "你猜")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "OA/ERP流程编号")
|
||||||
|
private String flowCode;
|
||||||
|
|
||||||
|
@Schema(description = "文件名", example = "王五")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@Schema(description = "文件大小")
|
||||||
|
private Integer fileSize;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 会计附件 Response VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AttachmentRespVO extends AttachmentBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1487")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 会计附件更新 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AttachmentUpdateReqVO extends AttachmentBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1487")
|
||||||
|
@NotNull(message = "主键不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.convert.attachment;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计附件 Convert
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AttachmentConvert {
|
||||||
|
|
||||||
|
AttachmentConvert INSTANCE = Mappers.getMapper(AttachmentConvert.class);
|
||||||
|
|
||||||
|
AttachmentDO convert(AttachmentCreateReqVO bean);
|
||||||
|
|
||||||
|
AttachmentDO convert(AttachmentUpdateReqVO bean);
|
||||||
|
|
||||||
|
AttachmentRespVO convert(AttachmentDO bean);
|
||||||
|
|
||||||
|
List<AttachmentRespVO> convertList(List<AttachmentDO> list);
|
||||||
|
|
||||||
|
PageResult<AttachmentRespVO> convertPage(PageResult<AttachmentDO> page);
|
||||||
|
|
||||||
|
List<AttachmentExcelVO> convertList02(List<AttachmentDO> list);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.dal.dataobject.attachment;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计附件 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("accounting_attachment")
|
||||||
|
@KeySequence("accounting_attachment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AttachmentDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 凭证id 一个凭证对应多个附件
|
||||||
|
*/
|
||||||
|
private Long voucherId;
|
||||||
|
/**
|
||||||
|
* 凭证号
|
||||||
|
*/
|
||||||
|
private String voucherNum;
|
||||||
|
/**
|
||||||
|
* 业务id
|
||||||
|
*/
|
||||||
|
private Long businessId;
|
||||||
|
/**
|
||||||
|
* 业务类型
|
||||||
|
*/
|
||||||
|
private String businessType;
|
||||||
|
/**
|
||||||
|
* 制单人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
/**
|
||||||
|
* 业务实体id
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
|
/**
|
||||||
|
* 业务实体
|
||||||
|
*/
|
||||||
|
private String company;
|
||||||
|
/**
|
||||||
|
* 文件后缀
|
||||||
|
*/
|
||||||
|
private String suffix;
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private String fileUrl;
|
||||||
|
/**
|
||||||
|
* 绝对路径
|
||||||
|
*/
|
||||||
|
private String fileAp;
|
||||||
|
/**
|
||||||
|
* 流程号
|
||||||
|
*/
|
||||||
|
private String flowId;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 摘要
|
||||||
|
*/
|
||||||
|
private String note;
|
||||||
|
/**
|
||||||
|
* 所属部门id
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
private String deptName;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 预留字段1
|
||||||
|
*/
|
||||||
|
private String attr1;
|
||||||
|
/**
|
||||||
|
* 预留字段2
|
||||||
|
*/
|
||||||
|
private String attr2;
|
||||||
|
/**
|
||||||
|
* 预留字段3
|
||||||
|
*/
|
||||||
|
private Integer attr3;
|
||||||
|
/**
|
||||||
|
* 预留字段4
|
||||||
|
*/
|
||||||
|
private Integer attr4;
|
||||||
|
/**
|
||||||
|
* OA/ERP流程编号
|
||||||
|
*/
|
||||||
|
private String flowCode;
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
|
private String fileName;
|
||||||
|
/**
|
||||||
|
* 文件大小
|
||||||
|
*/
|
||||||
|
private Integer fileSize;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.dal.mysql.attachment;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计附件 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AttachmentMapper extends BaseMapperX<AttachmentDO> {
|
||||||
|
|
||||||
|
default PageResult<AttachmentDO> selectPage(AttachmentPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<AttachmentDO>()
|
||||||
|
.eqIfPresent(AttachmentDO::getVoucherId, reqVO.getVoucherId())
|
||||||
|
.eqIfPresent(AttachmentDO::getVoucherNum, reqVO.getVoucherNum())
|
||||||
|
.betweenIfPresent(AttachmentDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(AttachmentDO::getCreateBy, reqVO.getCreateBy())
|
||||||
|
.eqIfPresent(AttachmentDO::getCompanyId, reqVO.getCompanyId())
|
||||||
|
.eqIfPresent(AttachmentDO::getCompany, reqVO.getCompany())
|
||||||
|
.eqIfPresent(AttachmentDO::getSuffix, reqVO.getSuffix())
|
||||||
|
.eqIfPresent(AttachmentDO::getFileUrl, reqVO.getFileUrl())
|
||||||
|
.eqIfPresent(AttachmentDO::getFileAp, reqVO.getFileAp())
|
||||||
|
.eqIfPresent(AttachmentDO::getFlowId, reqVO.getFlowId())
|
||||||
|
.eqIfPresent(AttachmentDO::getUserId, reqVO.getUserId())
|
||||||
|
.eqIfPresent(AttachmentDO::getRemark, reqVO.getRemark())
|
||||||
|
.eqIfPresent(AttachmentDO::getFlowCode, reqVO.getFlowCode())
|
||||||
|
.likeIfPresent(AttachmentDO::getFileName, reqVO.getFileName())
|
||||||
|
.eqIfPresent(AttachmentDO::getFileSize, reqVO.getFileSize())
|
||||||
|
.orderByDesc(AttachmentDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<AttachmentDO> selectList(AttachmentExportReqVO reqVO) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<AttachmentDO>()
|
||||||
|
.eqIfPresent(AttachmentDO::getVoucherId, reqVO.getVoucherId())
|
||||||
|
.eqIfPresent(AttachmentDO::getVoucherNum, reqVO.getVoucherNum())
|
||||||
|
.betweenIfPresent(AttachmentDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(AttachmentDO::getCreateBy, reqVO.getCreateBy())
|
||||||
|
.eqIfPresent(AttachmentDO::getCompanyId, reqVO.getCompanyId())
|
||||||
|
.eqIfPresent(AttachmentDO::getCompany, reqVO.getCompany())
|
||||||
|
.eqIfPresent(AttachmentDO::getSuffix, reqVO.getSuffix())
|
||||||
|
.eqIfPresent(AttachmentDO::getFileUrl, reqVO.getFileUrl())
|
||||||
|
.eqIfPresent(AttachmentDO::getFileAp, reqVO.getFileAp())
|
||||||
|
.eqIfPresent(AttachmentDO::getFlowId, reqVO.getFlowId())
|
||||||
|
.eqIfPresent(AttachmentDO::getUserId, reqVO.getUserId())
|
||||||
|
.eqIfPresent(AttachmentDO::getRemark, reqVO.getRemark())
|
||||||
|
.eqIfPresent(AttachmentDO::getFlowCode, reqVO.getFlowCode())
|
||||||
|
.likeIfPresent(AttachmentDO::getFileName, reqVO.getFileName())
|
||||||
|
.eqIfPresent(AttachmentDO::getFileSize, reqVO.getFileSize())
|
||||||
|
.orderByDesc(AttachmentDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.service.attachment;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计附件 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface AttachmentService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建会计附件
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createAttachment(@Valid AttachmentCreateReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会计附件
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateAttachment(@Valid AttachmentUpdateReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除会计附件
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteAttachment(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计附件
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 会计附件
|
||||||
|
*/
|
||||||
|
AttachmentDO getAttachment(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计附件列表
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
* @return 会计附件列表
|
||||||
|
*/
|
||||||
|
List<AttachmentDO> getAttachmentList(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计附件分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 会计附件分页
|
||||||
|
*/
|
||||||
|
PageResult<AttachmentDO> getAttachmentPage(AttachmentPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计附件列表, 用于 Excel 导出
|
||||||
|
*
|
||||||
|
* @param exportReqVO 查询条件
|
||||||
|
* @return 会计附件列表
|
||||||
|
*/
|
||||||
|
List<AttachmentDO> getAttachmentList(AttachmentExportReqVO exportReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.service.attachment;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.accounting.convert.attachment.AttachmentConvert;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.mysql.attachment.AttachmentMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计附件 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class AttachmentServiceImpl implements AttachmentService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AttachmentMapper attachmentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createAttachment(AttachmentCreateReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
AttachmentDO attachment = AttachmentConvert.INSTANCE.convert(createReqVO);
|
||||||
|
attachmentMapper.insert(attachment);
|
||||||
|
// 返回
|
||||||
|
return attachment.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAttachment(AttachmentUpdateReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateAttachmentExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
AttachmentDO updateObj = AttachmentConvert.INSTANCE.convert(updateReqVO);
|
||||||
|
attachmentMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAttachment(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateAttachmentExists(id);
|
||||||
|
// 删除
|
||||||
|
attachmentMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateAttachmentExists(Long id) {
|
||||||
|
if (attachmentMapper.selectById(id) == null) {
|
||||||
|
throw exception(ATTACHMENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AttachmentDO getAttachment(Long id) {
|
||||||
|
return attachmentMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttachmentDO> getAttachmentList(Collection<Long> ids) {
|
||||||
|
return attachmentMapper.selectBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<AttachmentDO> getAttachmentPage(AttachmentPageReqVO pageReqVO) {
|
||||||
|
return attachmentMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttachmentDO> getAttachmentList(AttachmentExportReqVO exportReqVO) {
|
||||||
|
return attachmentMapper.selectList(exportReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,263 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.service.attachment;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.mysql.attachment.AttachmentMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link AttachmentServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(AttachmentServiceImpl.class)
|
||||||
|
public class AttachmentServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AttachmentServiceImpl attachmentService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AttachmentMapper attachmentMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateAttachment_success() {
|
||||||
|
// 准备参数
|
||||||
|
AttachmentCreateReqVO reqVO = randomPojo(AttachmentCreateReqVO.class);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long attachmentId = attachmentService.createAttachment(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(attachmentId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
AttachmentDO attachment = attachmentMapper.selectById(attachmentId);
|
||||||
|
assertPojoEquals(reqVO, attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateAttachment_success() {
|
||||||
|
// mock 数据
|
||||||
|
AttachmentDO dbAttachment = randomPojo(AttachmentDO.class);
|
||||||
|
attachmentMapper.insert(dbAttachment);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
AttachmentUpdateReqVO reqVO = randomPojo(AttachmentUpdateReqVO.class, o -> {
|
||||||
|
o.setId(dbAttachment.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
attachmentService.updateAttachment(reqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
AttachmentDO attachment = attachmentMapper.selectById(reqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(reqVO, attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateAttachment_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
AttachmentUpdateReqVO reqVO = randomPojo(AttachmentUpdateReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> attachmentService.updateAttachment(reqVO), ATTACHMENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteAttachment_success() {
|
||||||
|
// mock 数据
|
||||||
|
AttachmentDO dbAttachment = randomPojo(AttachmentDO.class);
|
||||||
|
attachmentMapper.insert(dbAttachment);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbAttachment.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
attachmentService.deleteAttachment(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(attachmentMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteAttachment_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> attachmentService.deleteAttachment(id), ATTACHMENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetAttachmentPage() {
|
||||||
|
// mock 数据
|
||||||
|
AttachmentDO dbAttachment = randomPojo(AttachmentDO.class, o -> { // 等会查询到
|
||||||
|
o.setVoucherId(null);
|
||||||
|
o.setVoucherNum(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
o.setCreateBy(null);
|
||||||
|
o.setCompanyId(null);
|
||||||
|
o.setCompany(null);
|
||||||
|
o.setSuffix(null);
|
||||||
|
o.setFileUrl(null);
|
||||||
|
o.setFileAp(null);
|
||||||
|
o.setFlowId(null);
|
||||||
|
o.setUserId(null);
|
||||||
|
o.setRemark(null);
|
||||||
|
o.setFlowCode(null);
|
||||||
|
o.setFileName(null);
|
||||||
|
o.setFileSize(null);
|
||||||
|
});
|
||||||
|
attachmentMapper.insert(dbAttachment);
|
||||||
|
// 测试 voucherId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setVoucherId(null)));
|
||||||
|
// 测试 voucherNum 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setVoucherNum(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCreateTime(null)));
|
||||||
|
// 测试 createBy 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCreateBy(null)));
|
||||||
|
// 测试 companyId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCompanyId(null)));
|
||||||
|
// 测试 company 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCompany(null)));
|
||||||
|
// 测试 suffix 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setSuffix(null)));
|
||||||
|
// 测试 fileUrl 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileUrl(null)));
|
||||||
|
// 测试 fileAp 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileAp(null)));
|
||||||
|
// 测试 flowId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFlowId(null)));
|
||||||
|
// 测试 userId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setUserId(null)));
|
||||||
|
// 测试 remark 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setRemark(null)));
|
||||||
|
// 测试 flowCode 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFlowCode(null)));
|
||||||
|
// 测试 fileName 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileName(null)));
|
||||||
|
// 测试 fileSize 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileSize(null)));
|
||||||
|
// 准备参数
|
||||||
|
AttachmentPageReqVO reqVO = new AttachmentPageReqVO();
|
||||||
|
reqVO.setVoucherId(null);
|
||||||
|
reqVO.setVoucherNum(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
reqVO.setCreateBy(null);
|
||||||
|
reqVO.setCompanyId(null);
|
||||||
|
reqVO.setCompany(null);
|
||||||
|
reqVO.setSuffix(null);
|
||||||
|
reqVO.setFileUrl(null);
|
||||||
|
reqVO.setFileAp(null);
|
||||||
|
reqVO.setFlowId(null);
|
||||||
|
reqVO.setUserId(null);
|
||||||
|
reqVO.setRemark(null);
|
||||||
|
reqVO.setFlowCode(null);
|
||||||
|
reqVO.setFileName(null);
|
||||||
|
reqVO.setFileSize(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<AttachmentDO> pageResult = attachmentService.getAttachmentPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbAttachment, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetAttachmentList() {
|
||||||
|
// mock 数据
|
||||||
|
AttachmentDO dbAttachment = randomPojo(AttachmentDO.class, o -> { // 等会查询到
|
||||||
|
o.setVoucherId(null);
|
||||||
|
o.setVoucherNum(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
o.setCreateBy(null);
|
||||||
|
o.setCompanyId(null);
|
||||||
|
o.setCompany(null);
|
||||||
|
o.setSuffix(null);
|
||||||
|
o.setFileUrl(null);
|
||||||
|
o.setFileAp(null);
|
||||||
|
o.setFlowId(null);
|
||||||
|
o.setUserId(null);
|
||||||
|
o.setRemark(null);
|
||||||
|
o.setFlowCode(null);
|
||||||
|
o.setFileName(null);
|
||||||
|
o.setFileSize(null);
|
||||||
|
});
|
||||||
|
attachmentMapper.insert(dbAttachment);
|
||||||
|
// 测试 voucherId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setVoucherId(null)));
|
||||||
|
// 测试 voucherNum 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setVoucherNum(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCreateTime(null)));
|
||||||
|
// 测试 createBy 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCreateBy(null)));
|
||||||
|
// 测试 companyId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCompanyId(null)));
|
||||||
|
// 测试 company 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setCompany(null)));
|
||||||
|
// 测试 suffix 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setSuffix(null)));
|
||||||
|
// 测试 fileUrl 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileUrl(null)));
|
||||||
|
// 测试 fileAp 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileAp(null)));
|
||||||
|
// 测试 flowId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFlowId(null)));
|
||||||
|
// 测试 userId 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setUserId(null)));
|
||||||
|
// 测试 remark 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setRemark(null)));
|
||||||
|
// 测试 flowCode 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFlowCode(null)));
|
||||||
|
// 测试 fileName 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileName(null)));
|
||||||
|
// 测试 fileSize 不匹配
|
||||||
|
attachmentMapper.insert(cloneIgnoreId(dbAttachment, o -> o.setFileSize(null)));
|
||||||
|
// 准备参数
|
||||||
|
AttachmentExportReqVO reqVO = new AttachmentExportReqVO();
|
||||||
|
reqVO.setVoucherId(null);
|
||||||
|
reqVO.setVoucherNum(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
reqVO.setCreateBy(null);
|
||||||
|
reqVO.setCompanyId(null);
|
||||||
|
reqVO.setCompany(null);
|
||||||
|
reqVO.setSuffix(null);
|
||||||
|
reqVO.setFileUrl(null);
|
||||||
|
reqVO.setFileAp(null);
|
||||||
|
reqVO.setFlowId(null);
|
||||||
|
reqVO.setUserId(null);
|
||||||
|
reqVO.setRemark(null);
|
||||||
|
reqVO.setFlowCode(null);
|
||||||
|
reqVO.setFileName(null);
|
||||||
|
reqVO.setFileSize(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
List<AttachmentDO> list = attachmentService.getAttachmentList(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, list.size());
|
||||||
|
assertPojoEquals(dbAttachment, list.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue