From 583d34a801e111b185f61f88a70a7ddb0ecf90d9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 26 Aug 2023 01:51:47 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=94=B6=E4=BB=B6=E5=9C=B0=E5=9D=80=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/address/AddressController.java | 101 ++++-------------- .../admin/address/vo/AddressCreateReqVO.java | 14 --- .../admin/address/vo/AddressExcelVO.java | 40 ------- .../admin/address/vo/AddressExportReqVO.java | 38 ------- .../admin/address/vo/AddressPageReqVO.java | 40 ------- .../admin/address/vo/AddressUpdateReqVO.java | 18 ---- .../admin/user/vo/MemberUserBaseVO.java | 4 +- .../convert/address/AddressConvert.java | 13 --- .../convert/user/MemberUserConvert.java | 16 ++- .../dal/mysql/address/AddressMapper.java | 26 ----- .../service/address/AddressService.java | 59 ---------- .../service/address/AddressServiceImpl.java | 58 ---------- 12 files changed, 29 insertions(+), 398 deletions(-) delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressCreateReqVO.java delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExcelVO.java delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExportReqVO.java delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressPageReqVO.java delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressUpdateReqVO.java diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java index 3e6919e83..0363634c5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java @@ -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 createAddress(@Valid @RequestBody AddressCreateReqVO createReqVO) { - return success(addressService.createAddress(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户收件地址") - @PreAuthorize("@ss.hasPermission('member:address:update')") - public CommonResult 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 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 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> getAddressList(@RequestParam("ids") Collection ids) { - List list = addressService.getAddressList(ids); + @Parameter(name = "userId", description = "用户编号", required = true) + @PreAuthorize("@ss.hasPermission('member:user:query')") + public CommonResult> getAddressList(@RequestParam("userId") Long userId) { + List list = addressService.getAddressList(userId); return success(AddressConvert.INSTANCE.convertList2(list)); } - @GetMapping("/page") - @Operation(summary = "获得用户收件地址分页") - @PreAuthorize("@ss.hasPermission('member:address:query')") - public CommonResult> getAddressPage(@Valid AddressPageReqVO pageVO) { - PageResult 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 list = addressService.getAddressList(exportReqVO); - // 导出 Excel - List datas = AddressConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "用户收件地址.xls", "数据", AddressExcelVO.class, datas); - } - } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressCreateReqVO.java deleted file mode 100644 index ac0833ba7..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressCreateReqVO.java +++ /dev/null @@ -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 { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExcelVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExcelVO.java deleted file mode 100644 index 8a0543247..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExcelVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExportReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExportReqVO.java deleted file mode 100644 index 214bf952b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExportReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressPageReqVO.java deleted file mode 100644 index 32b059448..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressPageReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressUpdateReqVO.java deleted file mode 100644 index 4e91579e4..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressUpdateReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java index ba5d961bc..e20963e5e 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java @@ -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") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java index e6f56a022..fd5198e14 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java @@ -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 convertList2(List list); - PageResult convertPage(PageResult page); - - List convertList02(List list); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java index d07c3ddc5..5b963be69 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java @@ -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 convertPage(PageResult page); - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") + @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") MemberUserRespVO convert03(MemberUserDO bean); default PageResult convertPage(PageResult pageResult, @@ -50,11 +48,11 @@ public interface MemberUserConvert { Map levelMap = convertMap(levels, MemberLevelDO::getId, MemberLevelDO::getName); Map 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; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java index 9beb025c0..db824f6f5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java @@ -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 { return selectList(new LambdaQueryWrapperX().eq(MemberAddressDO::getUserId, userId) .eqIfPresent(MemberAddressDO::getDefaultStatus, defaulted)); } - default PageResult selectPage(AddressPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .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 selectList(AddressExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .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)); - } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java index 260ab7987..099c49c42 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java @@ -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 getAddressList(Collection ids); - - /** - * 获得用户收件地址分页 - * - * @param pageReqVO 分页查询 - * @return 用户收件地址分页 - */ - PageResult getAddressPage(AddressPageReqVO pageReqVO); - - /** - * 获得用户收件地址列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 用户收件地址列表 - */ - List getAddressList(AddressExportReqVO exportReqVO); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java index 79f129b75..2689177ea 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java @@ -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 getAddressList(Collection ids) { - return addressMapper.selectBatchIds(ids); - } - - @Override - public PageResult getAddressPage(AddressPageReqVO pageReqVO) { - return addressMapper.selectPage(pageReqVO); - } - - @Override - public List getAddressList(AddressExportReqVO exportReqVO) { - return addressMapper.selectList(exportReqVO); - } - }