Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/mall_product
commit
1b192b5032
@ -0,0 +1,102 @@
|
||||
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.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
||||
|
||||
@Tag(name = "管理后台 - 用户收件地址")
|
||||
@RestController
|
||||
@RequestMapping("/member/address")
|
||||
@Validated
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
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 {
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户收件地址 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AddressRespVO extends AddressBaseVO {
|
||||
|
||||
@Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7380")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
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;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue