member:完善 cloud 下的 api 注解问题

This commit is contained in:
YunaiV
2023-10-22 16:35:29 +08:00
parent 08c5248757
commit 6a51097e1d
25 changed files with 358 additions and 324 deletions

View File

@@ -22,12 +22,26 @@
<artifactId>yudao-common</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<scope>provided</scope>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -1,29 +0,0 @@
package cn.iocoder.yudao.module.member.api.address;
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
/**
* 用户收件地址 API 接口
*
* @author 芋道源码
*/
public interface AddressApi {
/**
* 获得用户收件地址
*
* @param id 收件地址编号
* @param userId 用户编号
* @return 用户收件地址
*/
AddressRespDTO getAddress(Long id, Long userId);
/**
* 获得用户默认收件地址
*
* @param userId 用户编号
* @return 用户收件地址
*/
AddressRespDTO getDefaultAddress(Long userId);
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.member.api.address;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
import cn.iocoder.yudao.module.member.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 用户收件地址")
public interface MemberAddressApi {
String PREFIX = ApiConstants.PREFIX + "/address";
@GetMapping(PREFIX + "/get")
@Operation(summary = "获得用户收件地址")
@Parameters({
@Parameter(name = "id", description = "收件地址编号", required = true, example = "1024"),
@Parameter(name = "userId", description = "用户编号", required = true, example = "2048"),
})
CommonResult<MemberAddressRespDTO> getAddress(@RequestParam("id") Long id,
@RequestParam("userId") Long userId);
/**
* 获得用户默认收件地址
*
* @param userId 用户编号
* @return 用户收件地址
*/
@GetMapping(PREFIX + "/get-default")
@Operation(summary = "获得用户默认收件地址")
@Parameter(name = "userId", description = "用户编号", required = true, example = "2048")
CommonResult<MemberAddressRespDTO> getDefaultAddress(@RequestParam("userId") Long userId);
}

View File

@@ -1,42 +0,0 @@
package cn.iocoder.yudao.module.member.api.address.dto;
import lombok.Data;
/**
* 用户收件地址 Response DTO
*
* @author 芋道源码
*/
@Data
public class AddressRespDTO {
/**
* 编号
*/
private Long id;
/**
* 用户编号
*/
private Long userId;
/**
* 收件人名称
*/
private String name;
/**
* 手机号
*/
private String mobile;
/**
* 地区编号
*/
private Integer areaId;
/**
* 收件详细地址
*/
private String detailAddress;
/**
* 是否默认
*/
private Boolean defaultStatus;
}

View File

@@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.member.api.address.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "RPC 服务 - 用户收件地址 Response DTO")
@Data
public class MemberAddressRespDTO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
private Long userId;
@Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
private String name;
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300")
private String mobile;
@Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2666")
private Integer areaId;
@Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码 88 小区 106 号")
private String detailAddress;
@Schema(description = "是否默认", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean defaultStatus;
}

View File

@@ -1,18 +1,21 @@
package cn.iocoder.yudao.module.member.api.config;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO;
import cn.iocoder.yudao.module.member.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
/**
* 用户配置 API 接口
*
* @author owen
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 用户配置")
public interface MemberConfigApi {
/**
* 获得积分配置
*
* @return 积分配置
*/
MemberConfigRespDTO getConfig();
String PREFIX = ApiConstants.PREFIX + "/config";
@GetMapping(PREFIX + "/get")
@Operation(summary = "获得用户配置")
CommonResult<MemberConfigRespDTO> getConfig();
}

View File

@@ -1,32 +1,22 @@
package cn.iocoder.yudao.module.member.api.config.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 用户信息 Response DTO
*
* @author 芋道源码
*/
@Schema(description = "RPC 服务 - 用户信息 Response DTO")
@Data
public class MemberConfigRespDTO {
/**
* 积分抵扣开关
*/
@Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean pointTradeDeductEnable;
/**
* 积分抵扣,单位:分
* <p>
* 1 积分抵扣多少分
*/
private Integer pointTradeDeductUnitPrice;
/**
* 积分抵扣最大值
*/
@Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer pointTradeDeductUnitPrice; // 1 积分抵扣多少分
@Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
private Integer pointTradeDeductMaxPrice;
/**
* 1 元赠送多少分
*/
@Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer pointTradeGivePoint;
}

View File

@@ -1,41 +1,52 @@
package cn.iocoder.yudao.module.member.api.level;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
import cn.iocoder.yudao.module.member.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 会员等级 API 接口
*
* @author owen
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 会员等级")
public interface MemberLevelApi {
/**
* 获得会员等级
*
* @param id 会员等级编号
* @return 会员等级
*/
MemberLevelRespDTO getMemberLevel(Long id);
String PREFIX = ApiConstants.PREFIX + "/address";
/**
* 增加会员经验
*
* @param userId 会员ID
* @param experience 经验
* @param bizType 业务类型 {@link MemberExperienceBizTypeEnum}
* @param bizId 业务编号
*/
void addExperience(Long userId, Integer experience, Integer bizType, String bizId);
@GetMapping(PREFIX + "/get")
@Operation(summary = "获得会员等级")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
CommonResult<MemberLevelRespDTO> getMemberLevel(@RequestParam("id") Long id);
/**
* 扣减会员经验
*
* @param userId 会员ID
* @param experience 经验
* @param bizType 业务类型 {@link MemberExperienceBizTypeEnum}
* @param bizId 业务编号
*/
void reduceExperience(Long userId, Integer experience, Integer bizType, String bizId);
@PostMapping(PREFIX + "/add")
@Operation(summary = "增加会员经验")
@Parameters({
@Parameter(name = "userId", description = "会员编号", required = true, example = "1024"),
@Parameter(name = "experience", description = "经验值", required = true, example = "100"),
@Parameter(name = "bizType", description = "业务类型", required = true, example = "1"),
@Parameter(name = "bizId", description = "业务编号", required = true, example = "1")
})
CommonResult<Boolean> addExperience(@RequestParam("userId") Long userId,
@RequestParam("experience") Integer experience,
@RequestParam("bizType") Integer bizType,
@RequestParam("bizId") String bizId);
@PostMapping(PREFIX + "/reduce")
@Operation(summary = "扣减会员经验")
@Parameters({
@Parameter(name = "userId", description = "会员编号", required = true, example = "1024"),
@Parameter(name = "experience", description = "经验值", required = true, example = "100"),
@Parameter(name = "bizType", description = "业务类型", required = true, example = "1"),
@Parameter(name = "bizId", description = "业务编号", required = true, example = "1")
})
CommonResult<Boolean> reduceExperience(@RequestParam("userId") Long userId,
@RequestParam("experience") Integer experience,
@RequestParam("bizType") Integer bizType,
@RequestParam("bizId") String bizId);
}

View File

@@ -1,41 +1,28 @@
package cn.iocoder.yudao.module.member.api.level.dto;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 会员等级 Resp DTO
*
* @author 芋道源码
*/
@Schema(description = "RPC 服务 - 会员等级 Response DTO")
@Data
public class MemberLevelRespDTO {
/**
* 编号
*/
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
/**
* 等级名称
*/
@Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "普通会员")
private String name;
/**
* 等级
*/
@Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer level;
/**
* 升级经验
*/
@Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer experience;
/**
* 享受折扣
*/
@Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer discountPercent;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status; // 参见 CommonStatusEnum 枚举
}

View File

@@ -1,36 +1,47 @@
package cn.iocoder.yudao.module.member.api.point;
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.Min;
/**
* 用户积分的 API 接口
*
* @author owen
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 用户积分")
public interface MemberPointApi {
/**
* 增加用户积分
*
* @param userId 用户编号
* @param point 积分
* @param bizType 业务类型 {@link MemberPointBizTypeEnum}
* @param bizId 业务编号
*/
void addPoint(Long userId, @Min(value = 1L, message = "积分必须是正数") Integer point,
Integer bizType, String bizId);
String PREFIX = ApiConstants.PREFIX + "/point";
/**
* 减少用户积分
*
* @param userId 用户编号
* @param point 积分
* @param bizType 业务类型 {@link MemberPointBizTypeEnum}
* @param bizId 业务编号
*/
void reducePoint(Long userId, @Min(value = 1L, message = "积分必须是正数") Integer point,
Integer bizType, String bizId);
@PostMapping(PREFIX + "/add")
@Operation(summary = "增加用户积分")
@Parameters({
@Parameter(name = "userId", description = "会员编号", required = true, example = "1024"),
@Parameter(name = "point", description = "积分", required = true, example = "100"),
@Parameter(name = "bizType", description = "业务类型", required = true, example = "1"),
@Parameter(name = "bizId", description = "业务编号", required = true, example = "1")
})
CommonResult<Boolean> addPoint(@RequestParam("userId") Long userId,
@RequestParam("point") @Min(value = 1L, message = "积分必须是正数") Integer point,
@RequestParam("bizType") Integer bizType,
@RequestParam("bizId") String bizId);
@PostMapping(PREFIX + "/reducePoint")
@Operation(summary = "减少用户积分")
@Parameters({
@Parameter(name = "userId", description = "会员编号", required = true, example = "1024"),
@Parameter(name = "point", description = "积分", required = true, example = "100"),
@Parameter(name = "bizType", description = "业务类型", required = true, example = "1"),
@Parameter(name = "bizId", description = "业务编号", required = true, example = "1")
})
CommonResult<Boolean> reducePoint(@RequestParam("userId") Long userId,
@RequestParam("point") @Min(value = 1L, message = "积分必须是正数") Integer point,
@RequestParam("bizType") Integer bizType,
@RequestParam("bizId") String bizId);
}

View File

@@ -1,6 +1,14 @@
package cn.iocoder.yudao.module.member.api.user;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.member.enums.ApiConstants;
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.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
@@ -8,28 +16,21 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/**
* 会员用户的 API 接口
*
* @author 芋道源码
*/
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 会员用户的")
public interface MemberUserApi {
/**
* 获得会员用户信息
*
* @param id 用户编号
* @return 用户信息
*/
MemberUserRespDTO getUser(Long id);
String PREFIX = ApiConstants.PREFIX + "/user";
/**
* 获得会员用户信息们
*
* @param ids 用户编号的数组
* @return 用户信息们
*/
List<MemberUserRespDTO> getUserList(Collection<Long> ids);
@GetMapping(PREFIX + "/get")
@Operation(summary = "获得会员用户信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
CommonResult<MemberUserRespDTO> getUser(@RequestParam("id") Long id);
@GetMapping(PREFIX + "/list")
@Operation(summary = "获得会员用户信息们")
@Parameter(name = "ids", description = "用户编号的数组", example = "1,2", required = true)
CommonResult<List<MemberUserRespDTO>> getUserList(@RequestParam("ids") Collection<Long> ids);
/**
* 获得会员用户 Map
@@ -38,22 +39,17 @@ public interface MemberUserApi {
* @return 会员用户 Map
*/
default Map<Long, MemberUserRespDTO> getUserMap(Collection<Long> ids) {
return convertMap(getUserList(ids), MemberUserRespDTO::getId);
return convertMap(getUserList(ids).getCheckedData(), MemberUserRespDTO::getId);
}
/**
* 基于用户昵称,模糊匹配用户列表
*
* @param nickname 用户昵称,模糊匹配
* @return 用户信息的列表
*/
List<MemberUserRespDTO> getUserListByNickname(String nickname);
@GetMapping(PREFIX + "/list-by-nickname")
@Operation(summary = "基于用户昵称,模糊匹配用户列表")
@Parameter(name = "nickname", description = "用户昵称,模糊匹配", required = true, example = "土豆")
CommonResult<List<MemberUserRespDTO>> getUserListByNickname(@RequestParam("nickname") String nickname);
@GetMapping(PREFIX + "/get-by-mobile")
@Operation(summary = "基于手机号,精准匹配用户")
@Parameter(name = "mobile", description = "基于手机号,精准匹配用户", required = true, example = "1560")
CommonResult<MemberUserRespDTO> getUserByMobile(@RequestParam("mobile") String mobile);
/**
* 基于手机号,精准匹配用户
*
* @param mobile 手机号
* @return 用户信息
*/
MemberUserRespDTO getUserByMobile(String mobile);
}

View File

@@ -1,55 +1,38 @@
package cn.iocoder.yudao.module.member.api.user.dto;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 用户信息 Response DTO
*
* @author 芋道源码
*/
@Schema(description = "RPC 服务 - 用户信息 Response DTO")
@Data
public class MemberUserRespDTO {
/**
* 用户ID
*/
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
/**
* 用户昵称
*/
@Schema(description = "昵称", example = "小王同学")
private String nickname;
/**
* 帐号状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 用户头像
*/
@Schema(description = "帐号状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status; // 参见 CommonStatusEnum 枚举
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.jpg")
private String avatar;
/**
* 手机
*/
@Schema(description = "手机号", example = "15601691300")
private String mobile;
/**
* 创建时间(注册时间)
*/
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
// ========== 其它信息 ==========
/**
* 会员级别编号
*/
@Schema(description = "会员级别编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long levelId;
/**
* 积分
*/
@Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "886")
private Integer point;
}

View File

@@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.member.enums;
import cn.iocoder.yudao.framework.common.enums.RpcConstants;
/**
* API 相关的枚举
*
* @author 芋道源码
*/
public class ApiConstants {
/**
* 服务名
*
* 注意,需要保证和 spring.application.name 保持一致
*/
public static final String NAME = "member-server";
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/member";
public static final String VERSION = "1.0.0";
}