mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
code review:移除收件地址多余的方法
This commit is contained in:
parent
1b192b5032
commit
583d34a801
@ -1,32 +1,24 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address;
|
||||
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
|
||||
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.member.controller.admin.address.vo.*;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
|
||||
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 用户收件地址")
|
||||
@RestController
|
||||
@ -37,66 +29,13 @@ public class AddressController {
|
||||
@Resource
|
||||
private AddressService addressService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户收件地址")
|
||||
@PreAuthorize("@ss.hasPermission('member:address:create')")
|
||||
public CommonResult<Long> createAddress(@Valid @RequestBody AddressCreateReqVO createReqVO) {
|
||||
return success(addressService.createAddress(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户收件地址")
|
||||
@PreAuthorize("@ss.hasPermission('member:address:update')")
|
||||
public CommonResult<Boolean> updateAddress(@Valid @RequestBody AddressUpdateReqVO updateReqVO) {
|
||||
addressService.updateAddress(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户收件地址")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:address:delete')")
|
||||
public CommonResult<Boolean> deleteAddress(@RequestParam("id") Long id) {
|
||||
addressService.deleteAddress(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户收件地址")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:address:query')")
|
||||
public CommonResult<AddressRespVO> getAddress(@RequestParam("id") Long id) {
|
||||
MemberAddressDO address = addressService.getAddress(id);
|
||||
return success(AddressConvert.INSTANCE.convert2(address));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得用户收件地址列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('member:address:query')")
|
||||
public CommonResult<List<AddressRespVO>> getAddressList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<MemberAddressDO> list = addressService.getAddressList(ids);
|
||||
@Parameter(name = "userId", description = "用户编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:user:query')")
|
||||
public CommonResult<List<AddressRespVO>> getAddressList(@RequestParam("userId") Long userId) {
|
||||
List<MemberAddressDO> list = addressService.getAddressList(userId);
|
||||
return success(AddressConvert.INSTANCE.convertList2(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户收件地址分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:address:query')")
|
||||
public CommonResult<PageResult<AddressRespVO>> getAddressPage(@Valid AddressPageReqVO pageVO) {
|
||||
PageResult<MemberAddressDO> pageResult = addressService.getAddressPage(pageVO);
|
||||
return success(AddressConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出用户收件地址 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('member:address:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportAddressExcel(@Valid AddressExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<MemberAddressDO> list = addressService.getAddressList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<AddressExcelVO> datas = AddressConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "用户收件地址.xls", "数据", AddressExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.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 AddressCreateReqVO extends AddressBaseVO {
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.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 AddressExcelVO {
|
||||
|
||||
@ExcelProperty("收件地址编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("收件人名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("手机号")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("地区编码")
|
||||
private Long areaId;
|
||||
|
||||
@ExcelProperty("收件详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@ExcelProperty("是否默认")
|
||||
private Boolean defaultStatus;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 用户收件地址 Excel 导出 Request VO,参数和 AddressPageReqVO 是一致的")
|
||||
@Data
|
||||
public class AddressExportReqVO {
|
||||
|
||||
@Schema(description = "用户编号", example = "20369")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "收件人名称", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地区编码", example = "15716")
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "收件详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "是否默认", example = "2")
|
||||
private Boolean defaultStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.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 AddressPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户编号", example = "20369")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "收件人名称", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地区编码", example = "15716")
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "收件详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "是否默认", example = "2")
|
||||
private Boolean defaultStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.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 AddressUpdateReqVO extends AddressBaseVO {
|
||||
|
||||
@Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7380")
|
||||
@NotNull(message = "收件地址编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -40,10 +40,10 @@ public class MemberUserBaseVO {
|
||||
@Schema(description = "用户性别", example = "1")
|
||||
private Byte sex;
|
||||
|
||||
@Schema(description = "所在地", example = "4371")
|
||||
@Schema(description = "所在地编号", example = "4371")
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "所在地可视化显示", example = "4371")
|
||||
@Schema(description = "所在地全程", example = "上海上海市普陀区")
|
||||
private String areaName;
|
||||
|
||||
@Schema(description = "出生日期", example = "2023-03-12")
|
||||
|
@ -1,12 +1,8 @@
|
||||
package cn.iocoder.yudao.module.member.convert.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressExcelVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
|
||||
@ -44,15 +40,6 @@ public interface AddressConvert {
|
||||
return AreaUtils.format(areaId);
|
||||
}
|
||||
|
||||
MemberAddressDO convert(AddressCreateReqVO bean);
|
||||
|
||||
MemberAddressDO convert(AddressUpdateReqVO bean);
|
||||
|
||||
AddressRespVO convert2(MemberAddressDO bean);
|
||||
|
||||
List<AddressRespVO> convertList2(List<MemberAddressDO> list);
|
||||
|
||||
PageResult<AddressRespVO> convertPage(PageResult<MemberAddressDO> page);
|
||||
|
||||
List<AddressExcelVO> convertList02(List<MemberAddressDO> list);
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package cn.iocoder.yudao.module.member.convert.user;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserInfoRespVO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -37,7 +35,7 @@ public interface MemberUserConvert {
|
||||
|
||||
PageResult<MemberUserRespVO> convertPage(PageResult<MemberUserDO> page);
|
||||
|
||||
@Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName")
|
||||
@Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName")
|
||||
MemberUserRespVO convert03(MemberUserDO bean);
|
||||
|
||||
default PageResult<MemberUserRespVO> convertPage(PageResult<MemberUserDO> pageResult,
|
||||
@ -50,11 +48,11 @@ public interface MemberUserConvert {
|
||||
Map<Long, String> levelMap = convertMap(levels, MemberLevelDO::getId, MemberLevelDO::getName);
|
||||
Map<Long, String> groupMap = convertMap(groups, MemberGroupDO::getId, MemberGroupDO::getName);
|
||||
// 填充关联数据
|
||||
for (MemberUserRespVO vo : result.getList()) {
|
||||
vo.setTagNames(convertList(vo.getTagIds(), tagMap::get));
|
||||
vo.setLevelName(MapUtil.getStr(levelMap, vo.getLevelId(), StrUtil.EMPTY));
|
||||
vo.setGroupName(MapUtil.getStr(groupMap, vo.getGroupId(), StrUtil.EMPTY));
|
||||
}
|
||||
result.getList().forEach(user -> {
|
||||
user.setTagNames(convertList(user.getTagIds(), tagMap::get));
|
||||
user.setLevelName(levelMap.get(user.getLevelId()));
|
||||
user.setGroupName(groupMap.get(user.getGroupId()));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressExportReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -21,28 +18,5 @@ public interface AddressMapper extends BaseMapperX<MemberAddressDO> {
|
||||
return selectList(new LambdaQueryWrapperX<MemberAddressDO>().eq(MemberAddressDO::getUserId, userId)
|
||||
.eqIfPresent(MemberAddressDO::getDefaultStatus, defaulted));
|
||||
}
|
||||
default PageResult<MemberAddressDO> selectPage(AddressPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MemberAddressDO>()
|
||||
.eqIfPresent(MemberAddressDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(MemberAddressDO::getName, reqVO.getName())
|
||||
.eqIfPresent(MemberAddressDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(MemberAddressDO::getAreaId, reqVO.getAreaId())
|
||||
.eqIfPresent(MemberAddressDO::getDetailAddress, reqVO.getDetailAddress())
|
||||
.eqIfPresent(MemberAddressDO::getDefaultStatus, reqVO.getDefaultStatus())
|
||||
.betweenIfPresent(MemberAddressDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(MemberAddressDO::getId));
|
||||
}
|
||||
|
||||
default List<MemberAddressDO> selectList(AddressExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<MemberAddressDO>()
|
||||
.eqIfPresent(MemberAddressDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(MemberAddressDO::getName, reqVO.getName())
|
||||
.eqIfPresent(MemberAddressDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(MemberAddressDO::getAreaId, reqVO.getAreaId())
|
||||
.eqIfPresent(MemberAddressDO::getDetailAddress, reqVO.getDetailAddress())
|
||||
.eqIfPresent(MemberAddressDO::getDefaultStatus, reqVO.getDefaultStatus())
|
||||
.betweenIfPresent(MemberAddressDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(MemberAddressDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,10 @@
|
||||
package cn.iocoder.yudao.module.member.service.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressExportReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -70,57 +64,4 @@ public interface AddressService {
|
||||
*/
|
||||
MemberAddressDO getDefaultUserAddress(Long userId);
|
||||
|
||||
/**
|
||||
* 创建用户收件地址
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createAddress(@Valid AddressCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户收件地址
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateAddress(@Valid AddressUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户收件地址
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteAddress(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 用户收件地址
|
||||
*/
|
||||
MemberAddressDO getAddress(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 用户收件地址列表
|
||||
*/
|
||||
List<MemberAddressDO> getAddressList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 用户收件地址分页
|
||||
*/
|
||||
PageResult<MemberAddressDO> getAddressPage(AddressPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得用户收件地址列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 用户收件地址列表
|
||||
*/
|
||||
List<MemberAddressDO> getAddressList(AddressExportReqVO exportReqVO);
|
||||
}
|
||||
|
@ -1,11 +1,6 @@
|
||||
package cn.iocoder.yudao.module.member.service.address;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressExportReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
@ -16,7 +11,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -100,56 +94,4 @@ public class AddressServiceImpl implements AddressService {
|
||||
return CollUtil.getFirst(addresses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createAddress(AddressCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
MemberAddressDO address = AddressConvert.INSTANCE.convert(createReqVO);
|
||||
addressMapper.insert(address);
|
||||
// 返回
|
||||
return address.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAddress(AddressUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateAddressExists(updateReqVO.getId());
|
||||
// 更新
|
||||
MemberAddressDO updateObj = AddressConvert.INSTANCE.convert(updateReqVO);
|
||||
addressMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAddress(Long id) {
|
||||
// 校验存在
|
||||
validateAddressExists(id);
|
||||
// 删除
|
||||
addressMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateAddressExists(Long id) {
|
||||
if (addressMapper.selectById(id) == null) {
|
||||
throw exception(ADDRESS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberAddressDO getAddress(Long id) {
|
||||
return addressMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberAddressDO> getAddressList(Collection<Long> ids) {
|
||||
return addressMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MemberAddressDO> getAddressPage(AddressPageReqVO pageReqVO) {
|
||||
return addressMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberAddressDO> getAddressList(AddressExportReqVO exportReqVO) {
|
||||
return addressMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user