Merge remote-tracking branch 'origin/main'
commit
e5b1df08da
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modules>
|
||||
<module>yudao-module-accounting-api</module>
|
||||
<module>yudao-module-accounting-biz</module>
|
||||
</modules>
|
||||
<artifactId>yudao-module-accounting</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
会计档案模块
|
||||
</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baidu.aip</groupId>
|
||||
<artifactId>java-sdk</artifactId>
|
||||
<version>4.8.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.80</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.accounting.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 会计凭证枚举
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum AccountingStatusEnum {
|
||||
|
||||
INCOMPLETE("0", "不完整"),
|
||||
COMPLETE("1", "完整"),
|
||||
UNLOGFILE("0", "未归档"),
|
||||
LOGFILE("1", "已归档"),
|
||||
UNBORROWED("0", "未借阅"),
|
||||
BORROWED("1", "已借阅");
|
||||
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String value;
|
||||
/**
|
||||
* 类型名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package cn.iocoder.yudao.module.accounting.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
public interface ErrorCodeConstants {
|
||||
ErrorCode VOUCHER_NOT_EXISTS = new ErrorCode(200100, "会计凭证不存在");
|
||||
ErrorCode VOUCHER_DETAILS_NOT_EXISTS = new ErrorCode(300100, "凭证详情不存在");
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucher;
|
||||
|
||||
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.voucher.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
|
||||
import cn.iocoder.yudao.module.accounting.convert.voucher.VoucherConvert;
|
||||
import cn.iocoder.yudao.module.accounting.service.voucher.VoucherService;
|
||||
|
||||
@Tag(name = "管理后台 - 会计凭证")
|
||||
@RestController
|
||||
@RequestMapping("/accounting/voucher")
|
||||
@Validated
|
||||
public class VoucherController {
|
||||
|
||||
@Resource
|
||||
private VoucherService voucherService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建会计凭证")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:create')")
|
||||
public CommonResult<Long> createVoucher(@Valid @RequestBody VoucherCreateReqVO createReqVO) {
|
||||
return success(voucherService.createVoucher(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新会计凭证")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:update')")
|
||||
public CommonResult<Boolean> updateVoucher(@Valid @RequestBody VoucherUpdateReqVO updateReqVO) {
|
||||
voucherService.updateVoucher(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除会计凭证")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:delete')")
|
||||
public CommonResult<Boolean> deleteVoucher(@RequestParam("id") Long id) {
|
||||
voucherService.deleteVoucher(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得会计凭证")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:query')")
|
||||
public CommonResult<VoucherRespVO> getVoucher(@RequestParam("id") Long id) {
|
||||
VoucherDO voucher = voucherService.getVoucher(id);
|
||||
return success(VoucherConvert.INSTANCE.convert(voucher));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得会计凭证列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:query')")
|
||||
public CommonResult<List<VoucherRespVO>> getVoucherList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<VoucherDO> list = voucherService.getVoucherList(ids);
|
||||
return success(VoucherConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得会计凭证分页")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:query')")
|
||||
public CommonResult<PageResult<VoucherRespVO>> getVoucherPage(@Valid VoucherPageReqVO pageVO) {
|
||||
PageResult<VoucherDO> pageResult = voucherService.getVoucherPage(pageVO);
|
||||
return success(VoucherConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出会计凭证 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportVoucherExcel(@Valid VoucherExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<VoucherDO> list = voucherService.getVoucherList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<VoucherExcelVO> datas = VoucherConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "会计凭证.xls", "数据", VoucherExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucher.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 VoucherCreateReqVO extends VoucherBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucher.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 VoucherRespVO extends VoucherBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6174")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建日期")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucher.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 VoucherUpdateReqVO extends VoucherBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6174")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails;
|
||||
|
||||
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.voucherdetails.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO;
|
||||
import cn.iocoder.yudao.module.accounting.convert.voucherdetails.VoucherDetailsConvert;
|
||||
import cn.iocoder.yudao.module.accounting.service.voucherdetails.VoucherDetailsService;
|
||||
|
||||
@Tag(name = "管理后台 - 凭证详情")
|
||||
@RestController
|
||||
@RequestMapping("/accounting/voucher-details")
|
||||
@Validated
|
||||
public class VoucherDetailsController {
|
||||
|
||||
@Resource
|
||||
private VoucherDetailsService voucherDetailsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建凭证详情")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:create')")
|
||||
public CommonResult<Long> createVoucherDetails(@Valid @RequestBody VoucherDetailsCreateReqVO createReqVO) {
|
||||
return success(voucherDetailsService.createVoucherDetails(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新凭证详情")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:update')")
|
||||
public CommonResult<Boolean> updateVoucherDetails(@Valid @RequestBody VoucherDetailsUpdateReqVO updateReqVO) {
|
||||
voucherDetailsService.updateVoucherDetails(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除凭证详情")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:delete')")
|
||||
public CommonResult<Boolean> deleteVoucherDetails(@RequestParam("id") Long id) {
|
||||
voucherDetailsService.deleteVoucherDetails(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得凭证详情")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:query')")
|
||||
public CommonResult<VoucherDetailsRespVO> getVoucherDetails(@RequestParam("id") Long id) {
|
||||
VoucherDetailsDO voucherDetails = voucherDetailsService.getVoucherDetails(id);
|
||||
return success(VoucherDetailsConvert.INSTANCE.convert(voucherDetails));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得凭证详情列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:query')")
|
||||
public CommonResult<List<VoucherDetailsRespVO>> getVoucherDetailsList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<VoucherDetailsDO> list = voucherDetailsService.getVoucherDetailsList(ids);
|
||||
return success(VoucherDetailsConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得凭证详情分页")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:query')")
|
||||
public CommonResult<PageResult<VoucherDetailsRespVO>> getVoucherDetailsPage(@Valid VoucherDetailsPageReqVO pageVO) {
|
||||
PageResult<VoucherDetailsDO> pageResult = voucherDetailsService.getVoucherDetailsPage(pageVO);
|
||||
return success(VoucherDetailsConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出凭证详情 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('accounting:voucher-details:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportVoucherDetailsExcel(@Valid VoucherDetailsExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<VoucherDetailsDO> list = voucherDetailsService.getVoucherDetailsList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<VoucherDetailsExcelVO> datas = VoucherDetailsConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "凭证详情.xls", "数据", VoucherDetailsExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.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 VoucherDetailsCreateReqVO extends VoucherDetailsBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.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 VoucherDetailsRespVO extends VoucherDetailsBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31664")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建日期")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.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 VoucherDetailsUpdateReqVO extends VoucherDetailsBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31664")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.accounting.convert.voucher;
|
||||
|
||||
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.voucher.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
|
||||
|
||||
/**
|
||||
* 会计凭证 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VoucherConvert {
|
||||
|
||||
VoucherConvert INSTANCE = Mappers.getMapper(VoucherConvert.class);
|
||||
|
||||
VoucherDO convert(VoucherCreateReqVO bean);
|
||||
|
||||
VoucherDO convert(VoucherUpdateReqVO bean);
|
||||
|
||||
VoucherRespVO convert(VoucherDO bean);
|
||||
|
||||
List<VoucherRespVO> convertList(List<VoucherDO> list);
|
||||
|
||||
PageResult<VoucherRespVO> convertPage(PageResult<VoucherDO> page);
|
||||
|
||||
List<VoucherExcelVO> convertList02(List<VoucherDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.accounting.convert.voucherdetails;
|
||||
|
||||
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.voucherdetails.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO;
|
||||
|
||||
/**
|
||||
* 凭证详情 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VoucherDetailsConvert {
|
||||
|
||||
VoucherDetailsConvert INSTANCE = Mappers.getMapper(VoucherDetailsConvert.class);
|
||||
|
||||
VoucherDetailsDO convert(VoucherDetailsCreateReqVO bean);
|
||||
|
||||
VoucherDetailsDO convert(VoucherDetailsUpdateReqVO bean);
|
||||
|
||||
VoucherDetailsRespVO convert(VoucherDetailsDO bean);
|
||||
|
||||
List<VoucherDetailsRespVO> convertList(List<VoucherDetailsDO> list);
|
||||
|
||||
PageResult<VoucherDetailsRespVO> convertPage(PageResult<VoucherDetailsDO> page);
|
||||
|
||||
List<VoucherDetailsExcelVO> convertList02(List<VoucherDetailsDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.iocoder.yudao.module.accounting.dal.mysql.voucher;
|
||||
|
||||
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.voucher.VoucherDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*;
|
||||
|
||||
/**
|
||||
* 会计凭证 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VoucherMapper extends BaseMapperX<VoucherDO> {
|
||||
|
||||
default PageResult<VoucherDO> selectPage(VoucherPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<VoucherDO>()
|
||||
.eqIfPresent(VoucherDO::getCreateBy, reqVO.getCreateBy())
|
||||
.betweenIfPresent(VoucherDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(VoucherDO::getCompanyId, reqVO.getCompanyId())
|
||||
.eqIfPresent(VoucherDO::getCompany, reqVO.getCompany())
|
||||
.eqIfPresent(VoucherDO::getDeptId, reqVO.getDeptId())
|
||||
.likeIfPresent(VoucherDO::getDeptName, reqVO.getDeptName())
|
||||
.betweenIfPresent(VoucherDO::getVoucherTime, reqVO.getVoucherTime())
|
||||
.eqIfPresent(VoucherDO::getVoucherNum, reqVO.getVoucherNum())
|
||||
.eqIfPresent(VoucherDO::getDigest, reqVO.getDigest())
|
||||
.eqIfPresent(VoucherDO::getAudit, reqVO.getAudit())
|
||||
.eqIfPresent(VoucherDO::getChecker, reqVO.getChecker())
|
||||
.eqIfPresent(VoucherDO::getHandle, reqVO.getHandle())
|
||||
.eqIfPresent(VoucherDO::getServiceId, reqVO.getServiceId())
|
||||
.eqIfPresent(VoucherDO::getServiceExplain, reqVO.getServiceExplain())
|
||||
.eqIfPresent(VoucherDO::getType, reqVO.getType())
|
||||
.eqIfPresent(VoucherDO::getFlowId, reqVO.getFlowId())
|
||||
.eqIfPresent(VoucherDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(VoucherDO::getYear, reqVO.getYear())
|
||||
.eqIfPresent(VoucherDO::getPeriod, reqVO.getPeriod())
|
||||
.eqIfPresent(VoucherDO::getBorrowStatus, reqVO.getBorrowStatus())
|
||||
.betweenIfPresent(VoucherDO::getRecordTime, reqVO.getRecordTime())
|
||||
.eqIfPresent(VoucherDO::getPosition, reqVO.getPosition())
|
||||
.eqIfPresent(VoucherDO::getCherks, reqVO.getCherks())
|
||||
.eqIfPresent(VoucherDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(VoucherDO::getRecordId, reqVO.getRecordId())
|
||||
.eqIfPresent(VoucherDO::getFileStatus, reqVO.getFileStatus())
|
||||
.eqIfPresent(VoucherDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(VoucherDO::getOrganizationId, reqVO.getOrganizationId())
|
||||
.eqIfPresent(VoucherDO::getDepotId, reqVO.getDepotId())
|
||||
.eqIfPresent(VoucherDO::getCabinetId, reqVO.getCabinetId())
|
||||
.orderByDesc(VoucherDO::getId));
|
||||
}
|
||||
|
||||
default List<VoucherDO> selectList(VoucherExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<VoucherDO>()
|
||||
.eqIfPresent(VoucherDO::getCreateBy, reqVO.getCreateBy())
|
||||
.betweenIfPresent(VoucherDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(VoucherDO::getCompanyId, reqVO.getCompanyId())
|
||||
.eqIfPresent(VoucherDO::getCompany, reqVO.getCompany())
|
||||
.eqIfPresent(VoucherDO::getDeptId, reqVO.getDeptId())
|
||||
.likeIfPresent(VoucherDO::getDeptName, reqVO.getDeptName())
|
||||
.betweenIfPresent(VoucherDO::getVoucherTime, reqVO.getVoucherTime())
|
||||
.eqIfPresent(VoucherDO::getVoucherNum, reqVO.getVoucherNum())
|
||||
.eqIfPresent(VoucherDO::getDigest, reqVO.getDigest())
|
||||
.eqIfPresent(VoucherDO::getAudit, reqVO.getAudit())
|
||||
.eqIfPresent(VoucherDO::getChecker, reqVO.getChecker())
|
||||
.eqIfPresent(VoucherDO::getHandle, reqVO.getHandle())
|
||||
.eqIfPresent(VoucherDO::getServiceId, reqVO.getServiceId())
|
||||
.eqIfPresent(VoucherDO::getServiceExplain, reqVO.getServiceExplain())
|
||||
.eqIfPresent(VoucherDO::getType, reqVO.getType())
|
||||
.eqIfPresent(VoucherDO::getFlowId, reqVO.getFlowId())
|
||||
.eqIfPresent(VoucherDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(VoucherDO::getYear, reqVO.getYear())
|
||||
.eqIfPresent(VoucherDO::getPeriod, reqVO.getPeriod())
|
||||
.eqIfPresent(VoucherDO::getBorrowStatus, reqVO.getBorrowStatus())
|
||||
.betweenIfPresent(VoucherDO::getRecordTime, reqVO.getRecordTime())
|
||||
.eqIfPresent(VoucherDO::getPosition, reqVO.getPosition())
|
||||
.eqIfPresent(VoucherDO::getCherks, reqVO.getCherks())
|
||||
.eqIfPresent(VoucherDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(VoucherDO::getRecordId, reqVO.getRecordId())
|
||||
.eqIfPresent(VoucherDO::getFileStatus, reqVO.getFileStatus())
|
||||
.eqIfPresent(VoucherDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(VoucherDO::getOrganizationId, reqVO.getOrganizationId())
|
||||
.eqIfPresent(VoucherDO::getDepotId, reqVO.getDepotId())
|
||||
.eqIfPresent(VoucherDO::getCabinetId, reqVO.getCabinetId())
|
||||
.orderByDesc(VoucherDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package cn.iocoder.yudao.module.accounting.dal.mysql.voucherdetails;
|
||||
|
||||
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.voucherdetails.VoucherDetailsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*;
|
||||
|
||||
/**
|
||||
* 凭证详情 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface VoucherDetailsMapper extends BaseMapperX<VoucherDetailsDO> {
|
||||
|
||||
default PageResult<VoucherDetailsDO> selectPage(VoucherDetailsPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<VoucherDetailsDO>()
|
||||
.eqIfPresent(VoucherDetailsDO::getLineNum, reqVO.getLineNum())
|
||||
.eqIfPresent(VoucherDetailsDO::getCreateBy, reqVO.getCreateBy())
|
||||
.betweenIfPresent(VoucherDetailsDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(VoucherDetailsDO::getDigest, reqVO.getDigest())
|
||||
.eqIfPresent(VoucherDetailsDO::getVoucherType, reqVO.getVoucherType())
|
||||
.eqIfPresent(VoucherDetailsDO::getSubjectCode, reqVO.getSubjectCode())
|
||||
.likeIfPresent(VoucherDetailsDO::getSubjectName, reqVO.getSubjectName())
|
||||
.eqIfPresent(VoucherDetailsDO::getAssistCheck, reqVO.getAssistCheck())
|
||||
.eqIfPresent(VoucherDetailsDO::getDebitMoney, reqVO.getDebitMoney())
|
||||
.eqIfPresent(VoucherDetailsDO::getCreditorMoney, reqVO.getCreditorMoney())
|
||||
.eqIfPresent(VoucherDetailsDO::getFlowId, reqVO.getFlowId())
|
||||
.eqIfPresent(VoucherDetailsDO::getVoucherId, reqVO.getVoucherId())
|
||||
.eqIfPresent(VoucherDetailsDO::getVoucherNum, reqVO.getVoucherNum())
|
||||
.eqIfPresent(VoucherDetailsDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(VoucherDetailsDO::getFileStatus, reqVO.getFileStatus())
|
||||
.orderByDesc(VoucherDetailsDO::getId));
|
||||
}
|
||||
|
||||
default List<VoucherDetailsDO> selectList(VoucherDetailsExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<VoucherDetailsDO>()
|
||||
.eqIfPresent(VoucherDetailsDO::getLineNum, reqVO.getLineNum())
|
||||
.eqIfPresent(VoucherDetailsDO::getCreateBy, reqVO.getCreateBy())
|
||||
.betweenIfPresent(VoucherDetailsDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(VoucherDetailsDO::getDigest, reqVO.getDigest())
|
||||
.eqIfPresent(VoucherDetailsDO::getVoucherType, reqVO.getVoucherType())
|
||||
.eqIfPresent(VoucherDetailsDO::getSubjectCode, reqVO.getSubjectCode())
|
||||
.likeIfPresent(VoucherDetailsDO::getSubjectName, reqVO.getSubjectName())
|
||||
.eqIfPresent(VoucherDetailsDO::getAssistCheck, reqVO.getAssistCheck())
|
||||
.eqIfPresent(VoucherDetailsDO::getDebitMoney, reqVO.getDebitMoney())
|
||||
.eqIfPresent(VoucherDetailsDO::getCreditorMoney, reqVO.getCreditorMoney())
|
||||
.eqIfPresent(VoucherDetailsDO::getFlowId, reqVO.getFlowId())
|
||||
.eqIfPresent(VoucherDetailsDO::getVoucherId, reqVO.getVoucherId())
|
||||
.eqIfPresent(VoucherDetailsDO::getVoucherNum, reqVO.getVoucherNum())
|
||||
.eqIfPresent(VoucherDetailsDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(VoucherDetailsDO::getFileStatus, reqVO.getFileStatus())
|
||||
.orderByDesc(VoucherDetailsDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.voucher;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 会计凭证 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface VoucherService {
|
||||
|
||||
/**
|
||||
* 创建会计凭证
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createVoucher(@Valid VoucherCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新会计凭证
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateVoucher(@Valid VoucherUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除会计凭证
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteVoucher(Long id);
|
||||
|
||||
/**
|
||||
* 获得会计凭证
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 会计凭证
|
||||
*/
|
||||
VoucherDO getVoucher(Long id);
|
||||
|
||||
/**
|
||||
* 获得会计凭证列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 会计凭证列表
|
||||
*/
|
||||
List<VoucherDO> getVoucherList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得会计凭证分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 会计凭证分页
|
||||
*/
|
||||
PageResult<VoucherDO> getVoucherPage(VoucherPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得会计凭证列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 会计凭证列表
|
||||
*/
|
||||
List<VoucherDO> getVoucherList(VoucherExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.voucher;
|
||||
|
||||
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.voucher.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.accounting.convert.voucher.VoucherConvert;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.voucher.VoucherMapper;
|
||||
|
||||
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 VoucherServiceImpl implements VoucherService {
|
||||
|
||||
@Resource
|
||||
private VoucherMapper voucherMapper;
|
||||
|
||||
@Override
|
||||
public Long createVoucher(VoucherCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
VoucherDO voucher = VoucherConvert.INSTANCE.convert(createReqVO);
|
||||
voucherMapper.insert(voucher);
|
||||
// 返回
|
||||
return voucher.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVoucher(VoucherUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateVoucherExists(updateReqVO.getId());
|
||||
// 更新
|
||||
VoucherDO updateObj = VoucherConvert.INSTANCE.convert(updateReqVO);
|
||||
voucherMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVoucher(Long id) {
|
||||
// 校验存在
|
||||
validateVoucherExists(id);
|
||||
// 删除
|
||||
voucherMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateVoucherExists(Long id) {
|
||||
if (voucherMapper.selectById(id) == null) {
|
||||
throw exception(VOUCHER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoucherDO getVoucher(Long id) {
|
||||
return voucherMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VoucherDO> getVoucherList(Collection<Long> ids) {
|
||||
return voucherMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<VoucherDO> getVoucherPage(VoucherPageReqVO pageReqVO) {
|
||||
return voucherMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VoucherDO> getVoucherList(VoucherExportReqVO exportReqVO) {
|
||||
return voucherMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.voucherdetails;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 凭证详情 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface VoucherDetailsService {
|
||||
|
||||
/**
|
||||
* 创建凭证详情
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createVoucherDetails(@Valid VoucherDetailsCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新凭证详情
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateVoucherDetails(@Valid VoucherDetailsUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除凭证详情
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteVoucherDetails(Long id);
|
||||
|
||||
/**
|
||||
* 获得凭证详情
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 凭证详情
|
||||
*/
|
||||
VoucherDetailsDO getVoucherDetails(Long id);
|
||||
|
||||
/**
|
||||
* 获得凭证详情列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 凭证详情列表
|
||||
*/
|
||||
List<VoucherDetailsDO> getVoucherDetailsList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得凭证详情分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 凭证详情分页
|
||||
*/
|
||||
PageResult<VoucherDetailsDO> getVoucherDetailsPage(VoucherDetailsPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得凭证详情列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 凭证详情列表
|
||||
*/
|
||||
List<VoucherDetailsDO> getVoucherDetailsList(VoucherDetailsExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.voucherdetails;
|
||||
|
||||
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.voucherdetails.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.accounting.convert.voucherdetails.VoucherDetailsConvert;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.voucherdetails.VoucherDetailsMapper;
|
||||
|
||||
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 VoucherDetailsServiceImpl implements VoucherDetailsService {
|
||||
|
||||
@Resource
|
||||
private VoucherDetailsMapper voucherDetailsMapper;
|
||||
|
||||
@Override
|
||||
public Long createVoucherDetails(VoucherDetailsCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
VoucherDetailsDO voucherDetails = VoucherDetailsConvert.INSTANCE.convert(createReqVO);
|
||||
voucherDetailsMapper.insert(voucherDetails);
|
||||
// 返回
|
||||
return voucherDetails.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVoucherDetails(VoucherDetailsUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateVoucherDetailsExists(updateReqVO.getId());
|
||||
// 更新
|
||||
VoucherDetailsDO updateObj = VoucherDetailsConvert.INSTANCE.convert(updateReqVO);
|
||||
voucherDetailsMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVoucherDetails(Long id) {
|
||||
// 校验存在
|
||||
validateVoucherDetailsExists(id);
|
||||
// 删除
|
||||
voucherDetailsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateVoucherDetailsExists(Long id) {
|
||||
if (voucherDetailsMapper.selectById(id) == null) {
|
||||
throw exception(VOUCHER_DETAILS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoucherDetailsDO getVoucherDetails(Long id) {
|
||||
return voucherDetailsMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VoucherDetailsDO> getVoucherDetailsList(Collection<Long> ids) {
|
||||
return voucherDetailsMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<VoucherDetailsDO> getVoucherDetailsPage(VoucherDetailsPageReqVO pageReqVO) {
|
||||
return voucherDetailsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VoucherDetailsDO> getVoucherDetailsList(VoucherDetailsExportReqVO exportReqVO) {
|
||||
return voucherDetailsMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,383 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.voucher;
|
||||
|
||||
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.voucher.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.voucher.VoucherMapper;
|
||||
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 VoucherServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(VoucherServiceImpl.class)
|
||||
public class VoucherServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private VoucherServiceImpl voucherService;
|
||||
|
||||
@Resource
|
||||
private VoucherMapper voucherMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateVoucher_success() {
|
||||
// 准备参数
|
||||
VoucherCreateReqVO reqVO = randomPojo(VoucherCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long voucherId = voucherService.createVoucher(reqVO);
|
||||
// 断言
|
||||
assertNotNull(voucherId);
|
||||
// 校验记录的属性是否正确
|
||||
VoucherDO voucher = voucherMapper.selectById(voucherId);
|
||||
assertPojoEquals(reqVO, voucher);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateVoucher_success() {
|
||||
// mock 数据
|
||||
VoucherDO dbVoucher = randomPojo(VoucherDO.class);
|
||||
voucherMapper.insert(dbVoucher);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
VoucherUpdateReqVO reqVO = randomPojo(VoucherUpdateReqVO.class, o -> {
|
||||
o.setId(dbVoucher.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
voucherService.updateVoucher(reqVO);
|
||||
// 校验是否更新正确
|
||||
VoucherDO voucher = voucherMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, voucher);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateVoucher_notExists() {
|
||||
// 准备参数
|
||||
VoucherUpdateReqVO reqVO = randomPojo(VoucherUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> voucherService.updateVoucher(reqVO), VOUCHER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteVoucher_success() {
|
||||
// mock 数据
|
||||
VoucherDO dbVoucher = randomPojo(VoucherDO.class);
|
||||
voucherMapper.insert(dbVoucher);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbVoucher.getId();
|
||||
|
||||
// 调用
|
||||
voucherService.deleteVoucher(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(voucherMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteVoucher_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> voucherService.deleteVoucher(id), VOUCHER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetVoucherPage() {
|
||||
// mock 数据
|
||||
VoucherDO dbVoucher = randomPojo(VoucherDO.class, o -> { // 等会查询到
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setCompanyId(null);
|
||||
o.setCompany(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setVoucherTime(null);
|
||||
o.setVoucherNum(null);
|
||||
o.setDigest(null);
|
||||
o.setAudit(null);
|
||||
o.setChecker(null);
|
||||
o.setHandle(null);
|
||||
o.setServiceId(null);
|
||||
o.setServiceExplain(null);
|
||||
o.setType(null);
|
||||
o.setFlowId(null);
|
||||
o.setSource(null);
|
||||
o.setYear(null);
|
||||
o.setPeriod(null);
|
||||
o.setBorrowStatus(null);
|
||||
o.setRecordTime(null);
|
||||
o.setPosition(null);
|
||||
o.setCherks(null);
|
||||
o.setUserId(null);
|
||||
o.setRecordId(null);
|
||||
o.setFileStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setOrganizationId(null);
|
||||
o.setDepotId(null);
|
||||
o.setCabinetId(null);
|
||||
});
|
||||
voucherMapper.insert(dbVoucher);
|
||||
// 测试 createBy 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateTime(null)));
|
||||
// 测试 companyId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompanyId(null)));
|
||||
// 测试 company 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompany(null)));
|
||||
// 测试 deptId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptName(null)));
|
||||
// 测试 voucherTime 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherTime(null)));
|
||||
// 测试 voucherNum 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherNum(null)));
|
||||
// 测试 digest 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDigest(null)));
|
||||
// 测试 audit 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setAudit(null)));
|
||||
// 测试 checker 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setChecker(null)));
|
||||
// 测试 handle 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setHandle(null)));
|
||||
// 测试 serviceId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceId(null)));
|
||||
// 测试 serviceExplain 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceExplain(null)));
|
||||
// 测试 type 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setType(null)));
|
||||
// 测试 flowId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFlowId(null)));
|
||||
// 测试 source 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setSource(null)));
|
||||
// 测试 year 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setYear(null)));
|
||||
// 测试 period 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPeriod(null)));
|
||||
// 测试 borrowStatus 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setBorrowStatus(null)));
|
||||
// 测试 recordTime 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordTime(null)));
|
||||
// 测试 position 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPosition(null)));
|
||||
// 测试 cherks 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCherks(null)));
|
||||
// 测试 userId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setUserId(null)));
|
||||
// 测试 recordId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordId(null)));
|
||||
// 测试 fileStatus 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFileStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRemark(null)));
|
||||
// 测试 organizationId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setOrganizationId(null)));
|
||||
// 测试 depotId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDepotId(null)));
|
||||
// 测试 cabinetId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCabinetId(null)));
|
||||
// 准备参数
|
||||
VoucherPageReqVO reqVO = new VoucherPageReqVO();
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setCompanyId(null);
|
||||
reqVO.setCompany(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setVoucherTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setVoucherNum(null);
|
||||
reqVO.setDigest(null);
|
||||
reqVO.setAudit(null);
|
||||
reqVO.setChecker(null);
|
||||
reqVO.setHandle(null);
|
||||
reqVO.setServiceId(null);
|
||||
reqVO.setServiceExplain(null);
|
||||
reqVO.setType(null);
|
||||
reqVO.setFlowId(null);
|
||||
reqVO.setSource(null);
|
||||
reqVO.setYear(null);
|
||||
reqVO.setPeriod(null);
|
||||
reqVO.setBorrowStatus(null);
|
||||
reqVO.setRecordTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setPosition(null);
|
||||
reqVO.setCherks(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setRecordId(null);
|
||||
reqVO.setFileStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setOrganizationId(null);
|
||||
reqVO.setDepotId(null);
|
||||
reqVO.setCabinetId(null);
|
||||
|
||||
// 调用
|
||||
PageResult<VoucherDO> pageResult = voucherService.getVoucherPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbVoucher, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetVoucherList() {
|
||||
// mock 数据
|
||||
VoucherDO dbVoucher = randomPojo(VoucherDO.class, o -> { // 等会查询到
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setCompanyId(null);
|
||||
o.setCompany(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setVoucherTime(null);
|
||||
o.setVoucherNum(null);
|
||||
o.setDigest(null);
|
||||
o.setAudit(null);
|
||||
o.setChecker(null);
|
||||
o.setHandle(null);
|
||||
o.setServiceId(null);
|
||||
o.setServiceExplain(null);
|
||||
o.setType(null);
|
||||
o.setFlowId(null);
|
||||
o.setSource(null);
|
||||
o.setYear(null);
|
||||
o.setPeriod(null);
|
||||
o.setBorrowStatus(null);
|
||||
o.setRecordTime(null);
|
||||
o.setPosition(null);
|
||||
o.setCherks(null);
|
||||
o.setUserId(null);
|
||||
o.setRecordId(null);
|
||||
o.setFileStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setOrganizationId(null);
|
||||
o.setDepotId(null);
|
||||
o.setCabinetId(null);
|
||||
});
|
||||
voucherMapper.insert(dbVoucher);
|
||||
// 测试 createBy 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateTime(null)));
|
||||
// 测试 companyId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompanyId(null)));
|
||||
// 测试 company 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompany(null)));
|
||||
// 测试 deptId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptName(null)));
|
||||
// 测试 voucherTime 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherTime(null)));
|
||||
// 测试 voucherNum 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherNum(null)));
|
||||
// 测试 digest 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDigest(null)));
|
||||
// 测试 audit 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setAudit(null)));
|
||||
// 测试 checker 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setChecker(null)));
|
||||
// 测试 handle 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setHandle(null)));
|
||||
// 测试 serviceId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceId(null)));
|
||||
// 测试 serviceExplain 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceExplain(null)));
|
||||
// 测试 type 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setType(null)));
|
||||
// 测试 flowId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFlowId(null)));
|
||||
// 测试 source 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setSource(null)));
|
||||
// 测试 year 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setYear(null)));
|
||||
// 测试 period 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPeriod(null)));
|
||||
// 测试 borrowStatus 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setBorrowStatus(null)));
|
||||
// 测试 recordTime 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordTime(null)));
|
||||
// 测试 position 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPosition(null)));
|
||||
// 测试 cherks 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCherks(null)));
|
||||
// 测试 userId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setUserId(null)));
|
||||
// 测试 recordId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordId(null)));
|
||||
// 测试 fileStatus 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFileStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRemark(null)));
|
||||
// 测试 organizationId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setOrganizationId(null)));
|
||||
// 测试 depotId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDepotId(null)));
|
||||
// 测试 cabinetId 不匹配
|
||||
voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCabinetId(null)));
|
||||
// 准备参数
|
||||
VoucherExportReqVO reqVO = new VoucherExportReqVO();
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setCompanyId(null);
|
||||
reqVO.setCompany(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setVoucherTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setVoucherNum(null);
|
||||
reqVO.setDigest(null);
|
||||
reqVO.setAudit(null);
|
||||
reqVO.setChecker(null);
|
||||
reqVO.setHandle(null);
|
||||
reqVO.setServiceId(null);
|
||||
reqVO.setServiceExplain(null);
|
||||
reqVO.setType(null);
|
||||
reqVO.setFlowId(null);
|
||||
reqVO.setSource(null);
|
||||
reqVO.setYear(null);
|
||||
reqVO.setPeriod(null);
|
||||
reqVO.setBorrowStatus(null);
|
||||
reqVO.setRecordTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setPosition(null);
|
||||
reqVO.setCherks(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setRecordId(null);
|
||||
reqVO.setFileStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setOrganizationId(null);
|
||||
reqVO.setDepotId(null);
|
||||
reqVO.setCabinetId(null);
|
||||
|
||||
// 调用
|
||||
List<VoucherDO> list = voucherService.getVoucherList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbVoucher, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,263 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.voucherdetails;
|
||||
|
||||
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.voucherdetails.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.voucherdetails.VoucherDetailsMapper;
|
||||
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 VoucherDetailsServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(VoucherDetailsServiceImpl.class)
|
||||
public class VoucherDetailsServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private VoucherDetailsServiceImpl voucherDetailsService;
|
||||
|
||||
@Resource
|
||||
private VoucherDetailsMapper voucherDetailsMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateVoucherDetails_success() {
|
||||
// 准备参数
|
||||
VoucherDetailsCreateReqVO reqVO = randomPojo(VoucherDetailsCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long voucherDetailsId = voucherDetailsService.createVoucherDetails(reqVO);
|
||||
// 断言
|
||||
assertNotNull(voucherDetailsId);
|
||||
// 校验记录的属性是否正确
|
||||
VoucherDetailsDO voucherDetails = voucherDetailsMapper.selectById(voucherDetailsId);
|
||||
assertPojoEquals(reqVO, voucherDetails);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateVoucherDetails_success() {
|
||||
// mock 数据
|
||||
VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class);
|
||||
voucherDetailsMapper.insert(dbVoucherDetails);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
VoucherDetailsUpdateReqVO reqVO = randomPojo(VoucherDetailsUpdateReqVO.class, o -> {
|
||||
o.setId(dbVoucherDetails.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
voucherDetailsService.updateVoucherDetails(reqVO);
|
||||
// 校验是否更新正确
|
||||
VoucherDetailsDO voucherDetails = voucherDetailsMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, voucherDetails);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateVoucherDetails_notExists() {
|
||||
// 准备参数
|
||||
VoucherDetailsUpdateReqVO reqVO = randomPojo(VoucherDetailsUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> voucherDetailsService.updateVoucherDetails(reqVO), VOUCHER_DETAILS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteVoucherDetails_success() {
|
||||
// mock 数据
|
||||
VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class);
|
||||
voucherDetailsMapper.insert(dbVoucherDetails);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbVoucherDetails.getId();
|
||||
|
||||
// 调用
|
||||
voucherDetailsService.deleteVoucherDetails(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(voucherDetailsMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteVoucherDetails_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> voucherDetailsService.deleteVoucherDetails(id), VOUCHER_DETAILS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetVoucherDetailsPage() {
|
||||
// mock 数据
|
||||
VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class, o -> { // 等会查询到
|
||||
o.setLineNum(null);
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setDigest(null);
|
||||
o.setVoucherType(null);
|
||||
o.setSubjectCode(null);
|
||||
o.setSubjectName(null);
|
||||
o.setAssistCheck(null);
|
||||
o.setDebitMoney(null);
|
||||
o.setCreditorMoney(null);
|
||||
o.setFlowId(null);
|
||||
o.setVoucherId(null);
|
||||
o.setVoucherNum(null);
|
||||
o.setUserId(null);
|
||||
o.setFileStatus(null);
|
||||
});
|
||||
voucherDetailsMapper.insert(dbVoucherDetails);
|
||||
// 测试 lineNum 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setLineNum(null)));
|
||||
// 测试 createBy 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateTime(null)));
|
||||
// 测试 digest 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDigest(null)));
|
||||
// 测试 voucherType 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherType(null)));
|
||||
// 测试 subjectCode 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectCode(null)));
|
||||
// 测试 subjectName 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectName(null)));
|
||||
// 测试 assistCheck 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setAssistCheck(null)));
|
||||
// 测试 debitMoney 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDebitMoney(null)));
|
||||
// 测试 creditorMoney 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreditorMoney(null)));
|
||||
// 测试 flowId 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFlowId(null)));
|
||||
// 测试 voucherId 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherId(null)));
|
||||
// 测试 voucherNum 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherNum(null)));
|
||||
// 测试 userId 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setUserId(null)));
|
||||
// 测试 fileStatus 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFileStatus(null)));
|
||||
// 准备参数
|
||||
VoucherDetailsPageReqVO reqVO = new VoucherDetailsPageReqVO();
|
||||
reqVO.setLineNum(null);
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setDigest(null);
|
||||
reqVO.setVoucherType(null);
|
||||
reqVO.setSubjectCode(null);
|
||||
reqVO.setSubjectName(null);
|
||||
reqVO.setAssistCheck(null);
|
||||
reqVO.setDebitMoney(null);
|
||||
reqVO.setCreditorMoney(null);
|
||||
reqVO.setFlowId(null);
|
||||
reqVO.setVoucherId(null);
|
||||
reqVO.setVoucherNum(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setFileStatus(null);
|
||||
|
||||
// 调用
|
||||
PageResult<VoucherDetailsDO> pageResult = voucherDetailsService.getVoucherDetailsPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbVoucherDetails, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetVoucherDetailsList() {
|
||||
// mock 数据
|
||||
VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class, o -> { // 等会查询到
|
||||
o.setLineNum(null);
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setDigest(null);
|
||||
o.setVoucherType(null);
|
||||
o.setSubjectCode(null);
|
||||
o.setSubjectName(null);
|
||||
o.setAssistCheck(null);
|
||||
o.setDebitMoney(null);
|
||||
o.setCreditorMoney(null);
|
||||
o.setFlowId(null);
|
||||
o.setVoucherId(null);
|
||||
o.setVoucherNum(null);
|
||||
o.setUserId(null);
|
||||
o.setFileStatus(null);
|
||||
});
|
||||
voucherDetailsMapper.insert(dbVoucherDetails);
|
||||
// 测试 lineNum 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setLineNum(null)));
|
||||
// 测试 createBy 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateTime(null)));
|
||||
// 测试 digest 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDigest(null)));
|
||||
// 测试 voucherType 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherType(null)));
|
||||
// 测试 subjectCode 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectCode(null)));
|
||||
// 测试 subjectName 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectName(null)));
|
||||
// 测试 assistCheck 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setAssistCheck(null)));
|
||||
// 测试 debitMoney 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDebitMoney(null)));
|
||||
// 测试 creditorMoney 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreditorMoney(null)));
|
||||
// 测试 flowId 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFlowId(null)));
|
||||
// 测试 voucherId 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherId(null)));
|
||||
// 测试 voucherNum 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherNum(null)));
|
||||
// 测试 userId 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setUserId(null)));
|
||||
// 测试 fileStatus 不匹配
|
||||
voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFileStatus(null)));
|
||||
// 准备参数
|
||||
VoucherDetailsExportReqVO reqVO = new VoucherDetailsExportReqVO();
|
||||
reqVO.setLineNum(null);
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setDigest(null);
|
||||
reqVO.setVoucherType(null);
|
||||
reqVO.setSubjectCode(null);
|
||||
reqVO.setSubjectName(null);
|
||||
reqVO.setAssistCheck(null);
|
||||
reqVO.setDebitMoney(null);
|
||||
reqVO.setCreditorMoney(null);
|
||||
reqVO.setFlowId(null);
|
||||
reqVO.setVoucherId(null);
|
||||
reqVO.setVoucherNum(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setFileStatus(null);
|
||||
|
||||
// 调用
|
||||
List<VoucherDetailsDO> list = voucherDetailsService.getVoucherDetailsList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbVoucherDetails, list.get(0));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue