fix: API文档 @Parameter 不显示问题修复

This commit is contained in:
Ray.Hao 2024-05-14 20:53:57 +08:00
parent 9035949bd7
commit acbfc26945
23 changed files with 68 additions and 167 deletions

View File

@ -50,7 +50,7 @@ public class OrderController {
@Operation(summary = "订单详情")
@GetMapping("/{orderId}")
public Result getOrderDetail(
@Parameter(name ="订单ID") @PathVariable Long orderId
@Parameter(description ="订单ID") @PathVariable Long orderId
) {
OrderDTO orderDTO = new OrderDTO();
// 订单

View File

@ -40,7 +40,7 @@ public class AppOrderController {
@Operation(summary = "订单确认", description = "进入订单确认页面有两个入口1立即购买2购物车结算")
@PostMapping("/confirm")
public Result<OrderConfirmVO> confirmOrder(
@Parameter(name ="立即购买必填,购物车结算不填") @RequestParam(required = false) Long skuId
@Parameter(description ="立即购买必填,购物车结算不填") @RequestParam(required = false) Long skuId
) {
OrderConfirmVO result = orderService.confirmOrder(skuId);
return Result.success(result);

View File

@ -1,15 +1,11 @@
package com.youlai.mall.product.controller.admin;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.result.PageResult;
import com.youlai.common.result.Result;
import com.youlai.common.web.model.Option;
import com.youlai.mall.product.model.entity.Brand;
import com.youlai.mall.product.model.query.BrandCategoryQuery;
import com.youlai.mall.product.model.query.BrandPageQuery;
import com.youlai.mall.product.model.vo.BrandCategoryVO;
import com.youlai.mall.product.model.vo.BrandPageVO;
import com.youlai.mall.product.service.BrandCategoryService;
import com.youlai.mall.product.service.BrandService;
@ -79,21 +75,23 @@ public class BrandController {
@Operation(summary = "删除品牌")
@DeleteMapping("/{ids}")
public Result deleteBrands(
@Parameter(name = "品牌ID多个以英文逗号(,)分割") @PathVariable("ids") String ids
@Parameter(description = "品牌ID多个以英文逗号(,)分割") @PathVariable("ids") String ids
) {
boolean status = brandService.removeByIds(Arrays.asList(ids.split(",")));
return Result.judge(status);
}
@Operation(summary = "获取品牌分类关联列表")
@GetMapping("/{brandId}/brand-categories")
public Result<List<BrandCategoryVO>> listBrandCategories(BrandCategoryQuery queryParams) {
List<BrandCategoryVO> list = brandCategoryService.listBrandCategories(queryParams);
return Result.success(list);
@Operation(summary = "获取品牌关联的分类列表")
@GetMapping("/{brandId}/categories")
public Result<List<Option>> listBrandCategories(
@Parameter(description = "品牌ID") @PathVariable Long brandId
) {
List<Option> categories = brandCategoryService.listBrandCategories(brandId);
return Result.success(categories);
}
@Operation(summary = "保存品牌分类关联")
@PostMapping("/{brandId}/brand-categories")
@Operation(summary = "修改品牌分类关联")
@PutMapping("/{brandId}/categories")
public Result saveBrandCategories(
@Parameter(description = "品牌ID") @PathVariable Long brandId,
@RequestBody List<Long> categoryIds) {

View File

@ -46,7 +46,7 @@ public class CategoryController {
@Operation(summary = "获取商品分类表单数据")
@GetMapping("/{id}/form")
public Result getCategoryForm(
@Parameter(name = "商品分类ID") @PathVariable Long id
@Parameter(description = "商品分类ID") @PathVariable Long id
) {
Category category = categoryService.getById(id);
return Result.success(category);
@ -64,7 +64,7 @@ public class CategoryController {
@Operation(summary = "删除商品分类")
@DeleteMapping("/{id}")
public Result deleteCategory(
@Parameter(name = "商品分类ID") @PathVariable Long id
@Parameter(description = "商品分类ID") @PathVariable Long id
) {
boolean result = categoryService.deleteCategory(id);
return Result.judge(result);

View File

@ -54,7 +54,7 @@ public class SpuController {
@Operation(summary = "删除商品")
@DeleteMapping("/{ids}")
public Result deleteSpu(
@Parameter(name = "SPU ID,多个以英文逗号(,)分隔") @PathVariable String ids
@Parameter(description = "SPU ID,多个以英文逗号(,)分隔") @PathVariable String ids
) {
boolean result = spuService.removeBySpuIds(ids);
return Result.judge(result);

View File

@ -29,7 +29,7 @@ public class AppCategoryController {
@Operation(summary = "分类列表")
@GetMapping
public Result list(@Parameter(name = "上级分类ID") Long parentId) {
public Result list(@Parameter(description = "上级分类ID") Long parentId) {
List<CategoryVO> list = categoryService.listCategories(parentId);
return Result.success(list);
}

View File

@ -29,7 +29,7 @@ public class AppSkuController {
@Operation(summary = "获取商品库存信息")
@GetMapping("/{skuId}")
public Result<SkuInfoDto> getSkuInfo(
@Parameter(name ="商品ID") @PathVariable Long skuId
@Parameter(description ="商品ID") @PathVariable Long skuId
) {
SkuInfoDto skuInfo = skuService.getSkuInfo(skuId);
return Result.success(skuInfo);
@ -38,7 +38,7 @@ public class AppSkuController {
@Operation(summary = "获取商品列表")
@GetMapping
public Result<List<SkuInfoDto>> listSkuInfoByIds(
@Parameter(name ="SKU的ID集合") @RequestParam List<Long> skuIds
@Parameter(description ="SKU的ID集合") @RequestParam List<Long> skuIds
) {
List<SkuInfoDto> skuInfos = skuService.listSkuInfos(skuIds);
return Result.success(skuInfos);

View File

@ -37,7 +37,7 @@ public class AppSpuController {
@Operation(summary = "获取商品详情")
@GetMapping("/{spuId}")
public Result<SpuDetailVO> getSpuDetail(
@Parameter(name ="商品ID") @PathVariable Long spuId
@Parameter(description ="商品ID") @PathVariable Long spuId
) {
SpuDetailVO spuDetailVO = spuService.getSpuDetailForApp(spuId);
return Result.success(spuDetailVO);

View File

@ -1,27 +0,0 @@
package com.youlai.mall.product.converter;
import com.youlai.mall.product.model.entity.BrandCategory;
import com.youlai.mall.product.model.form.BrandCategoryForm;
import com.youlai.mall.product.model.vo.BrandCategoryVO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import java.util.List;
/**
* 品牌分类关联转换器
*
* @author Ray Hao
* @since 2024-05-06
*/
@Mapper(componentModel = "spring")
public interface BrandCategoryConverter {
List<BrandCategoryVO> entity2Vo(List<BrandCategory> list);
BrandCategoryForm entity2Form(BrandCategory entity);
@InheritInverseConfiguration(name = "entity2Form")
BrandCategory form2Entity(BrandCategoryForm entity);
}

View File

@ -1,9 +1,12 @@
package com.youlai.mall.product.mapper;
import com.youlai.common.web.model.Option;
import com.youlai.mall.product.model.entity.BrandCategory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 品牌分类关联 Mapper 接口
*
@ -14,4 +17,8 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BrandCategoryMapper extends BaseMapper<BrandCategory> {
/**
* 获取品牌的分类列表
*/
List<Option> listBrandCategories(Long brandId);
}

View File

@ -1,13 +1,11 @@
package com.youlai.mall.product.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* 品牌分类关联实体
*
@ -19,14 +17,6 @@ import lombok.Setter;
@TableName("pms_brand_category")
public class BrandCategory implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 分类ID
*/
@ -37,13 +27,4 @@ public class BrandCategory implements Serializable {
*/
private Long brandId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 创建人ID
*/
private Long createBy;
}
}

View File

@ -1,22 +0,0 @@
package com.youlai.mall.product.model.query;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 品牌分类关联查询对象
*
* @author Ray Hao
* @since 2024-05-06
*/
@Schema(description ="品牌分类关联查询对象")
@Data
public class BrandCategoryQuery {
@Schema(description="关键字")
private String keywords;
@Schema(description="品牌ID")
private Long brandId;
}

View File

@ -1,26 +0,0 @@
package com.youlai.mall.product.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Schema(description = "品牌分类视图对象")
@Getter
@Setter
public class BrandCategoryVO {
@Schema(description = "品牌ID", example = "1")
private Long brandId;
@Schema(description = "品牌名称", example = "小米")
private String brandName;
@Schema(description = "分类ID", example = "1")
private Long categoryId;
@Schema(description = "分类名称", example = "电子产品")
private String categoryName;
}

View File

@ -1,9 +1,8 @@
package com.youlai.mall.product.service;
import com.youlai.common.web.model.Option;
import com.youlai.mall.product.model.entity.BrandCategory;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.product.model.query.BrandCategoryQuery;
import com.youlai.mall.product.model.vo.BrandCategoryVO;
import java.util.List;
@ -17,10 +16,8 @@ public interface BrandCategoryService extends IService<BrandCategory> {
/**
* 品牌分类关联列表
* <p>
* {@link List<BrandCategoryVO>} 品牌分类关联分页列表
*/
List<BrandCategoryVO> listBrandCategories(BrandCategoryQuery queryParams);
List<Option> listBrandCategories(Long brandId);
/**

View File

@ -3,25 +3,18 @@ package com.youlai.mall.product.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.youlai.common.security.util.SecurityUtils;
import com.youlai.mall.product.model.entity.Brand;
import com.youlai.common.web.model.Option;
import com.youlai.mall.product.model.entity.BrandCategory;
import com.youlai.mall.product.mapper.BrandCategoryMapper;
import com.youlai.mall.product.model.vo.BrandCategoryVO;
import com.youlai.mall.product.service.BrandCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.youlai.mall.product.model.form.BrandCategoryForm;
import com.youlai.mall.product.model.query.BrandCategoryQuery;
import com.youlai.mall.product.converter.BrandCategoryConverter;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
/**
* 品牌分类关联服务实现类
*
@ -29,24 +22,17 @@ import cn.hutool.core.util.StrUtil;
* @since 2024-05-06
*/
@Service
@RequiredArgsConstructor
public class BrandCategoryServiceImpl extends ServiceImpl<BrandCategoryMapper, BrandCategory> implements BrandCategoryService {
private final BrandCategoryConverter brandCategoryConverter;
/**
* 获取品牌分类关联分页列表
*
* @param queryParams 查询参数
* @return {@link List<BrandCategoryVO>} 品牌分类关联分页列表
* 获取品牌的分类ID列表
*/
@Override
public List<BrandCategoryVO> listBrandCategories(BrandCategoryQuery queryParams) {
List<BrandCategory> list = this.list(new LambdaQueryWrapper<BrandCategory>()
.eq(queryParams.getBrandId() != null, BrandCategory::getBrandId, queryParams.getBrandId())
);
return brandCategoryConverter.entity2Vo(list);
public List<Option> listBrandCategories(Long brandId) {
if (brandId == null) {
return Collections.emptyList();
}
return this.baseMapper.listBrandCategories(brandId);
}
@ -75,7 +61,7 @@ public class BrandCategoryServiceImpl extends ServiceImpl<BrandCategoryMapper, B
this.remove(
new LambdaQueryWrapper<>(BrandCategory.class)
.eq(BrandCategory::getBrandId, brandId)
.in(BrandCategory::getId, removeCategoryIds)
.in(BrandCategory::getCategoryId, removeCategoryIds)
);
}
@ -85,16 +71,12 @@ public class BrandCategoryServiceImpl extends ServiceImpl<BrandCategoryMapper, B
.toList();
if (CollectionUtil.isNotEmpty(newCategoryIds)) {
Long userId = SecurityUtils.getUserId();
LocalDateTime now = LocalDateTime.now();
List<BrandCategory> newBrandCategories = newCategoryIds.stream()
.map(categoryId -> {
BrandCategory brandCategory = new BrandCategory();
brandCategory.setBrandId(brandId);
brandCategory.setCategoryId(categoryId);
brandCategory.setCreateBy(userId);
brandCategory.setCreateTime(now);
return brandCategory;
})
.toList();

View File

@ -2,5 +2,16 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.mall.product.mapper.BrandCategoryMapper">
<!-- 查询品牌分类列表 -->
<select id="listBrandCategories" resultType="com.youlai.common.web.model.Option">
SELECT
pc.id AS 'value',
pc.name AS 'label'
FROM
pms_brand_category pbc
INNER JOIN pms_category pc ON pbc.category_id = pc.id AND pc.is_deleted = 0
WHERE
pbc.brand_id = #{brandId}
</select>
</mapper>

View File

@ -46,7 +46,7 @@ public class SmsAdvertController {
@Operation(summary= "广告详情")
@GetMapping("/{id}")
public Result getAdvertDetail(
@Parameter(name = "广告ID") @PathVariable Long id
@Parameter(description = "广告ID") @PathVariable Long id
) {
SmsAdvert advert = smsAdvertService.getById(id);
return Result.success(advert);
@ -62,7 +62,7 @@ public class SmsAdvertController {
@Operation(summary= "修改广告")
@PutMapping(value = "/{id}")
public Result updateAdvert(
@Parameter(name = "广告ID") @PathVariable Long id,
@Parameter(description = "广告ID") @PathVariable Long id,
@RequestBody SmsAdvert advert) {
boolean status = smsAdvertService.updateById(advert);
return Result.judge(status);
@ -70,7 +70,7 @@ public class SmsAdvertController {
@Operation(summary= "删除广告")
@DeleteMapping("/{ids}")
public Result deleteAdverts(@Parameter(name = "广告ID多个以英文逗号(,)分割") @PathVariable("ids") String ids) {
public Result deleteAdverts(@Parameter(description = "广告ID多个以英文逗号(,)分割") @PathVariable("ids") String ids) {
boolean status = smsAdvertService.removeByIds(Arrays.asList(ids.split(",")));
return Result.judge(status);

View File

@ -32,7 +32,7 @@ public class SmsCouponController {
@Operation(summary= "优惠券表单数据")
@GetMapping("/{couponId}/form_data")
public Result<CouponForm> getCouponFormData(@Parameter(name = "优惠券ID") @PathVariable Long couponId) {
public Result<CouponForm> getCouponFormData(@Parameter(description = "优惠券ID") @PathVariable Long couponId) {
CouponForm couponForm = couponService.getCouponFormData(couponId);
return Result.success(couponForm);
}
@ -56,7 +56,7 @@ public class SmsCouponController {
@Operation(summary= "删除优惠券")
@DeleteMapping("/{ids}")
public Result deleteCoupons(@Parameter(name = "用户ID多个以英文逗号(,)分割") @PathVariable String ids) {
public Result deleteCoupons(@Parameter(description = "用户ID多个以英文逗号(,)分割") @PathVariable String ids) {
boolean result = couponService.deleteCoupons(ids);
return Result.judge(result);
}

View File

@ -36,7 +36,7 @@ public class MemberController {
@Operation(summary= "修改会员")
@PutMapping(value = "/{memberId}")
public <T> Result<T> update(
@Parameter(name = "会员ID") @PathVariable Long memberId,
@Parameter(description = "会员ID") @PathVariable Long memberId,
@RequestBody UmsMember member
) {
boolean status = memberService.updateById(member);
@ -46,7 +46,7 @@ public class MemberController {
@Operation(summary= "修改会员状态")
@PatchMapping("/{memberId}/status")
public <T> Result<T> updateMemberStatus(
@Parameter(name = "会员ID") @PathVariable Long memberId,
@Parameter(description = "会员ID") @PathVariable Long memberId,
@RequestBody UmsMember member
) {
boolean status = memberService.update(
@ -60,7 +60,7 @@ public class MemberController {
@Operation(summary= "删除会员")
@DeleteMapping("/{ids}")
public <T> Result<T> delete(
@Parameter(name = "会员ID多个以英文逗号(,)拼接") @PathVariable String ids
@Parameter(description = "会员ID多个以英文逗号(,)拼接") @PathVariable String ids
) {
boolean status = memberService.update(new LambdaUpdateWrapper<UmsMember>()
.in(UmsMember::getId, Arrays.asList(ids.split(",")))

View File

@ -33,7 +33,7 @@ public class AppAddressController {
@Operation(summary= "获取地址详情")
@GetMapping("/{addressId}")
public Result<UmsAddress> getAddressDetail(
@Parameter(name = "地址ID") @PathVariable Long addressId
@Parameter(description = "地址ID") @PathVariable Long addressId
) {
UmsAddress umsAddress = addressService.getById(addressId);
return Result.success(umsAddress);
@ -51,7 +51,7 @@ public class AppAddressController {
@Operation(summary= "修改地址")
@PutMapping("/{addressId}")
public Result updateAddress(
@Parameter(name = "地址ID") @PathVariable Long addressId,
@Parameter(description = "地址ID") @PathVariable Long addressId,
@RequestBody @Validated AddressForm addressForm
) {
boolean result = addressService.updateAddress(addressForm);
@ -61,7 +61,7 @@ public class AppAddressController {
@Operation(summary= "删除地址")
@DeleteMapping("/{ids}")
public Result deleteAddress(
@Parameter(name = "地址ID过个以英文逗号(,)分割") @PathVariable String ids
@Parameter(description = "地址ID过个以英文逗号(,)分割") @PathVariable String ids
) {
boolean status = addressService.removeByIds(Arrays.asList(ids.split(",")));
return Result.judge(status);

View File

@ -66,7 +66,7 @@ public class AppCartController {
@Operation(summary = "切换购物车商品的选中状态")
@PatchMapping("/toggle-check")
public Result toggleCheckAllItems(
@Parameter(name = "是否全选(true:全选;false:全不选)") boolean checked
@Parameter(description = "是否全选(true:全选;false:全不选)") boolean checked
) {
cartService.toggleCheckAllItems(checked);
return Result.success();

View File

@ -28,7 +28,7 @@ public class AppMemberController {
@Operation(summary = "根据会员ID获取OpenId")
@GetMapping("/{memberId}/openid")
public Result<String> getMemberOpenId(
@Parameter(name = "会员ID") @PathVariable Long memberId
@Parameter(description = "会员ID") @PathVariable Long memberId
) {
UmsMember member = memberService.getOne(new LambdaQueryWrapper<UmsMember>()
.eq(UmsMember::getId, memberId)
@ -64,7 +64,7 @@ public class AppMemberController {
@Operation(summary = "根据OpenId获取会员认证信息", hidden = true)
@GetMapping("/openid/{openid}")
public Result<MemberAuthDTO> getMemberByOpenid(@Parameter(name = "微信唯一身份标识") @PathVariable String openid) {
public Result<MemberAuthDTO> getMemberByOpenid(@Parameter(description = "微信唯一身份标识") @PathVariable String openid) {
MemberAuthDTO memberAuthInfo = memberService.getMemberByOpenid(openid);
return Result.success(memberAuthInfo);
}
@ -72,7 +72,7 @@ public class AppMemberController {
@Operation(summary = "根据手机号获取会员认证信息", hidden = true)
@GetMapping("/mobile/{mobile}")
public Result<MemberAuthDTO> getMemberByMobile(
@Parameter(name = "手机号码") @PathVariable String mobile
@Parameter(description = "手机号码") @PathVariable String mobile
) {
MemberAuthDTO memberAuthInfo = memberService.getMemberByMobile(mobile);
return Result.success(memberAuthInfo);

View File

@ -21,7 +21,7 @@ public class FileController {
@PostMapping
@Operation(summary= "文件上传")
public Result<FileInfoVO> uploadFile(
@Parameter(name = "表单文件对象") @RequestParam(value = "file") MultipartFile file
@Parameter(description = "表单文件对象") @RequestParam(value = "file") MultipartFile file
) {
FileInfoVO fileInfo = ossService.uploadFile(file);
return Result.success(fileInfo);
@ -30,7 +30,7 @@ public class FileController {
@DeleteMapping
@Operation(summary= "文件删除")
public Result deleteFile(
@Parameter(name = "文件路径") @RequestParam String filePath
@Parameter(description = "文件路径") @RequestParam String filePath
) {
boolean result = ossService.deleteFile(filePath);
return Result.judge(result);