Merge remote-tracking branch 'origin/main'
commit
f359d6b3c5
@ -1,263 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@ -1,311 +0,0 @@
|
||||
package cn.iocoder.yudao.module.accounting.service.other;
|
||||
|
||||
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.other.vo.*;
|
||||
import cn.iocoder.yudao.module.accounting.dal.dataobject.other.OtherDO;
|
||||
import cn.iocoder.yudao.module.accounting.dal.mysql.other.OtherMapper;
|
||||
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 OtherServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(OtherServiceImpl.class)
|
||||
public class OtherServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private OtherServiceImpl otherService;
|
||||
|
||||
@Resource
|
||||
private OtherMapper otherMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateOther_success() {
|
||||
// 准备参数
|
||||
OtherCreateReqVO reqVO = randomPojo(OtherCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long otherId = otherService.createOther(reqVO);
|
||||
// 断言
|
||||
assertNotNull(otherId);
|
||||
// 校验记录的属性是否正确
|
||||
OtherDO other = otherMapper.selectById(otherId);
|
||||
assertPojoEquals(reqVO, other);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateOther_success() {
|
||||
// mock 数据
|
||||
OtherDO dbOther = randomPojo(OtherDO.class);
|
||||
otherMapper.insert(dbOther);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
OtherUpdateReqVO reqVO = randomPojo(OtherUpdateReqVO.class, o -> {
|
||||
o.setId(dbOther.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
otherService.updateOther(reqVO);
|
||||
// 校验是否更新正确
|
||||
OtherDO other = otherMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, other);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateOther_notExists() {
|
||||
// 准备参数
|
||||
OtherUpdateReqVO reqVO = randomPojo(OtherUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> otherService.updateOther(reqVO), OTHER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteOther_success() {
|
||||
// mock 数据
|
||||
OtherDO dbOther = randomPojo(OtherDO.class);
|
||||
otherMapper.insert(dbOther);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbOther.getId();
|
||||
|
||||
// 调用
|
||||
otherService.deleteOther(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(otherMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteOther_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> otherService.deleteOther(id), OTHER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetOtherPage() {
|
||||
// mock 数据
|
||||
OtherDO dbOther = randomPojo(OtherDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setFlowCode(null);
|
||||
o.setSource(null);
|
||||
o.setYear(null);
|
||||
o.setPeriod(null);
|
||||
o.setBusinessType(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.setNote(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setRecordId(null);
|
||||
o.setUserId(null);
|
||||
o.setArchiveState(null);
|
||||
o.setRemark(null);
|
||||
});
|
||||
otherMapper.insert(dbOther);
|
||||
// 测试 name 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setName(null)));
|
||||
// 测试 flowCode 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFlowCode(null)));
|
||||
// 测试 source 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setSource(null)));
|
||||
// 测试 year 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setYear(null)));
|
||||
// 测试 period 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setPeriod(null)));
|
||||
// 测试 businessType 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setBusinessType(null)));
|
||||
// 测试 createTime 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCreateTime(null)));
|
||||
// 测试 createBy 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCreateBy(null)));
|
||||
// 测试 companyId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCompanyId(null)));
|
||||
// 测试 company 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCompany(null)));
|
||||
// 测试 suffix 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setSuffix(null)));
|
||||
// 测试 fileUrl 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFileUrl(null)));
|
||||
// 测试 fileAp 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFileAp(null)));
|
||||
// 测试 flowId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFlowId(null)));
|
||||
// 测试 note 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setNote(null)));
|
||||
// 测试 deptId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setDeptName(null)));
|
||||
// 测试 recordId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setRecordId(null)));
|
||||
// 测试 userId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setUserId(null)));
|
||||
// 测试 archiveState 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setArchiveState(null)));
|
||||
// 测试 remark 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setRemark(null)));
|
||||
// 准备参数
|
||||
OtherPageReqVO reqVO = new OtherPageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setFlowCode(null);
|
||||
reqVO.setSource(null);
|
||||
reqVO.setYear(null);
|
||||
reqVO.setPeriod(null);
|
||||
reqVO.setBusinessType(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.setNote(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setRecordId(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setArchiveState(null);
|
||||
reqVO.setRemark(null);
|
||||
|
||||
// 调用
|
||||
PageResult<OtherDO> pageResult = otherService.getOtherPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbOther, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetOtherList() {
|
||||
// mock 数据
|
||||
OtherDO dbOther = randomPojo(OtherDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setFlowCode(null);
|
||||
o.setSource(null);
|
||||
o.setYear(null);
|
||||
o.setPeriod(null);
|
||||
o.setBusinessType(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.setNote(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setRecordId(null);
|
||||
o.setUserId(null);
|
||||
o.setArchiveState(null);
|
||||
o.setRemark(null);
|
||||
});
|
||||
otherMapper.insert(dbOther);
|
||||
// 测试 name 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setName(null)));
|
||||
// 测试 flowCode 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFlowCode(null)));
|
||||
// 测试 source 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setSource(null)));
|
||||
// 测试 year 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setYear(null)));
|
||||
// 测试 period 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setPeriod(null)));
|
||||
// 测试 businessType 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setBusinessType(null)));
|
||||
// 测试 createTime 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCreateTime(null)));
|
||||
// 测试 createBy 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCreateBy(null)));
|
||||
// 测试 companyId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCompanyId(null)));
|
||||
// 测试 company 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setCompany(null)));
|
||||
// 测试 suffix 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setSuffix(null)));
|
||||
// 测试 fileUrl 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFileUrl(null)));
|
||||
// 测试 fileAp 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFileAp(null)));
|
||||
// 测试 flowId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setFlowId(null)));
|
||||
// 测试 note 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setNote(null)));
|
||||
// 测试 deptId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setDeptName(null)));
|
||||
// 测试 recordId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setRecordId(null)));
|
||||
// 测试 userId 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setUserId(null)));
|
||||
// 测试 archiveState 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setArchiveState(null)));
|
||||
// 测试 remark 不匹配
|
||||
otherMapper.insert(cloneIgnoreId(dbOther, o -> o.setRemark(null)));
|
||||
// 准备参数
|
||||
OtherExportReqVO reqVO = new OtherExportReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setFlowCode(null);
|
||||
reqVO.setSource(null);
|
||||
reqVO.setYear(null);
|
||||
reqVO.setPeriod(null);
|
||||
reqVO.setBusinessType(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.setNote(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setRecordId(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setArchiveState(null);
|
||||
reqVO.setRemark(null);
|
||||
|
||||
// 调用
|
||||
List<OtherDO> list = otherService.getOtherList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbOther, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.ea.controller.admin.electronicother;
|
||||
|
||||
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.ea.controller.admin.electronicother.vo.*;
|
||||
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicother.ElectronicOtherDO;
|
||||
import cn.iocoder.yudao.module.ea.convert.electronicother.ElectronicOtherConvert;
|
||||
import cn.iocoder.yudao.module.ea.service.electronicother.ElectronicOtherService;
|
||||
|
||||
@Tag(name = "管理后台 - 其他档案")
|
||||
@RestController
|
||||
@RequestMapping("/ea/electronic-other")
|
||||
@Validated
|
||||
public class ElectronicOtherController {
|
||||
|
||||
@Resource
|
||||
private ElectronicOtherService electronicOtherService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建其他档案")
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:create')")
|
||||
public CommonResult<Long> createElectronicOther(@Valid @RequestBody ElectronicOtherCreateReqVO createReqVO) {
|
||||
return success(electronicOtherService.createElectronicOther(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新其他档案")
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:update')")
|
||||
public CommonResult<Boolean> updateElectronicOther(@Valid @RequestBody ElectronicOtherUpdateReqVO updateReqVO) {
|
||||
electronicOtherService.updateElectronicOther(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除其他档案")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:delete')")
|
||||
public CommonResult<Boolean> deleteElectronicOther(@RequestParam("id") Long id) {
|
||||
electronicOtherService.deleteElectronicOther(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得其他档案")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:query')")
|
||||
public CommonResult<ElectronicOtherRespVO> getElectronicOther(@RequestParam("id") Long id) {
|
||||
ElectronicOtherDO electronicOther = electronicOtherService.getElectronicOther(id);
|
||||
return success(ElectronicOtherConvert.INSTANCE.convert(electronicOther));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得其他档案列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:query')")
|
||||
public CommonResult<List<ElectronicOtherRespVO>> getElectronicOtherList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ElectronicOtherDO> list = electronicOtherService.getElectronicOtherList(ids);
|
||||
return success(ElectronicOtherConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得其他档案分页")
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:query')")
|
||||
public CommonResult<PageResult<ElectronicOtherRespVO>> getElectronicOtherPage(@Valid ElectronicOtherPageReqVO pageVO) {
|
||||
PageResult<ElectronicOtherDO> pageResult = electronicOtherService.getElectronicOtherPage(pageVO);
|
||||
return success(ElectronicOtherConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出其他档案 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('ea:electronic-other:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportElectronicOtherExcel(@Valid ElectronicOtherExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ElectronicOtherDO> list = electronicOtherService.getElectronicOtherList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ElectronicOtherExcelVO> datas = ElectronicOtherConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "其他档案.xls", "数据", ElectronicOtherExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.ea.controller.admin.electronicother.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 ElectronicOtherCreateReqVO extends ElectronicOtherBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.ea.controller.admin.electronicother.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 ElectronicOtherExcelVO {
|
||||
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("表名")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("文件来源")
|
||||
private String source;
|
||||
|
||||
@ExcelProperty("年度")
|
||||
private String year;
|
||||
|
||||
@ExcelProperty("月份")
|
||||
private String period;
|
||||
|
||||
@ExcelProperty("业务类型")
|
||||
private String businessType;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ExcelProperty("制单人")
|
||||
private String createBy;
|
||||
|
||||
@ExcelProperty("业务实体")
|
||||
private String company;
|
||||
|
||||
@ExcelProperty("删除状态")
|
||||
private byte[] delStatus;
|
||||
|
||||
@ExcelProperty("文件后缀")
|
||||
private String suffix;
|
||||
|
||||
@ExcelProperty("文件地址")
|
||||
private String fileUrl;
|
||||
|
||||
@ExcelProperty("绝对路径")
|
||||
private String fileAp;
|
||||
|
||||
@ExcelProperty("摘要")
|
||||
private String note;
|
||||
|
||||
@ExcelProperty("所属部门")
|
||||
private String deptName;
|
||||
|
||||
@ExcelProperty("归档状态")
|
||||
private String archiveState;
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.ea.controller.admin.electronicother.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 ElectronicOtherPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表名", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "年度")
|
||||
private String year;
|
||||
|
||||
@Schema(description = "月份")
|
||||
private String period;
|
||||
|
||||
@Schema(description = "业务类型", example = "2")
|
||||
private String businessType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "制单人")
|
||||
private String createBy;
|
||||
|
||||
@Schema(description = "业务实体")
|
||||
private String company;
|
||||
|
||||
@Schema(description = "删除状态", example = "2")
|
||||
private byte[] delStatus;
|
||||
|
||||
@Schema(description = "文件后缀")
|
||||
private String suffix;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
private String fileUrl;
|
||||
|
||||
@Schema(description = "绝对路径")
|
||||
private String fileAp;
|
||||
|
||||
@Schema(description = "摘要")
|
||||
private String note;
|
||||
|
||||
@Schema(description = "所属部门", example = "张三")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "归档状态")
|
||||
private String archiveState;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.ea.controller.admin.electronicother.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 ElectronicOtherRespVO extends ElectronicOtherBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29291")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.ea.controller.admin.electronicother.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 ElectronicOtherUpdateReqVO extends ElectronicOtherBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29291")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.ea.convert.electronicother;
|
||||
|
||||
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.ea.controller.admin.electronicother.vo.*;
|
||||
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicother.ElectronicOtherDO;
|
||||
|
||||
/**
|
||||
* 其他档案 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ElectronicOtherConvert {
|
||||
|
||||
ElectronicOtherConvert INSTANCE = Mappers.getMapper(ElectronicOtherConvert.class);
|
||||
|
||||
ElectronicOtherDO convert(ElectronicOtherCreateReqVO bean);
|
||||
|
||||
ElectronicOtherDO convert(ElectronicOtherUpdateReqVO bean);
|
||||
|
||||
ElectronicOtherRespVO convert(ElectronicOtherDO bean);
|
||||
|
||||
List<ElectronicOtherRespVO> convertList(List<ElectronicOtherDO> list);
|
||||
|
||||
PageResult<ElectronicOtherRespVO> convertPage(PageResult<ElectronicOtherDO> page);
|
||||
|
||||
List<ElectronicOtherExcelVO> convertList02(List<ElectronicOtherDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cn.iocoder.yudao.module.ea.dal.dataobject.electronicother;
|
||||
|
||||
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("electronic_other")
|
||||
@KeySequence("electronic_other_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ElectronicOtherDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* OA/ERP流程编号
|
||||
*/
|
||||
private String flowCode;
|
||||
/**
|
||||
* 文件来源
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 年度
|
||||
*/
|
||||
private String year;
|
||||
/**
|
||||
* 月份
|
||||
*/
|
||||
private String period;
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String businessType;
|
||||
/**
|
||||
* 制单人
|
||||
*/
|
||||
private String createBy;
|
||||
/**
|
||||
* 业务实体id
|
||||
*/
|
||||
private Long companyId;
|
||||
/**
|
||||
* 业务实体
|
||||
*/
|
||||
private String company;
|
||||
/**
|
||||
* 删除状态
|
||||
*/
|
||||
private byte[] delStatus;
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String suffix;
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private String fileUrl;
|
||||
/**
|
||||
* 绝对路径
|
||||
*/
|
||||
private String fileAp;
|
||||
/**
|
||||
* 流程号
|
||||
*/
|
||||
private String flowId;
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 所属部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private String deptName;
|
||||
/**
|
||||
* 归档id
|
||||
*/
|
||||
private Long recordId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 归档状态
|
||||
*/
|
||||
private String archiveState;
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package cn.iocoder.yudao.module.ea.dal.mysql.electronicother;
|
||||
|
||||
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.ea.dal.dataobject.electronicother.ElectronicOtherDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.ea.controller.admin.electronicother.vo.*;
|
||||
|
||||
/**
|
||||
* 其他档案 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ElectronicOtherMapper extends BaseMapperX<ElectronicOtherDO> {
|
||||
|
||||
default PageResult<ElectronicOtherDO> selectPage(ElectronicOtherPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ElectronicOtherDO>()
|
||||
.likeIfPresent(ElectronicOtherDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ElectronicOtherDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(ElectronicOtherDO::getYear, reqVO.getYear())
|
||||
.eqIfPresent(ElectronicOtherDO::getPeriod, reqVO.getPeriod())
|
||||
.eqIfPresent(ElectronicOtherDO::getBusinessType, reqVO.getBusinessType())
|
||||
.betweenIfPresent(ElectronicOtherDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(ElectronicOtherDO::getCreateBy, reqVO.getCreateBy())
|
||||
.eqIfPresent(ElectronicOtherDO::getCompany, reqVO.getCompany())
|
||||
.eqIfPresent(ElectronicOtherDO::getDelStatus, reqVO.getDelStatus())
|
||||
.eqIfPresent(ElectronicOtherDO::getSuffix, reqVO.getSuffix())
|
||||
.eqIfPresent(ElectronicOtherDO::getFileUrl, reqVO.getFileUrl())
|
||||
.eqIfPresent(ElectronicOtherDO::getFileAp, reqVO.getFileAp())
|
||||
.eqIfPresent(ElectronicOtherDO::getNote, reqVO.getNote())
|
||||
.likeIfPresent(ElectronicOtherDO::getDeptName, reqVO.getDeptName())
|
||||
.eqIfPresent(ElectronicOtherDO::getArchiveState, reqVO.getArchiveState())
|
||||
.orderByDesc(ElectronicOtherDO::getId));
|
||||
}
|
||||
|
||||
default List<ElectronicOtherDO> selectList(ElectronicOtherExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ElectronicOtherDO>()
|
||||
.likeIfPresent(ElectronicOtherDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ElectronicOtherDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(ElectronicOtherDO::getYear, reqVO.getYear())
|
||||
.eqIfPresent(ElectronicOtherDO::getPeriod, reqVO.getPeriod())
|
||||
.eqIfPresent(ElectronicOtherDO::getBusinessType, reqVO.getBusinessType())
|
||||
.betweenIfPresent(ElectronicOtherDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(ElectronicOtherDO::getCreateBy, reqVO.getCreateBy())
|
||||
.eqIfPresent(ElectronicOtherDO::getCompany, reqVO.getCompany())
|
||||
.eqIfPresent(ElectronicOtherDO::getDelStatus, reqVO.getDelStatus())
|
||||
.eqIfPresent(ElectronicOtherDO::getSuffix, reqVO.getSuffix())
|
||||
.eqIfPresent(ElectronicOtherDO::getFileUrl, reqVO.getFileUrl())
|
||||
.eqIfPresent(ElectronicOtherDO::getFileAp, reqVO.getFileAp())
|
||||
.eqIfPresent(ElectronicOtherDO::getNote, reqVO.getNote())
|
||||
.likeIfPresent(ElectronicOtherDO::getDeptName, reqVO.getDeptName())
|
||||
.eqIfPresent(ElectronicOtherDO::getArchiveState, reqVO.getArchiveState())
|
||||
.orderByDesc(ElectronicOtherDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.ea.service.electronicother;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.ea.controller.admin.electronicother.vo.*;
|
||||
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicother.ElectronicOtherDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 其他档案 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface ElectronicOtherService {
|
||||
|
||||
/**
|
||||
* 创建其他档案
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createElectronicOther(@Valid ElectronicOtherCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新其他档案
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateElectronicOther(@Valid ElectronicOtherUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除其他档案
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteElectronicOther(Long id);
|
||||
|
||||
/**
|
||||
* 获得其他档案
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 其他档案
|
||||
*/
|
||||
ElectronicOtherDO getElectronicOther(Long id);
|
||||
|
||||
/**
|
||||
* 获得其他档案列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 其他档案列表
|
||||
*/
|
||||
List<ElectronicOtherDO> getElectronicOtherList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得其他档案分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 其他档案分页
|
||||
*/
|
||||
PageResult<ElectronicOtherDO> getElectronicOtherPage(ElectronicOtherPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得其他档案列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 其他档案列表
|
||||
*/
|
||||
List<ElectronicOtherDO> getElectronicOtherList(ElectronicOtherExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.ea.service.electronicother;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.ea.controller.admin.electronicother.vo.*;
|
||||
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicother.ElectronicOtherDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.ea.convert.electronicother.ElectronicOtherConvert;
|
||||
import cn.iocoder.yudao.module.ea.dal.mysql.electronicother.ElectronicOtherMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.ea.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 其他档案 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ElectronicOtherServiceImpl implements ElectronicOtherService {
|
||||
|
||||
@Resource
|
||||
private ElectronicOtherMapper electronicOtherMapper;
|
||||
|
||||
@Override
|
||||
public Long createElectronicOther(ElectronicOtherCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ElectronicOtherDO electronicOther = ElectronicOtherConvert.INSTANCE.convert(createReqVO);
|
||||
electronicOtherMapper.insert(electronicOther);
|
||||
// 返回
|
||||
return electronicOther.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateElectronicOther(ElectronicOtherUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateElectronicOtherExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ElectronicOtherDO updateObj = ElectronicOtherConvert.INSTANCE.convert(updateReqVO);
|
||||
electronicOtherMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteElectronicOther(Long id) {
|
||||
// 校验存在
|
||||
validateElectronicOtherExists(id);
|
||||
// 删除
|
||||
electronicOtherMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateElectronicOtherExists(Long id) {
|
||||
if (electronicOtherMapper.selectById(id) == null) {
|
||||
throw exception(ELECTRONIC_OTHER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectronicOtherDO getElectronicOther(Long id) {
|
||||
return electronicOtherMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ElectronicOtherDO> getElectronicOtherList(Collection<Long> ids) {
|
||||
return electronicOtherMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ElectronicOtherDO> getElectronicOtherPage(ElectronicOtherPageReqVO pageReqVO) {
|
||||
return electronicOtherMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ElectronicOtherDO> getElectronicOtherList(ElectronicOtherExportReqVO exportReqVO) {
|
||||
return electronicOtherMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -1,231 +0,0 @@
|
||||
package cn.iocoder.yudao.module.setting.service.detection;
|
||||
|
||||
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.setting.controller.admin.detection.vo.*;
|
||||
import cn.iocoder.yudao.module.setting.dal.dataobject.detection.DetectionDO;
|
||||
import cn.iocoder.yudao.module.setting.dal.mysql.detection.DetectionMapper;
|
||||
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.setting.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 DetectionServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author devin1
|
||||
*/
|
||||
@Import(DetectionServiceImpl.class)
|
||||
public class DetectionServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private DetectionServiceImpl detectionService;
|
||||
|
||||
@Resource
|
||||
private DetectionMapper detectionMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateDetection_success() {
|
||||
// 准备参数
|
||||
DetectionCreateReqVO reqVO = randomPojo(DetectionCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long detectionId = detectionService.createDetection(reqVO);
|
||||
// 断言
|
||||
assertNotNull(detectionId);
|
||||
// 校验记录的属性是否正确
|
||||
DetectionDO detection = detectionMapper.selectById(detectionId);
|
||||
assertPojoEquals(reqVO, detection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDetection_success() {
|
||||
// mock 数据
|
||||
DetectionDO dbDetection = randomPojo(DetectionDO.class);
|
||||
detectionMapper.insert(dbDetection);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
DetectionUpdateReqVO reqVO = randomPojo(DetectionUpdateReqVO.class, o -> {
|
||||
o.setId(dbDetection.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
detectionService.updateDetection(reqVO);
|
||||
// 校验是否更新正确
|
||||
DetectionDO detection = detectionMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, detection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDetection_notExists() {
|
||||
// 准备参数
|
||||
DetectionUpdateReqVO reqVO = randomPojo(DetectionUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> detectionService.updateDetection(reqVO), DETECTION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDetection_success() {
|
||||
// mock 数据
|
||||
DetectionDO dbDetection = randomPojo(DetectionDO.class);
|
||||
detectionMapper.insert(dbDetection);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbDetection.getId();
|
||||
|
||||
// 调用
|
||||
detectionService.deleteDetection(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(detectionMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDetection_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> detectionService.deleteDetection(id), DETECTION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetDetectionPage() {
|
||||
// mock 数据
|
||||
DetectionDO dbDetection = randomPojo(DetectionDO.class, o -> { // 等会查询到
|
||||
o.setOneType(null);
|
||||
o.setTwoType(null);
|
||||
o.setCode(null);
|
||||
o.setName(null);
|
||||
o.setPurpose(null);
|
||||
o.setObjects(null);
|
||||
o.setMethods(null);
|
||||
o.setEnableFlag(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
o.setCreateBy(null);
|
||||
});
|
||||
detectionMapper.insert(dbDetection);
|
||||
// 测试 oneType 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setOneType(null)));
|
||||
// 测试 twoType 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setTwoType(null)));
|
||||
// 测试 code 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setCode(null)));
|
||||
// 测试 name 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setName(null)));
|
||||
// 测试 purpose 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setPurpose(null)));
|
||||
// 测试 objects 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setObjects(null)));
|
||||
// 测试 methods 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setMethods(null)));
|
||||
// 测试 enableFlag 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setEnableFlag(null)));
|
||||
// 测试 remark 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setRemark(null)));
|
||||
// 测试 createTime 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setCreateTime(null)));
|
||||
// 测试 createBy 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setCreateBy(null)));
|
||||
// 准备参数
|
||||
DetectionPageReqVO reqVO = new DetectionPageReqVO();
|
||||
reqVO.setOneType(null);
|
||||
reqVO.setTwoType(null);
|
||||
reqVO.setCode(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setPurpose(null);
|
||||
reqVO.setObjects(null);
|
||||
reqVO.setMethods(null);
|
||||
reqVO.setEnableFlag(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setCreateBy(null);
|
||||
|
||||
// 调用
|
||||
PageResult<DetectionDO> pageResult = detectionService.getDetectionPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbDetection, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetDetectionList() {
|
||||
// mock 数据
|
||||
DetectionDO dbDetection = randomPojo(DetectionDO.class, o -> { // 等会查询到
|
||||
o.setOneType(null);
|
||||
o.setTwoType(null);
|
||||
o.setCode(null);
|
||||
o.setName(null);
|
||||
o.setPurpose(null);
|
||||
o.setObjects(null);
|
||||
o.setMethods(null);
|
||||
o.setEnableFlag(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
o.setCreateBy(null);
|
||||
});
|
||||
detectionMapper.insert(dbDetection);
|
||||
// 测试 oneType 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setOneType(null)));
|
||||
// 测试 twoType 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setTwoType(null)));
|
||||
// 测试 code 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setCode(null)));
|
||||
// 测试 name 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setName(null)));
|
||||
// 测试 purpose 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setPurpose(null)));
|
||||
// 测试 objects 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setObjects(null)));
|
||||
// 测试 methods 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setMethods(null)));
|
||||
// 测试 enableFlag 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setEnableFlag(null)));
|
||||
// 测试 remark 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setRemark(null)));
|
||||
// 测试 createTime 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setCreateTime(null)));
|
||||
// 测试 createBy 不匹配
|
||||
detectionMapper.insert(cloneIgnoreId(dbDetection, o -> o.setCreateBy(null)));
|
||||
// 准备参数
|
||||
DetectionExportReqVO reqVO = new DetectionExportReqVO();
|
||||
reqVO.setOneType(null);
|
||||
reqVO.setTwoType(null);
|
||||
reqVO.setCode(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setPurpose(null);
|
||||
reqVO.setObjects(null);
|
||||
reqVO.setMethods(null);
|
||||
reqVO.setEnableFlag(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setCreateBy(null);
|
||||
|
||||
// 调用
|
||||
List<DetectionDO> list = detectionService.getDetectionList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbDetection, list.get(0));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue