Merge remote-tracking branch 'origin/feature/1.8.0-uniapp' into feature/1.8.0-uniapp
commit
7c6e0b09ce
@ -0,0 +1,54 @@
|
||||
### 请求 /create 接口 => 成功
|
||||
POST {{appApi}}//member/address/create
|
||||
Content-Type: application/json
|
||||
tenant-id: {{appTenentId}}
|
||||
Authorization: Bearer 2510e2e4287346eb8e36353a55e27fd6
|
||||
|
||||
{
|
||||
"userId": "245",
|
||||
"name": "yunai",
|
||||
"mobile": "15601691300",
|
||||
"areaCode": "610632",
|
||||
"detailAddress": "芋道源码 233 号 666 室",
|
||||
"type": "1"
|
||||
}
|
||||
|
||||
### 请求 /update 接口 => 成功
|
||||
PUT {{appApi}}//member/address/update
|
||||
Content-Type: application/json
|
||||
tenant-id: {{appTenentId}}
|
||||
Authorization: Bearer 2510e2e4287346eb8e36353a55e27fd6
|
||||
|
||||
{
|
||||
"id": "1",
|
||||
"userId": "245",
|
||||
"name": "yunai888",
|
||||
"mobile": "15601691300",
|
||||
"areaCode": "610632",
|
||||
"detailAddress": "芋道源码 233 号 666 室",
|
||||
"type": "1"
|
||||
}
|
||||
|
||||
### 请求 /delete 接口 => 成功
|
||||
DELETE {{appApi}}//member/address/delete?id=2
|
||||
Content-Type: application/json
|
||||
tenant-id: {{appTenentId}}
|
||||
Authorization: Bearer fa4848b001de4eae9faf516c0c8520f8
|
||||
|
||||
### 请求 /get 接口 => 成功
|
||||
GET {{appApi}}//member/address/get?id=1
|
||||
Content-Type: application/json
|
||||
tenant-id: {{appTenentId}}
|
||||
Authorization: Bearer fa4848b001de4eae9faf516c0c8520f8
|
||||
|
||||
### 请求 /get-default 接口 => 成功
|
||||
GET {{appApi}}//member/address/get-default
|
||||
Content-Type: application/json
|
||||
tenant-id: {{appTenentId}}
|
||||
Authorization: Bearer fa4848b001de4eae9faf516c0c8520f8
|
||||
|
||||
### 请求 /list 接口 => 成功
|
||||
GET {{appApi}}//member/address/list
|
||||
Content-Type: application/json
|
||||
tenant-id: {{appTenentId}}
|
||||
Authorization: Bearer fa4848b001de4eae9faf516c0c8520f8
|
||||
@ -0,0 +1,78 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.AddressDO;
|
||||
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Api(tags = "用户 APP - 用户收件地址")
|
||||
@RestController
|
||||
@RequestMapping("/member/address")
|
||||
@Validated
|
||||
public class AppAddressController {
|
||||
|
||||
@Resource
|
||||
private AddressService addressService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建用户收件地址")
|
||||
public CommonResult<Long> createAddress(@Valid @RequestBody AppAddressCreateReqVO createReqVO) {
|
||||
return success(addressService.createAddress(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新用户收件地址")
|
||||
public CommonResult<Boolean> updateAddress(@Valid @RequestBody AppAddressUpdateReqVO updateReqVO) {
|
||||
addressService.updateAddress(getLoginUserId(), updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除用户收件地址")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
public CommonResult<Boolean> deleteAddress(@RequestParam("id") Long id) {
|
||||
addressService.deleteAddress(getLoginUserId(), id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得用户收件地址")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
public CommonResult<AppAddressRespVO> getAddress(@RequestParam("id") Long id) {
|
||||
AddressDO address = addressService.getAddress(getLoginUserId(), id);
|
||||
return success(AddressConvert.INSTANCE.convert(address));
|
||||
}
|
||||
|
||||
@GetMapping("/get-default")
|
||||
@ApiOperation("获得默认的用户收件地址")
|
||||
public CommonResult<AppAddressRespVO> getDefaultUserAddress() {
|
||||
AddressDO address = addressService.getDefaultUserAddress(getLoginUserId());
|
||||
return success(AddressConvert.INSTANCE.convert(address));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得用户收件地址列表")
|
||||
public CommonResult<List<AppAddressRespVO>> getAddressList() {
|
||||
List<AddressDO> list = addressService.getAddressList(getLoginUserId());
|
||||
return success(AddressConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.address;
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.address.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("用户 APP - 用户收件地址创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppAddressCreateReqVO extends AppAddressBaseVO {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.address.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("用户 APP - 用户收件地址 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppAddressRespVO extends AppAddressBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.address.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("用户 APP - 用户收件地址更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppAddressUpdateReqVO extends AppAddressBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.member.convert.address;
|
||||
|
||||
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.member.controller.app.address.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.AddressDO;
|
||||
|
||||
/**
|
||||
* 用户收件地址 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AddressConvert {
|
||||
|
||||
AddressConvert INSTANCE = Mappers.getMapper(AddressConvert.class);
|
||||
|
||||
AddressDO convert(AppAddressCreateReqVO bean);
|
||||
|
||||
AddressDO convert(AppAddressUpdateReqVO bean);
|
||||
|
||||
AppAddressRespVO convert(AddressDO bean);
|
||||
|
||||
List<AppAddressRespVO> convertList(List<AddressDO> list);
|
||||
|
||||
PageResult<AppAddressRespVO> convertPage(PageResult<AddressDO> page);
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.member.enums.AddressTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 用户收件地址 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("member_address")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AddressDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 地区编码
|
||||
*/
|
||||
private Integer areaCode;
|
||||
/**
|
||||
* 收件详细地址
|
||||
*/
|
||||
private String detailAddress;
|
||||
/**
|
||||
* 地址类型
|
||||
*
|
||||
* 枚举 {@link AddressTypeEnum}
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.address;
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.address;
|
||||
|
||||
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.member.dal.dataobject.address.AddressDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.*;
|
||||
|
||||
/**
|
||||
* 用户收件地址 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AddressMapper extends BaseMapperX<AddressDO> {
|
||||
|
||||
default PageResult<AddressDO> selectPage(AppAddressPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AddressDO>()
|
||||
.eqIfPresent(AddressDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(AddressDO::getName, reqVO.getName())
|
||||
.eqIfPresent(AddressDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(AddressDO::getAreaCode, reqVO.getAreaCode())
|
||||
.eqIfPresent(AddressDO::getDetailAddress, reqVO.getDetailAddress())
|
||||
.eqIfPresent(AddressDO::getType, reqVO.getType())
|
||||
.betweenIfPresent(AddressDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(AddressDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.member.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 用户收件地址的类型枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AddressTypeEnum {
|
||||
|
||||
DEFAULT(1, "默认收件地址"),
|
||||
NORMAL(2, "普通收件地址"), // 即非默认收件地址
|
||||
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.module.member.service.address;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.AddressDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 用户收件地址 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface AddressService {
|
||||
|
||||
/**
|
||||
* 创建用户收件地址
|
||||
*
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createAddress(Long userId, @Valid AppAddressCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户收件地址
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateAddress(Long userId, @Valid AppAddressUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户收件地址
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteAddress(Long userId, Long id);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 用户收件地址
|
||||
*/
|
||||
AddressDO getAddress(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址列表
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 用户收件地址列表
|
||||
*/
|
||||
List<AddressDO> getAddressList(Long userId);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param id 编号
|
||||
* @return 用户收件地址
|
||||
*/
|
||||
AddressDO getAddress(Long userId, Long id);
|
||||
|
||||
AddressDO getDefaultUserAddress(Long userId);
|
||||
}
|
||||
@ -0,0 +1,197 @@
|
||||
package cn.iocoder.yudao.module.member.service.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressExportReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.AddressDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.address.AddressMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
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.member.enums.ErrorCodeConstants.ADDRESS_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link AddressServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(AddressServiceImpl.class)
|
||||
public class AddressServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private AddressServiceImpl addressService;
|
||||
|
||||
@Resource
|
||||
private AddressMapper addressMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateAddress_success() {
|
||||
// 准备参数
|
||||
AppAddressCreateReqVO reqVO = randomPojo(AppAddressCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long addressId = addressService.createAddress(getLoginUserId(), reqVO);
|
||||
// 断言
|
||||
assertNotNull(addressId);
|
||||
// 校验记录的属性是否正确
|
||||
AddressDO address = addressMapper.selectById(addressId);
|
||||
assertPojoEquals(reqVO, address);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAddress_success() {
|
||||
// mock 数据
|
||||
AddressDO dbAddress = randomPojo(AddressDO.class);
|
||||
addressMapper.insert(dbAddress);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
AppAddressUpdateReqVO reqVO = randomPojo(AppAddressUpdateReqVO.class, o -> {
|
||||
o.setId(dbAddress.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
addressService.updateAddress(getLoginUserId(), reqVO);
|
||||
// 校验是否更新正确
|
||||
AddressDO address = addressMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, address);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAddress_notExists() {
|
||||
// 准备参数
|
||||
AppAddressUpdateReqVO reqVO = randomPojo(AppAddressUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> addressService.updateAddress(getLoginUserId(), reqVO), ADDRESS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAddress_success() {
|
||||
// mock 数据
|
||||
AddressDO dbAddress = randomPojo(AddressDO.class);
|
||||
addressMapper.insert(dbAddress);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbAddress.getId();
|
||||
|
||||
// 调用
|
||||
addressService.deleteAddress(getLoginUserId(), id);
|
||||
// 校验数据不存在了
|
||||
assertNull(addressMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAddress_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> addressService.deleteAddress(getLoginUserId(), id), ADDRESS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void ins() {
|
||||
// mock 数据
|
||||
AddressDO dbAddress = randomPojo(AddressDO.class, o -> { // 等会查询到
|
||||
o.setUserId(null);
|
||||
o.setName(null);
|
||||
o.setMobile(null);
|
||||
o.setAreaCode(null);
|
||||
o.setDetailAddress(null);
|
||||
o.setType(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
addressMapper.insert(dbAddress);
|
||||
// 测试 userId 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setUserId(null)));
|
||||
// 测试 name 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setName(null)));
|
||||
// 测试 mobile 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setMobile(null)));
|
||||
// 测试 areaCode 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setAreaCode(null)));
|
||||
// 测试 detailAddress 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setDetailAddress(null)));
|
||||
// 测试 type 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setType(null)));
|
||||
// 测试 createTime 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
AppAddressPageReqVO reqVO = new AppAddressPageReqVO();
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setMobile(null);
|
||||
reqVO.setAreaCode(null);
|
||||
reqVO.setDetailAddress(null);
|
||||
reqVO.setType(null);
|
||||
reqVO.setBeginCreateTime(null);
|
||||
reqVO.setEndCreateTime(null);
|
||||
|
||||
// 调用
|
||||
PageResult<AddressDO> pageResult = addressService.getAddressPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbAddress, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetAddressList() {
|
||||
// mock 数据
|
||||
AddressDO dbAddress = randomPojo(AddressDO.class, o -> { // 等会查询到
|
||||
o.setUserId(null);
|
||||
o.setName(null);
|
||||
o.setMobile(null);
|
||||
o.setAreaCode(null);
|
||||
o.setDetailAddress(null);
|
||||
o.setType(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
addressMapper.insert(dbAddress);
|
||||
// 测试 userId 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setUserId(null)));
|
||||
// 测试 name 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setName(null)));
|
||||
// 测试 mobile 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setMobile(null)));
|
||||
// 测试 areaCode 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setAreaCode(null)));
|
||||
// 测试 detailAddress 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setDetailAddress(null)));
|
||||
// 测试 type 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setType(null)));
|
||||
// 测试 createTime 不匹配
|
||||
addressMapper.insert(cloneIgnoreId(dbAddress, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
AppAddressExportReqVO reqVO = new AppAddressExportReqVO();
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setMobile(null);
|
||||
reqVO.setAreaCode(null);
|
||||
reqVO.setDetailAddress(null);
|
||||
reqVO.setType(null);
|
||||
reqVO.setBeginCreateTime(null);
|
||||
reqVO.setEndCreateTime(null);
|
||||
|
||||
// 调用
|
||||
List<AddressDO> list = addressService.getAddressList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbAddress, list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1 +1,2 @@
|
||||
DELETE FROM "member_user";
|
||||
DELETE FROM "member_address";
|
||||
|
||||
Loading…
Reference in New Issue