进一步同步 boot 和 cloud 代码,移除多余无用的类

pull/99/head
YunaiV 2024-02-27 17:11:56 +08:00
parent 36a5859344
commit 8145586764
19 changed files with 0 additions and 1788 deletions

View File

@ -1,78 +0,0 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler;
import java.lang.annotation.Annotation;
/**
*
*
* @author gaibu
*/
public abstract class AbstractDesensitizationHandler<T extends Annotation>
implements DesensitizationHandler<T> {
@Override
public String desensitize(String origin, T annotation) {
int prefixKeep = getPrefixKeep(annotation);
int suffixKeep = getSuffixKeep(annotation);
String replacer = getReplacer(annotation);
int length = origin.length();
// 情况一:原始字符串长度小于等于保留长度,则原始字符串全部替换
if (prefixKeep >= length || suffixKeep >= length) {
return buildReplacerByLength(replacer, length);
}
// 情况二:原始字符串长度小于等于前后缀保留字符串长度,则原始字符串全部替换
if ((prefixKeep + suffixKeep) >= length) {
return buildReplacerByLength(replacer, length);
}
// 情况三:原始字符串长度大于前后缀保留字符串长度,则替换中间字符串
int interval = length - prefixKeep - suffixKeep;
return origin.substring(0, prefixKeep) +
buildReplacerByLength(replacer, interval) +
origin.substring(prefixKeep + interval);
}
/**
*
*
* @param replacer
* @param length
* @return
*/
private String buildReplacerByLength(String replacer, int length) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < length; i++) {
builder.append(replacer);
}
return builder.toString();
}
/**
*
*
* @param annotation
* @return
*/
abstract Integer getPrefixKeep(T annotation);
/**
*
*
* @param annotation
* @return
*/
abstract Integer getSuffixKeep(T annotation);
/**
*
*
* @param annotation
* @return
*/
abstract String getReplacer(T annotation);
}

View File

@ -1,119 +0,0 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import jakarta.annotation.Resource;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿:后续再 review
/**
* {@link CrmBusinessStatusTypeServiceImpl}
*
* @author ljlleo
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmBusinessStatusTypeServiceImpl.class)
public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmBusinessStatusTypeServiceImpl businessStatusTypeService;
@Resource
private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
@Test
public void testCreateBusinessStatusType_success() {
// 准备参数
CrmBusinessStatusTypeSaveReqVO createReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class).setId(null);
// 调用
Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(createReqVO);
// 断言
assertNotNull(businessStatusTypeId);
// 校验记录的属性是否正确
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId);
assertPojoEquals(createReqVO, businessStatusType, "id");
}
@Test
public void testUpdateBusinessStatusType_success() {
// mock 数据
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class, o -> {
o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID
});
// 调用
businessStatusTypeService.updateBusinessStatusType(updateReqVO);
// 校验是否更新正确
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的
assertPojoEquals(updateReqVO, businessStatusType);
}
@Test
public void testUpdateBusinessStatusType_notExists() {
// 准备参数
CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(updateReqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS);
}
@Test
public void testDeleteBusinessStatusType_success() {
// mock 数据
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class);
businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbBusinessStatusType.getId();
// 调用
businessStatusTypeService.deleteBusinessStatusType(id);
// 校验数据不存在了
assertNull(businessStatusTypeMapper.selectById(id));
}
@Test
public void testDeleteBusinessStatusType_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> businessStatusTypeService.deleteBusinessStatusType(id), BUSINESS_STATUS_TYPE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetBusinessStatusTypePage() {
// mock 数据
CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到
});
businessStatusTypeMapper.insert(dbBusinessStatusType);
// 准备参数
CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO();
// 调用
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0));
}
}

View File

@ -1,181 +0,0 @@
package cn.iocoder.yudao.module.crm.service.business;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
* {@link CrmBusinessServiceImpl}
*
* @author ljlleo
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmBusinessServiceImpl.class)
public class CrmBusinessServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmBusinessServiceImpl businessService;
@Resource
private CrmBusinessMapper businessMapper;
@Test
public void testCreateBusiness_success() {
// 准备参数
CrmBusinessSaveReqVO reqVO = randomPojo(CrmBusinessSaveReqVO.class);
// 调用
Long businessId = businessService.createBusiness(reqVO, getLoginUserId());
// 断言
assertNotNull(businessId);
// 校验记录的属性是否正确
CrmBusinessDO business = businessMapper.selectById(businessId);
assertPojoEquals(reqVO, business);
}
@Test
public void testUpdateBusiness_success() {
// mock 数据
CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class);
businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmBusinessSaveReqVO reqVO = randomPojo(CrmBusinessSaveReqVO.class, o -> {
o.setId(dbBusiness.getId()); // 设置更新的 ID
});
// 调用
businessService.updateBusiness(reqVO);
// 校验是否更新正确
CrmBusinessDO business = businessMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, business);
}
@Test
public void testUpdateBusiness_notExists() {
// 准备参数
CrmBusinessSaveReqVO reqVO = randomPojo(CrmBusinessSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> businessService.updateBusiness(reqVO), BUSINESS_NOT_EXISTS);
}
@Test
public void testDeleteBusiness_success() {
// mock 数据
CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class);
businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbBusiness.getId();
// 调用
businessService.deleteBusiness(id);
// 校验数据不存在了
assertNull(businessMapper.selectById(id));
}
@Test
public void testDeleteBusiness_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> businessService.deleteBusiness(id), BUSINESS_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetBusinessPage() {
// mock 数据
CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到
o.setName(null);
o.setStatusTypeId(null);
o.setStatusId(null);
o.setContactNextTime(null);
o.setCustomerId(null);
o.setDealTime(null);
o.setPrice(null);
o.setDiscountPercent(null);
o.setProductPrice(null);
o.setRemark(null);
o.setCreateTime(null);
o.setEndStatus(null);
o.setEndRemark(null);
o.setContactLastTime(null);
o.setFollowUpStatus(null);
});
businessMapper.insert(dbBusiness);
// 测试 name 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null)));
// 测试 statusTypeId 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null)));
// 测试 statusId 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null)));
// 测试 contactNextTime 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null)));
// 测试 customerId 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null)));
// 测试 dealTime 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null)));
// 测试 price 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null)));
// 测试 discountPercent 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null)));
// 测试 productPrice 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null)));
// 测试 remark 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null)));
// 测试 createTime 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null)));
// 测试 endStatus 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null)));
// 测试 endRemark 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null)));
// 测试 contactLastTime 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null)));
// 测试 followUpStatus 不匹配
businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null)));
//// 准备参数
//CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO();
//reqVO.setName(null);
//reqVO.setStatusTypeId(null);
//reqVO.setStatusId(null);
//reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
//reqVO.setCustomerId(null);
//reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
//reqVO.setPrice(null);
//reqVO.setDiscountPercent(null);
//reqVO.setProductPrice(null);
//reqVO.setRemark(null);
//reqVO.setOwnerUserId(null);
//reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
//reqVO.setRoUserIds(null);
//reqVO.setRwUserIds(null);
//reqVO.setEndStatus(null);
//reqVO.setEndRemark(null);
//reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
//reqVO.setFollowUpStatus(null);
//
//// 调用
//PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(reqVO);
//// 断言
//assertEquals(1, pageResult.getTotal());
//assertEquals(1, pageResult.getList().size());
//assertPojoEquals(dbBusiness, pageResult.getList().get(0));
}
}

View File

@ -1,207 +0,0 @@
package cn.iocoder.yudao.module.crm.service.clue;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿:单测后续补;
/**
* {@link CrmClueServiceImpl}
*
* @author Wanwan
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmClueServiceImpl.class)
public class CrmClueServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmClueServiceImpl clueService;
@Resource
private CrmClueMapper clueMapper;
@Test
public void testCreateClue_success() {
// 准备参数
CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class);
// 调用
Long clueId = clueService.createClue(reqVO, getLoginUserId());
// 断言
assertNotNull(clueId);
// 校验记录的属性是否正确
CrmClueDO clue = clueMapper.selectById(clueId);
assertPojoEquals(reqVO, clue);
}
@Test
public void testUpdateClue_success() {
// mock 数据
CrmClueDO dbClue = randomPojo(CrmClueDO.class);
clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class, o -> {
o.setId(dbClue.getId()); // 设置更新的 ID
});
// 调用
clueService.updateClue(reqVO);
// 校验是否更新正确
CrmClueDO clue = clueMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, clue);
}
@Test
public void testUpdateClue_notExists() {
// 准备参数
CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS);
}
@Test
public void testDeleteClue_success() {
// mock 数据
CrmClueDO dbClue = randomPojo(CrmClueDO.class);
clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbClue.getId();
// 调用
clueService.deleteClue(id);
// 校验数据不存在了
assertNull(clueMapper.selectById(id));
}
@Test
public void testDeleteClue_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> clueService.deleteClue(id), CLUE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetCluePage() {
// mock 数据
CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到
o.setTransformStatus(null);
o.setFollowUpStatus(null);
o.setName(null);
o.setCustomerId(null);
o.setContactNextTime(null);
o.setTelephone(null);
o.setMobile(null);
o.setAddress(null);
o.setContactLastTime(null);
o.setCreateTime(null);
});
clueMapper.insert(dbClue);
// 测试 transformStatus 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null)));
// 测试 followUpStatus 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null)));
// 测试 name 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null)));
// 测试 customerId 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null)));
// 测试 contactNextTime 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null)));
// 测试 telephone 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null)));
// 测试 mobile 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null)));
// 测试 address 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null)));
// 测试 contactLastTime 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null)));
// 测试 createTime 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null)));
// 准备参数
CrmCluePageReqVO reqVO = new CrmCluePageReqVO();
reqVO.setName(null);
reqVO.setTelephone(null);
reqVO.setMobile(null);
// 调用
PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, 1L);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbClue, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetClueList() {
// mock 数据
CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到
o.setTransformStatus(null);
o.setFollowUpStatus(null);
o.setName(null);
o.setCustomerId(null);
o.setContactNextTime(null);
o.setTelephone(null);
o.setMobile(null);
o.setAddress(null);
o.setContactLastTime(null);
o.setCreateTime(null);
});
clueMapper.insert(dbClue);
// 测试 transformStatus 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null)));
// 测试 followUpStatus 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null)));
// 测试 name 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null)));
// 测试 customerId 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null)));
// 测试 contactNextTime 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null)));
// 测试 telephone 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null)));
// 测试 mobile 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null)));
// 测试 address 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null)));
// 测试 contactLastTime 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null)));
// 测试 createTime 不匹配
clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null)));
// 准备参数
CrmCluePageReqVO reqVO = new CrmCluePageReqVO();
reqVO.setName(null);
reqVO.setTelephone(null);
reqVO.setMobile(null);
reqVO.setPageSize(PAGE_SIZE_NONE);
// 调用
List<CrmClueDO> list = clueService.getCluePage(reqVO, 1L).getList();
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbClue, list.get(0));
}
}

View File

@ -1,135 +0,0 @@
package cn.iocoder.yudao.module.crm.service.contract;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
/**
* {@link CrmContractServiceImpl}
*
* @author dhb52
*/
@Import(CrmContractServiceImpl.class)
public class ContractServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmContractServiceImpl contractService;
@Resource
private CrmContractMapper contractMapper;
@Test
public void testCreateContract_success() {
// 准备参数
CrmContractSaveReqVO reqVO = randomPojo(CrmContractSaveReqVO.class);
// 调用
Long contractId = contractService.createContract(reqVO, getLoginUserId());
// 断言
assertNotNull(contractId);
// 校验记录的属性是否正确
CrmContractDO contract = contractMapper.selectById(contractId);
assertPojoEquals(reqVO, contract);
}
@Test
public void testUpdateContract_success() {
// mock 数据
CrmContractDO dbContract = randomPojo(CrmContractDO.class);
contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmContractSaveReqVO reqVO = randomPojo(CrmContractSaveReqVO.class, o -> {
o.setId(dbContract.getId()); // 设置更新的 ID
});
// 调用
contractService.updateContract(reqVO);
// 校验是否更新正确
CrmContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, contract);
}
@Test
public void testUpdateContract_notExists() {
// 准备参数
CrmContractSaveReqVO reqVO = randomPojo(CrmContractSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS);
}
@Test
public void testDeleteContract_success() {
// mock 数据
CrmContractDO dbContract = randomPojo(CrmContractDO.class);
contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbContract.getId();
// 调用
contractService.deleteContract(id);
// 校验数据不存在了
assertNull(contractMapper.selectById(id));
}
@Test
public void testDeleteContract_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> contractService.deleteContract(id), CONTRACT_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetContractPage() {
// mock 数据
CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到
o.setName(null);
o.setCustomerId(null);
o.setBusinessId(null);
o.setOrderDate(null);
o.setNo(null);
o.setDiscountPercent(null);
o.setProductPrice(null);
});
contractMapper.insert(dbContract);
// 测试 name 不匹配
contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null)));
// 测试 customerId 不匹配
contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null)));
// 测试 no 不匹配
contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null)));
// 准备参数
CrmContractPageReqVO reqVO = new CrmContractPageReqVO();
reqVO.setName(null);
reqVO.setCustomerId(null);
reqVO.setBusinessId(null);
reqVO.setNo(null);
// 调用
PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO, getLoginUserId());
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbContract, pageResult.getList().get(0));
}
}

View File

@ -1,141 +0,0 @@
package cn.iocoder.yudao.module.crm.service.customer;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿:单测后续补
/**
* {@link CrmCustomerServiceImpl}
*
* @author Wanwan
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmCustomerServiceImpl.class)
public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmCustomerServiceImpl customerService;
@Resource
private CrmCustomerMapper customerMapper;
@MockBean
private CrmPermissionService permissionService;
@Test
public void testCreateCustomer_success() {
// 准备参数
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class);
// 调用
Long customerId = customerService.createCustomer(reqVO, getLoginUserId());
// 断言
assertNotNull(customerId);
// 校验记录的属性是否正确
CrmCustomerDO customer = customerMapper.selectById(customerId);
assertPojoEquals(reqVO, customer);
}
@Test
public void testUpdateCustomer_success() {
// mock 数据
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class);
customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class, o -> {
o.setId(dbCustomer.getId()); // 设置更新的 ID
});
// 调用
customerService.updateCustomer(reqVO);
// 校验是否更新正确
CrmCustomerDO customer = customerMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, customer);
}
@Test
public void testUpdateCustomer_notExists() {
// 准备参数
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS);
}
@Test
public void testDeleteCustomer_success() {
// mock 数据
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class);
customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbCustomer.getId();
// 调用
customerService.deleteCustomer(id);
// 校验数据不存在了
assertNull(customerMapper.selectById(id));
}
@Test
public void testDeleteCustomer_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> customerService.deleteCustomer(id), CUSTOMER_NOT_EXISTS);
}
@Test
public void testGetCustomerPage() {
// mock 数据
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到
o.setName("张三");
o.setMobile("13888888888");
o.setTelephone("13888888888");
o.setWebsite("https://yudao.com");
});
//customerMapper.insert(dbCustomer);
// 测试 name 不匹配
//customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName("")));
// 测试 mobile 不匹配
//customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null)));
// 测试 telephone 不匹配
//customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null)));
// 测试 website 不匹配
//customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null)));
// 准备参数
CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO();
reqVO.setName("张三");
reqVO.setMobile("13888888888");
//reqVO.setTelephone(null);
//reqVO.setWebsite(null);
// 调用
PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L);
// 断言
//assertEquals(1, pageResult.getTotal());
//assertEquals(1, pageResult.getList().size());
//assertPojoEquals(dbCustomer, pageResult.getList().get(0));
}
}

View File

@ -1,119 +0,0 @@
package cn.iocoder.yudao.module.crm.service.customerlimitconfig;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿:单测后面搞
/**
* {@link CrmCustomerLimitConfigServiceImpl}
*
* @author Wanwan
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmCustomerLimitConfigServiceImpl.class)
public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmCustomerLimitConfigServiceImpl customerLimitConfigService;
@Resource
private CrmCustomerLimitConfigMapper customerLimitConfigMapper;
@Test
public void testCreateCustomerLimitConfig_success() {
// 准备参数
CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class);
// 调用
Long customerLimitConfigId = customerLimitConfigService.createCustomerLimitConfig(reqVO);
// 断言
assertNotNull(customerLimitConfigId);
// 校验记录的属性是否正确
CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(customerLimitConfigId);
assertPojoEquals(reqVO, customerLimitConfig);
}
@Test
public void testUpdateCustomerLimitConfig_success() {
// mock 数据
CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class);
customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class, o -> {
o.setId(dbCustomerLimitConfig.getId()); // 设置更新的 ID
});
// 调用
customerLimitConfigService.updateCustomerLimitConfig(reqVO);
// 校验是否更新正确
CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, customerLimitConfig);
}
@Test
public void testUpdateCustomerLimitConfig_notExists() {
// 准备参数
CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> customerLimitConfigService.updateCustomerLimitConfig(reqVO), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS);
}
@Test
public void testDeleteCustomerLimitConfig_success() {
// mock 数据
CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class);
customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbCustomerLimitConfig.getId();
// 调用
customerLimitConfigService.deleteCustomerLimitConfig(id);
// 校验数据不存在了
assertNull(customerLimitConfigMapper.selectById(id));
}
@Test
public void testDeleteCustomerLimitConfig_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> customerLimitConfigService.deleteCustomerLimitConfig(id), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetCustomerLimitConfigPage() {
// mock 数据
CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class, o -> { // 等会查询到
});
customerLimitConfigMapper.insert(dbCustomerLimitConfig);
// 准备参数
CrmCustomerLimitConfigPageReqVO reqVO = new CrmCustomerLimitConfigPageReqVO();
// 调用
PageResult<CrmCustomerLimitConfigDO> pageResult = customerLimitConfigService.getCustomerLimitConfigPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbCustomerLimitConfig, pageResult.getList().get(0));
}
}

View File

@ -1,137 +0,0 @@
package cn.iocoder.yudao.module.crm.service.receivable;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿:后续,需要补充测试用例
/**
* {@link CrmReceivablePlanServiceImpl}
*
* @author
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmReceivablePlanServiceImpl.class)
public class CrmCrmReceivablePlanServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmReceivablePlanServiceImpl receivablePlanService;
@Resource
private CrmReceivablePlanMapper crmReceivablePlanMapper;
@Test
public void testCreateReceivablePlan_success() {
// 准备参数
CrmReceivablePlanCreateReqVO reqVO = randomPojo(CrmReceivablePlanCreateReqVO.class);
// 调用
Long receivablePlanId = receivablePlanService.createReceivablePlan(reqVO, 1L);
// 断言
assertNotNull(receivablePlanId);
// 校验记录的属性是否正确
CrmReceivablePlanDO receivablePlan = crmReceivablePlanMapper.selectById(receivablePlanId);
assertPojoEquals(reqVO, receivablePlan);
}
@Test
public void testUpdateReceivablePlan_success() {
// mock 数据
CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class);
crmReceivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmReceivablePlanUpdateReqVO reqVO = randomPojo(CrmReceivablePlanUpdateReqVO.class, o -> {
o.setId(dbReceivablePlan.getId()); // 设置更新的 ID
});
// 调用
receivablePlanService.updateReceivablePlan(reqVO);
// 校验是否更新正确
CrmReceivablePlanDO receivablePlan = crmReceivablePlanMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, receivablePlan);
}
@Test
public void testUpdateReceivablePlan_notExists() {
// 准备参数
CrmReceivablePlanUpdateReqVO reqVO = randomPojo(CrmReceivablePlanUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> receivablePlanService.updateReceivablePlan(reqVO), RECEIVABLE_PLAN_NOT_EXISTS);
}
@Test
public void testDeleteReceivablePlan_success() {
// mock 数据
CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class);
crmReceivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbReceivablePlan.getId();
// 调用
receivablePlanService.deleteReceivablePlan(id);
// 校验数据不存在了
assertNull(crmReceivablePlanMapper.selectById(id));
}
@Test
public void testDeleteReceivablePlan_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> receivablePlanService.deleteReceivablePlan(id), RECEIVABLE_PLAN_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetReceivablePlanPage() {
// mock 数据
CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class, o -> { // 等会查询到
o.setPeriod(null);
o.setReturnTime(null);
o.setRemindDays(null);
o.setRemindTime(null);
o.setCustomerId(null);
o.setContractId(null);
o.setOwnerUserId(null);
o.setRemark(null);
o.setCreateTime(null);
});
crmReceivablePlanMapper.insert(dbReceivablePlan);
// 测试 customerId 不匹配
crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null)));
// 测试 contractId 不匹配
crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null)));
// 准备参数
CrmReceivablePlanPageReqVO reqVO = new CrmReceivablePlanPageReqVO();
reqVO.setCustomerId(null);
reqVO.setContractId(null);
reqVO.setPageSize(PAGE_SIZE_NONE);
// 调用
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(reqVO, 1L);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0));
}
}

View File

@ -1,143 +0,0 @@
package cn.iocoder.yudao.module.crm.service.receivable;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO;
import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
// TODO 芋艿:等实现完,在校验下;
/**
* {@link CrmReceivableServiceImpl}
*
* @author
*/
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import(CrmReceivableServiceImpl.class)
public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest {
@Resource
private CrmReceivableServiceImpl receivableService;
@Resource
private CrmReceivableMapper crmReceivableMapper;
@Test
public void testCreateReceivable_success() {
// 准备参数
CrmReceivableCreateReqVO reqVO = randomPojo(CrmReceivableCreateReqVO.class);
// 调用
Long receivableId = receivableService.createReceivable(reqVO, getLoginUserId());
// 断言
assertNotNull(receivableId);
// 校验记录的属性是否正确
CrmReceivableDO receivable = crmReceivableMapper.selectById(receivableId);
assertPojoEquals(reqVO, receivable);
}
@Test
public void testUpdateReceivable_success() {
// mock 数据
CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class);
crmReceivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据
// 准备参数
CrmReceivableUpdateReqVO reqVO = randomPojo(CrmReceivableUpdateReqVO.class, o -> {
o.setId(dbReceivable.getId()); // 设置更新的 ID
});
// 调用
receivableService.updateReceivable(reqVO);
// 校验是否更新正确
CrmReceivableDO receivable = crmReceivableMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, receivable);
}
@Test
public void testUpdateReceivable_notExists() {
// 准备参数
CrmReceivableUpdateReqVO reqVO = randomPojo(CrmReceivableUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS);
}
@Test
public void testDeleteReceivable_success() {
// mock 数据
CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class);
crmReceivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbReceivable.getId();
// 调用
receivableService.deleteReceivable(id);
// 校验数据不存在了
assertNull(crmReceivableMapper.selectById(id));
}
@Test
public void testDeleteReceivable_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetReceivablePage() {
// mock 数据
CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class, o -> { // 等会查询到
o.setNo(null);
o.setPlanId(null);
o.setCustomerId(null);
o.setContractId(null);
o.setProcessInstanceId(null);
o.setReturnTime(null);
o.setReturnType(null);
o.setPrice(null);
o.setOwnerUserId(null);
o.setSort(null);
o.setAuditStatus(null);
o.setRemark(null);
o.setCreateTime(null);
});
crmReceivableMapper.insert(dbReceivable);
// 测试 no 不匹配
crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null)));
// 测试 planId 不匹配
crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null)));
// 测试 customerId 不匹配
crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null)));
// 准备参数
CrmReceivablePageReqVO reqVO = new CrmReceivablePageReqVO();
reqVO.setNo(null);
reqVO.setPlanId(null);
reqVO.setCustomerId(null);
// 调用
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(reqVO, 1L);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbReceivable, pageResult.getList().get(0));
}
}

View File

@ -1,11 +0,0 @@
DELETE FROM "crm_contract";
DELETE FROM "crm_clue";
DELETE FROM "crm_receivable";
DELETE FROM "crm_receivable_plan";
DELETE FROM "crm_customer";
DELETE FROM "crm_customer_limit_config";

View File

@ -1,162 +0,0 @@
CREATE TABLE IF NOT EXISTS "crm_contract" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar NOT NULL,
"customer_id" bigint,
"business_id" bigint,
"process_instance_id" bigint,
"order_date" varchar,
"owner_user_id" bigint,
"no" varchar,
"start_time" varchar,
"end_time" varchar,
"price" int,
"discount_percent" int,
"product_price" int,
"ro_user_ids" varchar,
"rw_user_ids" varchar,
"contact_id" bigint,
"sign_user_id" bigint,
"contact_last_time" varchar,
"remark" varchar,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '合同表';
CREATE TABLE IF NOT EXISTS "crm_clue" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"transform_status" bit NOT NULL,
"follow_up_status" bit NOT NULL,
"name" varchar NOT NULL,
"customer_id" bigint NOT NULL,
"contact_next_time" varchar,
"telephone" varchar,
"mobile" varchar,
"address" varchar,
"owner_user_id" bigint,
"contact_last_time" varchar,
"remark" varchar,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL,
PRIMARY KEY ("id")
) COMMENT '线索表';
CREATE TABLE IF NOT EXISTS "crm_receivable" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"no" varchar,
"plan_id" bigint,
"customer_id" bigint,
"contract_id" bigint,
"check_status" int,
"process_instance_id" bigint,
"return_time" varchar,
"return_type" varchar,
"price" varchar,
"owner_user_id" bigint,
"batch_id" bigint,
"sort" int,
"data_scope" int,
"data_scope_dept_ids" varchar,
"status" int NOT NULL,
"remark" varchar,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '回款';
CREATE TABLE IF NOT EXISTS "crm_receivable_plan" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"index_no" bigint,
"receivable_id" bigint,
"status" int NOT NULL,
"check_status" varchar,
"process_instance_id" bigint,
"price" varchar,
"return_time" varchar,
"remind_days" bigint,
"remind_time" varchar,
"customer_id" bigint,
"contract_id" bigint,
"owner_user_id" bigint,
"sort" int,
"remark" varchar,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '回款计划';
CREATE TABLE IF NOT EXISTS "crm_customer" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(255),
"follow_up_status" int NOT NULL,
"lock_status" int NOT NULL,
"deal_status" int NOT NULL,
"industry_id" int,
"level" int,
"source" int,
"mobile" varchar(255),
"telephone" varchar(255),
"website" varchar(255),
"qq" varchar(255),
"wechat" varchar(255),
"email" varchar(255),
"description" varchar(255),
"remark" varchar(255),
"owner_user_id" bigint,
"area_id" int,
"detail_address" varchar(255),
"contact_last_time" datetime,
"contact_next_time" datetime,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL,
PRIMARY KEY ("id")
) COMMENT '客户表';
CREATE TABLE IF NOT EXISTS "crm_customer_limit_config" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"type" int NOT NULL,
"user_ids" varchar,
"dept_ids" varchar,
"max_count" int NOT NULL,
"deal_count_enabled" varchar,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL,
PRIMARY KEY ("id")
) COMMENT '客户限制配置表';
CREATE TABLE IF NOT EXISTS "crm_permission"
(
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"biz_id" bigint NOT NULL,
"biz_type" int NOT NULL,
"user_id" bigint NOT NULL,
"level" int NOT NULL,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL,
PRIMARY KEY ("id")
) COMMENT '客户限制配置表';

View File

@ -1,27 +0,0 @@
package cn.iocoder.yudao.module.infra.controller.admin.health;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.security.PermitAll;
/**
* @description:
* @author: jhaol
*/
@Tag(name = "infra 模块 - 健康检查")
@RestController
@RequestMapping("/infra/health")
@Validated
public class HealthController {
@GetMapping()
@Operation(summary = "健康检查")
@PermitAll
public Integer health() {
return 0;
}
}

View File

@ -1,70 +0,0 @@
package cn.iocoder.yudao.module.statistics.dal.dataobject.member;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
/**
* DO
* <p>
*
*
* @author
*/
@TableName("member_statistics")
@KeySequence("member_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberStatisticsDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
*
*/
private LocalDateTime time;
/**
*
*/
private Integer userRegisterCount;
/**
* 访UV
*/
private Integer userVisitCount;
/**
* 访PV
*/
private Integer pageVisitCount;
/**
*
*/
private Integer rechargeUserCount;
/**
*
*/
private Integer orderCreateUserCount;
/**
*
*/
private Integer orderPayUserCount;
/**
*
*/
private Integer orderPayPrice;
}

View File

@ -1,74 +0,0 @@
package cn.iocoder.yudao.module.statistics.dal.mysql.product;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
/**
* SPU DO
*
* SPU
*
* @author
*/
@TableName("product_spu_statistics")
@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductSpuStatisticsDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* SPU
*
* ProductSpuDO id
*/
private Long spuId;
/**
*
*/
private LocalDateTime time;
/**
*
*/
private Integer browseCount;
/**
*
*/
private Integer favoriteCount;
/**
*
*
* createTime
*
*/
private Integer addCartCount;
/**
*
*/
private Integer createOrderCount;
/**
*
*/
private Integer payOrderCount;
/**
*
*/
private Integer payPrice;
}

View File

@ -1,70 +0,0 @@
package cn.iocoder.yudao.module.statistics.dal.mysql.product;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
/**
* DO
*
*
*
* {@link ProductSpuStatisticsDO}
*
* @author
*/
@TableName("product_spu_statistics")
@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductStatisticsDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
*
*/
private LocalDateTime time;
/**
*
*/
private Integer browseCount;
/**
*
*/
private Integer favoriteCount;
/**
*
*
* createTime
*
*/
private Integer addCartCount;
/**
*
*/
private Integer createOrderCount;
/**
*
*/
private Integer payOrderCount;
/**
*
*/
private Integer payPrice;
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.system.enums.dept;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*/
@Getter
@AllArgsConstructor
public enum DeptIdEnum {
/**
*
*/
ROOT(0L);
private final Long id;
}

View File

@ -1,47 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.auth.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
@Schema(description = "管理后台 - 社交绑定登录 Request VO使用 code 授权码 + 账号密码")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthSocialBindLoginReqVO {
@Schema(description = "社交平台的类型,参见 UserSocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@InEnum(SocialTypeEnum.class)
@NotNull(message = "社交平台的类型不能为空")
private Integer type;
@Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "授权码不能为空")
private String code;
@Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62")
@NotEmpty(message = "state 不能为空")
private String state;
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
@NotEmpty(message = "登录账号不能为空")
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username;
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
@NotEmpty(message = "密码不能为空")
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password;
}

View File

@ -1,27 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.health;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.security.PermitAll;
/**
* @description:
* @author: jhaol
*/
@Tag(name = "system 模块 - 健康检查")
@RestController
@RequestMapping("/system/health")
@Validated
public class HealthController {
@GetMapping()
@Operation(summary = "健康检查")
@PermitAll
public Integer health() {
return 0;
}
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.system.convert.ip;
import cn.iocoder.yudao.framework.ip.core.Area;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface AreaConvert {
AreaConvert INSTANCE = Mappers.getMapper(AreaConvert.class);
List<AreaNodeRespVO> convertList(List<Area> list);
List<AppAreaNodeRespVO> convertList3(List<Area> list);
}