feat(themes): 新增主题查询与风格筛选接口
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.yolo.keyborad.controller;
|
||||
|
||||
import com.yolo.keyborad.common.BaseResponse;
|
||||
import com.yolo.keyborad.common.ResultUtils;
|
||||
import com.yolo.keyborad.model.vo.themes.KeyboradThemesRespVO;
|
||||
import com.yolo.keyborad.service.KeyboradThemesService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 java.util.List;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 14:53
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/themes")
|
||||
@Tag(name = "主题")
|
||||
public class ThemesController {
|
||||
|
||||
@Resource
|
||||
private KeyboradThemesService themesService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查询所有主题", description = "查询所有主题列表接口")
|
||||
public BaseResponse<List<KeyboradThemesRespVO>> list() {
|
||||
return ResultUtils.success(themesService.selectAllThemes());
|
||||
}
|
||||
|
||||
@GetMapping("/listByStyle")
|
||||
@Operation(summary = "按风格查询主题", description = "按主题风格查询主题列表接口")
|
||||
public BaseResponse<List<KeyboradThemesRespVO>> listByStyle(@RequestParam("themeStyle") Long themeStyleId) {
|
||||
return ResultUtils.success(themesService.selectThemesByStyle(themeStyleId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yolo.keyborad.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboardThemeStyles;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 15:20
|
||||
*/
|
||||
|
||||
public interface KeyboardThemeStylesMapper extends BaseMapper<KeyboardThemeStyles> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yolo.keyborad.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboradThemes;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 14:51
|
||||
*/
|
||||
|
||||
public interface KeyboradThemesMapper extends BaseMapper<KeyboradThemes> {
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yolo.keyborad.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 15:20
|
||||
*/
|
||||
|
||||
@Schema
|
||||
@Data
|
||||
@TableName(value = "keyboard_theme_styles")
|
||||
public class KeyboardThemeStyles {
|
||||
/**
|
||||
* 主键 Id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Schema(description="主键 Id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 风格名称
|
||||
*/
|
||||
@TableField(value = "style_name")
|
||||
@Schema(description="风格名称")
|
||||
private String styleName;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField(value = "deleted")
|
||||
@Schema(description="是否删除")
|
||||
private Boolean deleted;
|
||||
|
||||
@TableField(value = "created_at")
|
||||
@Schema(description="")
|
||||
private Date createdAt;
|
||||
|
||||
@TableField(value = "updated_at")
|
||||
@Schema(description="")
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.yolo.keyborad.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 14:51
|
||||
*/
|
||||
|
||||
@Schema
|
||||
@Data
|
||||
@TableName(value = "keyborad_themes")
|
||||
public class KeyboradThemes {
|
||||
/**
|
||||
* 主键 Id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Schema(description="主键 Id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 键盘皮肤名称
|
||||
*/
|
||||
@TableField(value = "theme_name")
|
||||
@Schema(description="键盘皮肤名称")
|
||||
private String themeName;
|
||||
|
||||
/**
|
||||
* 键盘价格
|
||||
*/
|
||||
@TableField(value = "theme_price")
|
||||
@Schema(description="键盘价格")
|
||||
private BigDecimal themePrice;
|
||||
|
||||
/**
|
||||
* 主题标签
|
||||
*/
|
||||
@TableField(value = "theme_tag")
|
||||
@Schema(description="主题标签")
|
||||
private String themeTag;
|
||||
|
||||
/**
|
||||
* 主题下载次数
|
||||
*/
|
||||
@TableField(value = "theme_download")
|
||||
@Schema(description="主题下载次数")
|
||||
private String themeDownload;
|
||||
|
||||
/**
|
||||
* 主题风格
|
||||
*/
|
||||
@TableField(value = "theme_style")
|
||||
@Schema(description="主题风格")
|
||||
private Long themeStyle;
|
||||
|
||||
/**
|
||||
* 主题状态
|
||||
*/
|
||||
@TableField(value = "theme_status")
|
||||
@Schema(description="主题状态")
|
||||
private Boolean themeStatus;
|
||||
|
||||
/**
|
||||
* 主题购买次数
|
||||
*/
|
||||
@TableField(value = "theme_purchases_number")
|
||||
@Schema(description="主题购买次数")
|
||||
private Long themePurchasesNumber;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField(value = "deleted")
|
||||
@Schema(description="是否删除")
|
||||
private Boolean deleted;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "created_at")
|
||||
@Schema(description="创建时间")
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_at")
|
||||
@Schema(description="更新时间")
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yolo.keyborad.model.vo.themes;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9
|
||||
*/
|
||||
@Schema(description = "主题返回对象")
|
||||
@Data
|
||||
public class KeyboradThemesRespVO {
|
||||
/**
|
||||
* 主键 Id
|
||||
*/
|
||||
@Schema(description = "主键 Id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 键盘皮肤名称
|
||||
*/
|
||||
@Schema(description = "键盘皮肤名称")
|
||||
private String themeName;
|
||||
|
||||
/**
|
||||
* 键盘价格
|
||||
*/
|
||||
@Schema(description = "键盘价格")
|
||||
private BigDecimal themePrice;
|
||||
|
||||
/**
|
||||
* 主题标签
|
||||
*/
|
||||
@Schema(description = "主题标签")
|
||||
private String themeTag;
|
||||
|
||||
/**
|
||||
* 主题下载次数
|
||||
*/
|
||||
@Schema(description = "主题下载次数")
|
||||
private String themeDownload;
|
||||
|
||||
/**
|
||||
* 主题风格
|
||||
*/
|
||||
@Schema(description = "主题风格")
|
||||
private Long themeStyle;
|
||||
|
||||
/**
|
||||
* 主题状态
|
||||
*/
|
||||
@Schema(description = "主题状态")
|
||||
private Boolean themeStatus;
|
||||
|
||||
/**
|
||||
* 主题购买次数
|
||||
*/
|
||||
@Schema(description = "主题购买次数")
|
||||
private Long themePurchasesNumber;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yolo.keyborad.service;
|
||||
|
||||
import com.yolo.keyborad.model.entity.KeyboardThemeStyles;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 15:20
|
||||
*/
|
||||
|
||||
public interface KeyboardThemeStylesService extends IService<KeyboardThemeStyles>{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yolo.keyborad.service;
|
||||
|
||||
import com.yolo.keyborad.model.entity.KeyboradThemes;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yolo.keyborad.model.vo.themes.KeyboradThemesRespVO;
|
||||
|
||||
import java.util.List;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 14:51
|
||||
*/
|
||||
|
||||
public interface KeyboradThemesService extends IService<KeyboradThemes>{
|
||||
|
||||
/**
|
||||
* 查询所有主题列表(未删除且上架)
|
||||
* @return 主题列表
|
||||
*/
|
||||
List<KeyboradThemesRespVO> selectAllThemes();
|
||||
|
||||
/**
|
||||
* 按主题风格查询主题列表(未删除且上架)
|
||||
* @param themeStyle 主题风格
|
||||
* @return 主题列表
|
||||
*/
|
||||
List<KeyboradThemesRespVO> selectThemesByStyle(Long themeStyle);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yolo.keyborad.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yolo.keyborad.mapper.KeyboardThemeStylesMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboardThemeStyles;
|
||||
import com.yolo.keyborad.service.KeyboardThemeStylesService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 15:20
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class KeyboardThemeStylesServiceImpl extends ServiceImpl<KeyboardThemeStylesMapper, KeyboardThemeStyles> implements KeyboardThemeStylesService{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yolo.keyborad.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yolo.keyborad.mapper.KeyboradThemesMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboradThemes;
|
||||
import com.yolo.keyborad.model.vo.themes.KeyboradThemesRespVO;
|
||||
import com.yolo.keyborad.service.KeyboradThemesService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/9 14:51
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class KeyboradThemesServiceImpl extends ServiceImpl<KeyboradThemesMapper, KeyboradThemes> implements KeyboradThemesService{
|
||||
|
||||
@Override
|
||||
public List<KeyboradThemesRespVO> selectAllThemes() {
|
||||
List<KeyboradThemes> themesList = this.lambdaQuery()
|
||||
.eq(KeyboradThemes::getDeleted, false)
|
||||
.eq(KeyboradThemes::getThemeStatus, false)
|
||||
.list();
|
||||
return BeanUtil.copyToList(themesList, KeyboradThemesRespVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyboradThemesRespVO> selectThemesByStyle(Long themeStyle) {
|
||||
List<KeyboradThemes> themesList = this.lambdaQuery()
|
||||
.eq(KeyboradThemes::getDeleted, false)
|
||||
.eq(KeyboradThemes::getThemeStatus, false)
|
||||
.eq(KeyboradThemes::getThemeStyle, themeStyle)
|
||||
.list();
|
||||
return BeanUtil.copyToList(themesList, KeyboradThemesRespVO.class);
|
||||
}
|
||||
}
|
||||
17
src/main/resources/mapper/KeyboardThemeStylesMapper.xml
Normal file
17
src/main/resources/mapper/KeyboardThemeStylesMapper.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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.KeyboardThemeStylesMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yolo.keyborad.model.entity.KeyboardThemeStyles">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table keyboard_theme_styles-->
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="style_name" jdbcType="VARCHAR" property="styleName" />
|
||||
<result column="deleted" jdbcType="BOOLEAN" property="deleted" />
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
||||
<result column="updated_at" jdbcType="DATE" property="updatedAt" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, style_name, deleted, created_at, updated_at
|
||||
</sql>
|
||||
</mapper>
|
||||
24
src/main/resources/mapper/KeyboradThemesMapper.xml
Normal file
24
src/main/resources/mapper/KeyboradThemesMapper.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user