springboot企业级抽奖项目业务三(活动模块)

news2024/9/20 22:37:51

梅开三度

开发流程

该业务基于rouyi生成好了mapper和service的代码,现在需要在controller层写接口

实际操作流程:

看接口文档一>controller里定义函数一>看给出的工具类一>补全controller里的函数一>运行测试

接口文档

在用户模块用户先看到活动列表,在活动列表内点击具体活动,进入看到活动信息、奖品信息和中奖列表。

controller里定义

在注解框架里加上list、info、products和hit四个函数

@RestController
@RequestMapping(value = "/api/game")
@Api(tags = {"活动模块"})
public class GameController {
    @Autowired
    private GameLoadService loadService;
    @Autowired
    private CardGameService gameService;
    @Autowired
    private ViewCardUserHitService hitService;

    @GetMapping("/list/{status}/{curpage}/{limit}")
    @ApiOperation(value = "活动列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="status",value = "活动状态(-1=全部,0=未开始,1=进行中,2=已结束)",example = "-1",required = true),
            @ApiImplicitParam(name = "curpage",value = "第几页",defaultValue = "1",dataType = "int", example = "1",required = true),
            @ApiImplicitParam(name = "limit",value = "每页条数",defaultValue = "10",dataType = "int",example = "3",required = true)
    })
    public ApiResult list(@PathVariable int status,@PathVariable int curpage,@PathVariable int limit) {
        //TODO
        return null;
    }

    @GetMapping("/info/{gameid}")
    @ApiOperation(value = "活动信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="gameid",value = "活动id",example = "1",required = true)
    })
    public ApiResult<CardGame> info(@PathVariable int gameid) {
        //TODO
        return null;
    }

    @GetMapping("/products/{gameid}")
    @ApiOperation(value = "奖品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="gameid",value = "活动id",example = "1",required = true)
    })
    public ApiResult<List<CardProductDto>> products(@PathVariable int gameid) {
        //TODO
        return null;
    }

    @GetMapping("/hit/{gameid}/{curpage}/{limit}")
    @ApiOperation(value = "中奖列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="gameid",value = "活动id",dataType = "int",example = "1",required = true),
            @ApiImplicitParam(name = "curpage",value = "第几页",defaultValue = "1",dataType = "int", example = "1",required = true),
            @ApiImplicitParam(name = "limit",value = "每页条数",defaultValue = "10",dataType = "int",example = "3",required = true)
    })
    public ApiResult<PageBean<ViewCardUserHit>> hit(@PathVariable int gameid,@PathVariable int curpage,@PathVariable int limit) {
        //TODO
        return null;
    }


}

看给出的工具类

找该模块附近的common和util包

补全controller里的函数

比较简单,直接上完整代码(初版,后期修bug)

基本就用wrapper查下

@RestController
@RequestMapping(value = "/api/game")
@Api(tags = {"活动模块"})
public class GameController {
    @Autowired
    private GameLoadService loadService;
    @Autowired
    private CardGameService gameService;
    @Autowired
    private ViewCardUserHitService hitService;

    @GetMapping("/list/{status}/{curpage}/{limit}")
    @ApiOperation(value = "活动列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="status",value = "活动状态(-1=全部,0=未开始,1=进行中,2=已结束)",example = "-1",required = true),
            @ApiImplicitParam(name = "curpage",value = "第几页",defaultValue = "1",dataType = "int", example = "1",required = true),
            @ApiImplicitParam(name = "limit",value = "每页条数",defaultValue = "10",dataType = "int",example = "3",required = true)
    })
    public ApiResult list(@PathVariable int status,@PathVariable int curpage,@PathVariable int limit) {

        QueryWrapper<CardGame> wrapper = new QueryWrapper<>();
        if (status != -1) {
            wrapper.eq("status",status);
        }
        Page<CardGame> all = gameService.page(new Page(curpage,limit),wrapper);
        return new ApiResult(1,"成功",new PageBean<CardGame>(all));
    }

    @GetMapping("/info/{gameid}")
    @ApiOperation(value = "活动信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="gameid",value = "活动id",example = "1",required = true)
    })
    public ApiResult<CardGame> info(@PathVariable int gameid) {
        CardGame game = gameService.getById(gameid);
        return new ApiResult(1,"成功",game);
    }

    @GetMapping("/products/{gameid}")
    @ApiOperation(value = "奖品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="gameid",value = "活动id",example = "1",required = true)
    })
    public ApiResult<List<CardProductDto>> products(@PathVariable int gameid) {
        List<CardProductDto> productList = loadService.getByGameId(gameid);
        return new ApiResult(1,"成功",productList);
    }

    @GetMapping("/hit/{gameid}/{curpage}/{limit}")
    @ApiOperation(value = "中奖列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="gameid",value = "活动id",dataType = "int",example = "1",required = true),
            @ApiImplicitParam(name = "curpage",value = "第几页",defaultValue = "1",dataType = "int", example = "1",required = true),
            @ApiImplicitParam(name = "limit",value = "每页条数",defaultValue = "10",dataType = "int",example = "3",required = true)
    })
    public ApiResult<PageBean<ViewCardUserHit>> hit(@PathVariable int gameid,@PathVariable int curpage,@PathVariable int limit) {
        QueryWrapper<ViewCardUserHit> wrapper = new QueryWrapper<>();
        if (gameid == -1) {
            wrapper.eq("gameid",gameid);
        }
        Page<ViewCardUserHit> all = hitService.page(new Page(curpage,limit),wrapper);
        return new ApiResult(1,"成功",new PageBean<ViewCardUserHit>(all));
    }


}

运行测试

前后端联调:

​​​​​​​

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1546476.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Cisco firepower 2140 run ASA and config failover

1 背景 here we got 2 cisco firepower 2140 hardware appliance we’re planning to run ASA on it. and config failover for Primary Unit and Secondary Unit 现场2台Cisco firepower 2140防火墙&#xff0c; 运行ASA模式&#xff0c; 双机组HA&#xff0c;心跳线使用E1/1…

爬虫实践(1)

这一篇只提登录模拟&#xff0c;主要介绍chrome开发者窗口的使用&#xff0c;实际上相关接口调用都是用到cookie&#xff0c;需要再加一篇从token到cookie&#xff0c;以保证实践的完整性 以migu登录为例&#xff0c;分析其登录过程&#xff0c;之后可以使用任意语言模拟登录&…

如何利用FLUENT计算流体力学方法解决大气与环境领域流动问题

ANSYS FLUENT是目前全球领先的商用CFD 软件&#xff0c;市场占有率达70%左右&#xff0c;是工程师和研究者不可多得的有力工具。由于采用了多种求解方法和多重网格加速收敛技术&#xff0c;因而FLUENT能达到最佳的收敛速度和求解精度。灵活的非结构化网格和基于解的自适应网格技…

设置MATLAB三维绘图的视角

MATLAB三维绘图plot3在生成绘图后&#xff0c;默认显示视角是斜着的&#xff1a; 使用view(2)命令可以使其转成XoY平面&#xff08;从上往下看的视角&#xff09;&#xff1a;

【第二部分--Python之基础】02

二、运算符与程序流程控制 1、运算符 1.1 算术运算符 算术运算符用于组织整数类型和浮点类型的数据&#xff0c;有一元运算符和二元运算符之分。 一元算术运算符有两个&#xff1a;&#xff08;正号&#xff09;和-&#xff08;负号&#xff09;&#xff0c;例如&#xff1…

自动驾驶-如何进行多传感器的融合

自动驾驶-如何进行多传感器的融合 附赠自动驾驶学习资料和量产经验&#xff1a;链接 引言 自动驾驶中主要使用的感知传感器是摄像头和激光雷达&#xff0c;这两种模态的数据都可以进行目标检测和语义分割并用于自动驾驶中&#xff0c;但是如果只使用单一的传感器进行上述工作…

【Python】enumerate函数的使用方法,小白一看就懂

enumerate函数的使用方法&#xff1a; season[‘a’,‘b’,‘c’,‘d’] for i in enumerate(season): print(i) season[‘a’,‘b’,‘c’,‘d’] for i,eliment in enumerate(season): print(i,eliment) 输出结果为&#xff1a; 练习题&#xff1a; 2.给出10个学生姓名…

国内ip地址随意更换的潜在风险和策略

在数字化时代&#xff0c;IP地址是互联网通信的基础&#xff0c;而国内IP地址的随意更换可能带来一系列安全风险和问题。虎观代理小二将探讨国内IP地址随意更换的潜在影响以及如何有效应对这一挑战。 1.什么是国内IP地址&#xff1f; 国内IP地址是指在国内分配和使用的IP地址&…

【漏洞复现】用友U8C任意文件读取漏洞

声明&#xff1a;亲爱的读者&#xff0c;我们诚挚地提醒您&#xff0c;Aniya网络安全的技术文章仅供个人研究学习参考。任何因传播或利用本实验室提供的信息而造成的直接或间接后果及损失&#xff0c;均由使用者自行承担责任。Aniya网络安全及作者对此概不负责。如有侵权&#…

ChatGPT 对 ELT的理解

本文主要内容来自 ChatGPT 4.0 到底什么是 ETL&#xff1f;在数据库内部&#xff0c;把数据从 ODS 层加工成 DWD&#xff0c;再加工成 DWS&#xff0c;这个过程和 ETL 的关系是什么&#xff1f;带着这些问题&#xff0c;我问了一下 ChatGPT&#xff0c;总结如下。 数据在两个数…

工厂能耗管控物联网解决方案

工厂能耗管控物联网解决方案 工厂能耗管控物联网解决方案是一种创新的、基于先进技术手段的能源管理系统&#xff0c;它深度融合了物联网&#xff08;IoT&#xff09;、云计算、大数据分析以及人工智能等前沿科技&#xff0c;以实现对工业生产过程中能源消耗的实时监测、精确计…

小学科学期刊投稿邮箱论文发表

《小学科学》是由国家新闻出版总署批准的教育理论类半月刊&#xff0c;由长春出版传媒集团有限责任公司主管主办&#xff0c;旨在为广大一线科学教师、教研员和其他教育工作者提供一个展示传播、交流、研讨科学教育及教研成果的平台&#xff0c;促进小学科学教育工作者的沟通与…

智能楼宇3D可视化解决方案

什么是智能楼宇? 智能楼宇是为提高楼宇的使用合理性与效率,配置合适的建筑环境系统与楼宇自动化系统、办公自动化与管理信息系统以及先进的通信系统,并通过结构化综合布线系统集成为智能化系统的大楼。 面临的问题 信息孤岛,无法统一管理 各个子系统独立工作、独立管理,…

达梦数据库自动备份(全库)+还原(全库) 控制台

一 前提 1.安装达梦数据库DB8(请参照以前文章) 我的数据库安装目录是 /app/dmDB8 2.已创建实例 (请参照上一篇文章) 二 准备测试数据 三 自动备份步骤 1.开启归档模式 开启DM管理工具管理控制台 弹不出来工具的 输入命令 xhost 第一步 将服务器转换为配置状态 右键-&g…

冒泡排序 快速排序 归并排序 其他排序

书接上回.. 目录 2.3 交换排序 2.3.1冒泡排序 2.3.2 快速排序 快速排序的优化: 快速排序非递归 2.4 归并排序 基本思想 归并排序非递归 海量数据的排序问题 排序算法时间空间复杂度和稳定性总结 四. 其他非基于比较排序 (了解) 2.3 交换排序 基本思想&#xff1a;…

缺省和重载。引用——初识c++

. 个人主页&#xff1a;晓风飞 专栏&#xff1a;数据结构|Linux|C语言 路漫漫其修远兮&#xff0c;吾将上下而求索 文章目录 C输入&输出cout 和cin<<>> 缺省参数全缺省半缺省应用场景声明和定义分离的情况 函数重载1.参数的类型不同2.参数的个数不同3.参数的顺…

systemd-journal(二)之配置文件详解journal-remote.conf,journald.conf,journald.conf

文章目录 写在前面概述journal-remote.conf&#xff0c; journal-remote.conf.d概要配置目录和优先级选项SealSplitModeServerKeyFileServerCertificateFileTrustedCertificateFileMaxUse, KeepFree, MaxFileSize, MaxFiles journal-upload.conf&#xff0c; journal-upload.co…

mmocr安装和使用

https://github.com/open-mmlab/mmocr/blob/main/README_zh-CN.md https://mmocr.readthedocs.io/en/dev-1.x/get_started/quick_run.html 介绍 MMOCR 是基于 PyTorch 和 mmdetection 的开源工具箱&#xff0c;专注于文本检测&#xff0c;文本识别以及相应的下游任务&#xf…

Chromium 通过IDL方式添加扩展API,并且在普通网页也可以调用

先严格按照Chromium 通过IDL方式添加扩展API - 知乎、chromium 41 extensions 自定义 api 接口_chromium自定义扩展api-CSDN博客 里提到的方式&#xff0c;加入扩展api。然后最关键的地方来了&#xff1a; 到src\extensions\renderer\native_extension_bindings_system.cc \sr…

探索网络分析:图理论算法介绍及其如何用于地理空间分析

网络分析简介 出售真空吸尘器的挨家挨户的推销员列出了一个潜在客户,分布在邻近他的几个城市中。他想离开家,参观每个潜在客户,然后返回家园。他可以采取的最短、最有效的路线是什么? 这种情况被称为旅行推销员问题,它可能是优化中研究最深入的问题(旅行推销员问题,2023…