This commit is contained in:
2025-09-23 17:17:13 +08:00
parent af242be601
commit f475d940be
8 changed files with 132 additions and 0 deletions
@@ -0,0 +1,22 @@
-- 创建套餐表
-- 执行前请备份数据
USE `order-center`;
CREATE TABLE IF NOT EXISTS `packages` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`code_id` VARCHAR(64) NOT NULL COMMENT '二维码编码(与qrcodes.code_id对应)',
`vlog_count` INT DEFAULT 0 COMMENT 'Vlog数量',
`video_count` INT DEFAULT 0 COMMENT '视频数量',
`photo_count` INT DEFAULT 0 COMMENT '照片数量',
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
`company` VARCHAR(128) DEFAULT NULL COMMENT '所属公司',
`is_del` TINYINT(1) DEFAULT 0 COMMENT '是否删除 0-否 1-是',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_code_id` (`code_id`),
KEY `idx_tenant_id` (`tenant_id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='套餐表';
@@ -0,0 +1,34 @@
package com.central.order.controller;
import com.central.common.model.Result;
import com.central.order.model.PackagePlan;
import com.central.order.service.IPackagePlanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Tag(name = "套餐管理")
@RequestMapping("/package")
public class PackagePlanController {
@Autowired
private IPackagePlanService packagePlanService;
@Operation(summary = "根据二维码编码获取套餐内容")
@GetMapping("/byCode/{codeId}")
public Result<List<PackagePlan>> getByCode(@PathVariable("codeId") String codeId) {
List<PackagePlan> list = packagePlanService.getByCodeId(codeId);
if (CollectionUtils.isEmpty(list)) {
return Result.succeed(list, "暂无数据");
}
return Result.succeed(list, "获取成功");
}
}
@@ -0,0 +1,18 @@
package com.central.order.mapper;
import com.central.db.mapper.SuperMapper;
import com.central.order.model.PackagePlan;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface PackagePlanMapper extends SuperMapper<PackagePlan> {
/**
* 根据二维码编码查询套餐列表
*/
List<PackagePlan> findByCodeId(@Param("codeId") String codeId);
}
@@ -0,0 +1,4 @@
package com.central.order.model;
public class PackagePlan {
}
@@ -0,0 +1,17 @@
package com.central.order.service;
import com.central.common.service.ISuperService;
import com.central.order.model.PackagePlan;
import java.util.List;
/**
* 套餐服务
*/
public interface IPackagePlanService extends ISuperService<PackagePlan> {
/**
* 根据二维码编码查询套餐列表
*/
List<PackagePlan> getByCodeId(String codeId);
}
@@ -0,0 +1,19 @@
package com.central.order.service.impl;
import com.central.common.service.impl.SuperServiceImpl;
import com.central.order.mapper.PackagePlanMapper;
import com.central.order.model.PackagePlan;
import com.central.order.service.IPackagePlanService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PackagePlanServiceImpl extends SuperServiceImpl<PackagePlanMapper, PackagePlan> implements IPackagePlanService {
@Override
public List<PackagePlan> getByCodeId(String codeId) {
return baseMapper.findByCodeId(codeId);
}
}
@@ -0,0 +1,18 @@
<?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.central.order.mapper.PackagePlanMapper">
<resultMap id="PackagePlanResultMap" type="com.central.order.model.PackagePlan">
</resultMap>
<select id="findByCodeId" resultMap="PackagePlanResultMap">
SELECT *
FROM packages
WHERE code_id = #{codeId}
AND (is_del IS NULL OR is_del = 0)
ORDER BY create_time DESC
</select>
</mapper>