fix(service): 修复 themeStyle=9999 时查询逻辑缺失

This commit is contained in:
2025-12-09 19:49:23 +08:00
parent 5ea763b1db
commit bdb4f009d0
7 changed files with 71 additions and 90 deletions

View File

@@ -3,7 +3,7 @@ package com.yolo.keyborad.controller;
import com.yolo.keyborad.common.BaseResponse; import com.yolo.keyborad.common.BaseResponse;
import com.yolo.keyborad.common.ResultUtils; import com.yolo.keyborad.common.ResultUtils;
import com.yolo.keyborad.model.vo.themes.KeyboardThemeStylesRespVO; import com.yolo.keyborad.model.vo.themes.KeyboardThemeStylesRespVO;
import com.yolo.keyborad.model.vo.themes.KeyboradThemesRespVO; import com.yolo.keyborad.model.vo.themes.KeyboardThemesRespVO;
import com.yolo.keyborad.service.KeyboardThemeStylesService; import com.yolo.keyborad.service.KeyboardThemeStylesService;
import com.yolo.keyborad.service.KeyboradThemesService; import com.yolo.keyborad.service.KeyboradThemesService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@@ -39,7 +39,7 @@ public class ThemesController {
@GetMapping("/listByStyle") @GetMapping("/listByStyle")
@Operation(summary = "按风格查询主题", description = "按主题风格查询主题列表接口") @Operation(summary = "按风格查询主题", description = "按主题风格查询主题列表接口")
public BaseResponse<List<KeyboradThemesRespVO>> listByStyle(@RequestParam("themeStyle") Long themeStyleId) { public BaseResponse<List<KeyboardThemesRespVO>> listByStyle(@RequestParam("themeStyle") Long themeStyleId) {
return ResultUtils.success(themesService.selectThemesByStyle(themeStyleId)); return ResultUtils.success(themesService.selectThemesByStyle(themeStyleId));
} }

View File

@@ -1,12 +1,12 @@
package com.yolo.keyborad.mapper; package com.yolo.keyborad.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yolo.keyborad.model.entity.KeyboradThemes; import com.yolo.keyborad.model.entity.KeyboardThemes;
/* /*
* @author: ziin * @author: ziin
* @date: 2025/12/9 14:51 * @date: 2025/12/9 14:51
*/ */
public interface KeyboradThemesMapper extends BaseMapper<KeyboradThemes> { public interface KeyboardThemesMapper extends BaseMapper<KeyboardThemes> {
} }

View File

@@ -11,87 +11,92 @@ import lombok.Data;
/* /*
* @author: ziin * @author: ziin
* @date: 2025/12/9 14:51 * @date: 2025/12/9 19:47
*/ */
@Schema @Schema
@Data @Data
@TableName(value = "keyborad_themes") @TableName(value = "keyboard_themes")
public class KeyboradThemes { public class KeyboardThemes {
/**
* 主键 Id
*/
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
@Schema(description="主键 Id") @Schema(description="主键 Id")
private Long id; private Long id;
/**
* 键盘皮肤名称
*/
@TableField(value = "theme_name") @TableField(value = "theme_name")
@Schema(description="键盘皮肤名称") @Schema(description="键盘皮肤名称")
private String themeName; private String themeName;
/**
* 键盘价格
*/
@TableField(value = "theme_price") @TableField(value = "theme_price")
@Schema(description="键盘价格") @Schema(description="键盘价格")
private BigDecimal themePrice; private BigDecimal themePrice;
/**
* 主题标签
*/
@TableField(value = "theme_tag") @TableField(value = "theme_tag")
@Schema(description="主题标签") @Schema(description="主题标签")
private String themeTag; private String themeTag;
/**
* 主题下载次数
*/
@TableField(value = "theme_download") @TableField(value = "theme_download")
@Schema(description="主题下载次数") @Schema(description="主题下载次数")
private String themeDownload; private String themeDownload;
/**
* 主题风格
*/
@TableField(value = "theme_style") @TableField(value = "theme_style")
@Schema(description="主题风格") @Schema(description="主题风格")
private Long themeStyle; private Long themeStyle;
/** /**
* 主题状态 * 主题上架状态
*/ */
@TableField(value = "theme_status") @TableField(value = "theme_status")
@Schema(description="主题状态") @Schema(description = "主题上架状态")
private Boolean themeStatus; private Boolean themeStatus;
/**
* 主题购买次数
*/
@TableField(value = "theme_purchases_number") @TableField(value = "theme_purchases_number")
@Schema(description="主题购买次数") @Schema(description="主题购买次数")
private Long themePurchasesNumber; private Long themePurchasesNumber;
/**
* 是否删除
*/
@TableField(value = "deleted") @TableField(value = "deleted")
@Schema(description="是否删除") @Schema(description="是否删除")
private Boolean deleted; private Boolean deleted;
/**
* 创建时间
*/
@TableField(value = "created_at") @TableField(value = "created_at")
@Schema(description="创建时间") @Schema(description="创建时间")
private Date createdAt; private Date createdAt;
/**
* 更新时间
*/
@TableField(value = "updated_at") @TableField(value = "updated_at")
@Schema(description="更新时间") @Schema(description="更新时间")
private Date updatedAt; private Date updatedAt;
/**
* 预览图
*/
@TableField(value = "theme_preview_image_url")
@Schema(description = "预览图")
private String themePreviewImageUrl;
/**
* 是否免费
*/
@TableField(value = "is_free")
@Schema(description = "是否免费")
private Boolean isFree;
/**
* 下载地址
*/
@TableField(value = "theme_download_url")
@Schema(description = "下载地址")
private String themeDownloadUrl;
/**
* 排序
*/
@TableField(value = "sort")
@Schema(description = "排序")
private Integer sort;
/**
* 真实下载数量
*/
@TableField(value = "real_download_count")
@Schema(description = "真实下载数量")
private Long realDownloadCount;
} }

View File

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
*/ */
@Schema(description = "主题返回对象") @Schema(description = "主题返回对象")
@Data @Data
public class KeyboradThemesRespVO { public class KeyboardThemesRespVO {
/** /**
* 主键 Id * 主键 Id
*/ */

View File

@@ -1,8 +1,8 @@
package com.yolo.keyborad.service; package com.yolo.keyborad.service;
import com.yolo.keyborad.model.entity.KeyboradThemes; import com.yolo.keyborad.model.entity.KeyboardThemes;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yolo.keyborad.model.vo.themes.KeyboradThemesRespVO; import com.yolo.keyborad.model.vo.themes.KeyboardThemesRespVO;
import java.util.List; import java.util.List;
/* /*
@@ -10,19 +10,19 @@ import java.util.List;
* @date: 2025/12/9 14:51 * @date: 2025/12/9 14:51
*/ */
public interface KeyboradThemesService extends IService<KeyboradThemes>{ public interface KeyboradThemesService extends IService<KeyboardThemes>{
/** /**
* 查询所有主题列表(未删除且上架) * 查询所有主题列表(未删除且上架)
* @return 主题列表 * @return 主题列表
*/ */
List<KeyboradThemesRespVO> selectAllThemes(); List<KeyboardThemesRespVO> selectAllThemes();
/** /**
* 按主题风格查询主题列表(未删除且上架) * 按主题风格查询主题列表(未删除且上架)
* @param themeStyle 主题风格 * @param themeStyle 主题风格
* @return 主题列表 * @return 主题列表
*/ */
List<KeyboradThemesRespVO> selectThemesByStyle(Long themeStyle); List<KeyboardThemesRespVO> selectThemesByStyle(Long themeStyle);
} }

View File

@@ -2,12 +2,12 @@ package com.yolo.keyborad.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yolo.keyborad.mapper.KeyboradThemesMapper; import com.yolo.keyborad.mapper.KeyboardThemesMapper;
import com.yolo.keyborad.model.entity.KeyboradThemes; import com.yolo.keyborad.model.entity.KeyboardThemes;
import com.yolo.keyborad.model.vo.themes.KeyboradThemesRespVO; import com.yolo.keyborad.model.vo.themes.KeyboardThemesRespVO;
import com.yolo.keyborad.service.KeyboradThemesService; import com.yolo.keyborad.service.KeyboradThemesService;
/* /*
* @author: ziin * @author: ziin
@@ -15,31 +15,31 @@ import com.yolo.keyborad.service.KeyboradThemesService;
*/ */
@Service @Service
public class KeyboradThemesServiceImpl extends ServiceImpl<KeyboradThemesMapper, KeyboradThemes> implements KeyboradThemesService{ public class KeyboradThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper, KeyboardThemes> implements KeyboradThemesService{
@Override @Override
public List<KeyboradThemesRespVO> selectAllThemes() { public List<KeyboardThemesRespVO> selectAllThemes() {
List<KeyboradThemes> themesList = this.lambdaQuery() List<KeyboardThemes> themesList = this.lambdaQuery()
.eq(KeyboradThemes::getDeleted, false) .eq(KeyboardThemes::getDeleted, false)
.eq(KeyboradThemes::getThemeStatus, false) .eq(KeyboardThemes::getThemeStatus, false)
.list(); .list();
return BeanUtil.copyToList(themesList, KeyboradThemesRespVO.class); return BeanUtil.copyToList(themesList, KeyboardThemesRespVO.class);
} }
@Override @Override
public List<KeyboradThemesRespVO> selectThemesByStyle(Long themeStyle) { public List<KeyboardThemesRespVO> selectThemesByStyle(Long themeStyle) {
if (themeStyle == 9999) { if (themeStyle == 9999) {
List<KeyboradThemes> themesList = this.lambdaQuery() List<KeyboardThemes> themesList = this.lambdaQuery()
.eq(KeyboradThemes::getDeleted, false) .eq(KeyboardThemes::getDeleted, false)
.eq(KeyboradThemes::getThemeStatus, false) .eq(KeyboardThemes::getThemeStatus, false)
.list(); .list();
return BeanUtil.copyToList(themesList, KeyboradThemesRespVO.class); return BeanUtil.copyToList(themesList, KeyboardThemesRespVO.class);
} }
List<KeyboradThemes> themesList = this.lambdaQuery() List<KeyboardThemes> themesList = this.lambdaQuery()
.eq(KeyboradThemes::getDeleted, false) .eq(KeyboardThemes::getDeleted, false)
.eq(KeyboradThemes::getThemeStatus, false) .eq(KeyboardThemes::getThemeStatus, false)
.eq(KeyboradThemes::getThemeStyle, themeStyle) .eq(KeyboardThemes::getThemeStyle, themeStyle)
.list(); .list();
return BeanUtil.copyToList(themesList, KeyboradThemesRespVO.class); return BeanUtil.copyToList(themesList, KeyboardThemesRespVO.class);
} }
} }

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yolo.keyborad.mapper.KeyboradThemesMapper">
<resultMap id="BaseResultMap" type="com.yolo.keyborad.model.entity.KeyboradThemes">
<!--@mbg.generated-->
<!--@Table keyborad_themes-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="theme_name" jdbcType="VARCHAR" property="themeName" />
<result column="theme_price" jdbcType="NUMERIC" property="themePrice" />
<result column="theme_tag" jdbcType="CHAR" property="themeTag" />
<result column="theme_download" jdbcType="VARCHAR" property="themeDownload" />
<result column="theme_style" jdbcType="BIGINT" property="themeStyle" />
<result column="theme_status" jdbcType="BOOLEAN" property="themeStatus" />
<result column="theme_purchases_number" jdbcType="BIGINT" property="themePurchasesNumber" />
<result column="deleted" jdbcType="BOOLEAN" property="deleted" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, theme_name, theme_price, theme_tag, theme_download, theme_style, theme_status,
theme_purchases_number, deleted, created_at, updated_at
</sql>
</mapper>