浏览代码

赛事发布初始化

Memory_LG 5 月之前
父节点
当前提交
092e13cf3c

+ 131 - 0
qmjszx-admin/src/main/java/beilv/web/controller/CompetitionController.java

@@ -0,0 +1,131 @@
+package beilv.web.controller;
+
+import java.util.List;
+
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import beilv.common.annotation.Log;
+import beilv.common.enums.BusinessType;
+import beilv.system.domain.Competition;
+import beilv.system.service.ICompetitionService;
+import beilv.common.core.controller.BaseController;
+import beilv.common.core.domain.AjaxResult;
+import beilv.common.utils.poi.ExcelUtil;
+import beilv.common.core.page.TableDataInfo;
+
+/**
+ * 赛事发布Controller
+ *
+ * @author LG
+ * @date 2024-12-31
+ */
+@Controller
+@RequestMapping("/system/competition")
+public class CompetitionController extends BaseController {
+    private String prefix = "system/competition";
+
+    @Autowired
+    private ICompetitionService competitionService;
+
+    @RequiresPermissions("system:competition:view")
+    @GetMapping()
+    public String competition() {
+        return prefix + "/competition";
+    }
+
+    /**
+     * 查询赛事发布列表
+     */
+    @RequiresPermissions("system:competition:list")
+    @PostMapping("/list")
+    @ResponseBody
+    public TableDataInfo list(Competition competition) {
+        startPage();
+        List<Competition> list = competitionService.selectCompetitionList(competition);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出赛事发布列表
+     */
+    @RequiresPermissions("system:competition:export")
+    @Log(title = "赛事发布", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    @ResponseBody
+    public AjaxResult export(Competition competition) {
+        List<Competition> list = competitionService.selectCompetitionList(competition);
+        ExcelUtil<Competition> util = new ExcelUtil<Competition>(Competition.class);
+        return util.exportExcel(list, "赛事发布数据");
+    }
+
+    /**
+     * 新增赛事发布
+     */
+    @RequiresPermissions("system:competition:add")
+    @GetMapping("/add")
+    public String add() {
+        return prefix + "/add";
+    }
+
+    /**
+     * 新增保存赛事发布
+     */
+    @RequiresPermissions("system:competition:add")
+    @Log(title = "赛事发布", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    @ResponseBody
+    public AjaxResult addSave(Competition competition) {
+        return toAjax(competitionService.insertCompetition(competition));
+    }
+
+    /**
+     * 修改赛事发布
+     */
+    @RequiresPermissions("system:competition:edit")
+    @GetMapping("/edit/{id}")
+    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
+        Competition competition = competitionService.selectCompetitionById(id);
+        mmap.put("competition", competition);
+        return prefix + "/edit";
+    }
+
+    /**
+     * 修改保存赛事发布
+     */
+    @RequiresPermissions("system:competition:edit")
+    @Log(title = "赛事发布", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    @ResponseBody
+    public AjaxResult editSave(Competition competition) {
+        return toAjax(competitionService.updateCompetition(competition));
+    }
+
+    /**
+     * 删除赛事发布
+     */
+    @RequiresPermissions("system:competition:remove")
+    @Log(title = "赛事发布", businessType = BusinessType.DELETE)
+    @PostMapping("/remove")
+    @ResponseBody
+    public AjaxResult remove(String ids) {
+        return toAjax(competitionService.deleteCompetitionByIds(ids));
+    }
+
+    /**
+     * 赛事发布
+     */
+    @RequiresPermissions("system:competition:publish")
+    @Log(title="赛事发布", businessType=BusinessType.UPDATE)
+    @PostMapping("/publish")
+    @ResponseBody
+    public AjaxResult publish(String id){
+       return toAjax(competitionService.publishCompetitionById(id));
+    }
+}

+ 12 - 0
qmjszx-admin/src/main/resources/static/ruoyi/js/ry-ui.js

@@ -1174,6 +1174,18 @@ var table = {
                     $.modal.open("修改" + table.options.modalName, $.operate.editUrl(id));
                 }
             },
+            publish: function(id, dataName){
+                table.set();
+                $.modal.confirm("确定发布该条" + dataName + "信息吗?<br/>发布后赛事信息无法修改!", function() {
+                    var url = $.common.isEmpty(id) ? table.options.publishUrl : table.options.publishUrl.replace("{id}", id);
+                    if (table.options.type == table_type.bootstrapTreeTable) {
+                        $.operate.get(url);
+                    } else {
+                        var data = { "id": id };
+                        $.operate.submit(url, "post", "json", data);
+                    }
+                });
+            },
             // 修改信息,以tab页展现
             editTab: function(id) {
                 table.set();

+ 175 - 0
qmjszx-admin/src/main/resources/templates/system/competition/add.html

@@ -0,0 +1,175 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<head>
+    <th:block th:include="include :: header('新增赛事发布')" />
+    <th:block th:include="include :: datetimepicker-css" />
+    <th:block th:include="include :: summernote-css" />
+</head>
+<body class="white-bg">
+    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
+        <form class="form-horizontal m" id="form-competition-add">
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动标题:</label>
+                    <div class="col-sm-8">
+                        <input name="competitionTitle" class="form-control" type="text" placeholder="请输入活动标题">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动类型:</label>
+                    <div class="col-sm-8">
+                        <select name="competitionType" class="form-control" th:with="type=${@dict.getType('competition_type')}">
+                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">团队最大人数:</label>
+                    <div class="col-sm-8">
+                        <input name="personMax" class="form-control" type="text" placeholder="请输入团队最大人数">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">最大团队数:</label>
+                    <div class="col-sm-8">
+                        <input name="teamMax" class="form-control" type="text"  placeholder="请输入最大团队数">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">场地:</label>
+                    <div class="col-sm-8">
+                        <input name="competitionPlace" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">报名开始时间:</label>
+                    <div class="col-sm-8">
+                        <div class="input-group date">
+                            <input name="applyStartTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text">
+                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">报名结束时间:</label>
+                    <div class="col-sm-8">
+                        <div class="input-group date">
+                            <input name="applyEndTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
+                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">取消报名截至时间(活动开始前N小时可退款):</label>
+                    <div class="col-sm-8">
+                        <input name="applyBeforeTime" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动费用(每人):</label>
+                    <div class="col-sm-8">
+                        <input name="competitionExpense" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动详情:</label>
+                    <div class="col-sm-8">
+                        <input type="hidden" class="form-control" name="competitionDetails">
+                        <div class="summernote" id="competitionDetails"></div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">报名须知:</label>
+                    <div class="col-sm-8">
+                        <input type="hidden" class="form-control" name="registrationNotes">
+                        <div class="summernote" id="registrationNotes"></div>
+                    </div>
+                </div>
+            </div>
+        </form>
+    </div>
+    <th:block th:include="include :: footer" />
+    <th:block th:include="include :: datetimepicker-js" />
+    <th:block th:include="include :: summernote-js" />
+    <script th:inline="javascript">
+        var prefix = ctx + "system/competition"
+        $("#form-competition-add").validate({
+            focusCleanup: true
+        });
+
+        function submitHandler() {
+            if ($.validate.form()) {
+                $.operate.save(prefix + "/add", $('#form-competition-add').serialize());
+            }
+        }
+
+        $("input[name='applyStartTime']").datetimepicker({
+            format: "yyyy-mm-dd",
+            minView: "month",
+            autoclose: true
+        });
+
+        $("input[name='applyEndTime']").datetimepicker({
+            format: "yyyy-mm-dd",
+            minView: "month",
+            autoclose: true
+        });
+
+        $(function() {
+            $('.summernote').summernote({
+                lang: 'zh-CN',
+                dialogsInBody: true,
+                callbacks: {
+                    onChange: function(contents, $edittable) {
+                        $("input[name='" + this.id + "']").val(contents);
+                    },
+                    onImageUpload: function(files) {
+                        var obj = this;
+                    	var data = new FormData();
+                    	data.append("file", files[0]);
+                    	$.ajax({
+                            type: "post",
+                            url: ctx + "common/upload",
+                    		data: data,
+                    		cache: false,
+                    		contentType: false,
+                    		processData: false,
+                    		dataType: 'json',
+                    		success: function(result) {
+                    		    if (result.code == web_status.SUCCESS) {
+                    		        $('#' + obj.id).summernote('insertImage', result.url);
+                    		    } else {
+                    		        $.modal.alertError(result.msg);
+                    		    }
+                    		},
+                    		error: function(error) {
+                    		    $.modal.alertWarning("图片上传失败。");
+                    		}
+                    	});
+                    }
+                }
+            });
+        });
+    </script>
+</body>
+</html>

+ 159 - 0
qmjszx-admin/src/main/resources/templates/system/competition/competition.html

@@ -0,0 +1,159 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
+<head>
+    <th:block th:include="include :: header('赛事发布列表')" />
+</head>
+<body class="gray-bg">
+     <div class="container-div">
+        <div class="row">
+            <div class="col-sm-12 search-collapse">
+                <form id="formId">
+                    <div class="select-list">
+                        <ul>
+                            <li>
+                                <label>活动标题:</label>
+                                <input type="text" name="competitionTitle" data-template="请输入活动标题"/>
+                            </li>
+                            <li>
+                                <label>活动类型:</label>
+                                <select name="competitionType" th:with="type=${@dict.getType('competition_type')}">
+                                    <option value="">所有</option>
+                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+                                </select>
+                            </li>
+                            <li>
+                                <label>场地:</label>
+                                <input type="text" name="competitionPlace" template="请输入场地"/>
+                            </li>
+                            <li>
+                                <label>活动状态:</label>
+                                <select name="competitionState" th:with="type=${@dict.getType('competition_state')}">
+                                    <option value="">所有</option>
+                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+                                </select>
+                            </li>
+                            <li>
+                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
+                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
+                            </li>
+                        </ul>
+                    </div>
+                </form>
+            </div>
+
+            <div class="btn-group-sm" id="toolbar" role="group">
+                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:competition:add">
+                    <i class="fa fa-plus"></i> 添加
+                </a>
+            </div>
+            <div class="col-sm-12 select-table table-striped">
+                <table id="bootstrap-table"></table>
+            </div>
+        </div>
+    </div>
+    <th:block th:include="include :: footer" />
+    <script th:inline="javascript">
+        var publisFlag=[[${@permission.hasPermi('system:competiton:publish')}]]
+        var editFlag = [[${@permission.hasPermi('system:competition:edit')}]];
+        var removeFlag = [[${@permission.hasPermi('system:competition:remove')}]];
+        var competitionTypeDatas = [[${@dict.getType('competition_type')}]];
+        var competitionStateDatas = [[${@dict.getType('competition_state')}]];
+        var prefix = ctx + "system/competition";
+
+        $(function() {
+            var options = {
+                url: prefix + "/list",
+                createUrl: prefix + "/add",
+                updateUrl: prefix + "/edit/{id}",
+                removeUrl: prefix + "/remove",
+                publishUrl: prefix + "/publish",
+                exportUrl: prefix + "/export",
+                modalName: "赛事发布",
+                columns: [{
+                    checkbox: true
+                },
+                {
+                    field: 'id',
+                    title: 'id',
+                    visible: false
+                },
+                {
+                    field: 'competitionTitle',
+                    title: '活动标题'
+                },
+                {
+                    field: 'competitionType',
+                    title: '活动类型',
+                    formatter: function(value, row, index) {
+                       return $.table.selectDictLabel(competitionTypeDatas, value);
+                    }
+                },
+                {
+                    field: 'personMax',
+                    title: '团队最大人数'
+                },
+                {
+                    field: 'teamMax',
+                    title: '最大团队数'
+                },
+                {
+                    field: 'competitionPlace',
+                    title: '场地'
+                },
+                {
+                    field: 'applyStartTime',
+                    title: '报名开始时间'
+                },
+                {
+                    field: 'applyEndTime',
+                    title: '报名结束时间'
+                },
+                {
+                    field: 'applyBeforeTime',
+                    title: '取消报名截至时间(活动开始前N小时可退款)'
+                },
+                {
+                    field: 'competitionMaximum',
+                    title: '活动上限人数'
+                },
+                {
+                    field: 'competitionExpense',
+                    title: '活动费用(每人)'
+                },
+                {
+                    field: 'competitionDetails',
+                    title: '活动详情'
+                },
+                {
+                    field: 'registrationNotes',
+                    title: '报名须知'
+                },
+                {
+                    field: 'competitionState',
+                    title: '活动状态',
+                    formatter: function(value, row, index) {
+                       return $.table.selectDictLabel(competitionStateDatas, value);
+                    }
+                },
+                {
+                    title: '操作',
+                    align: 'center',
+                    formatter: function(value, row, index) {
+                        var actions = [];
+                        if(row.competitionState === 'competiton_state_1'){
+                            actions.push('<a class="btn btn-success btn-xs ' + publisFlag + '" href="javascript:void(0)" onclick="$.operate.publish(\'' + row.id + '\', \'' + row.competitionTitle + '\')"><i class="fa fa-edit"></i>发布</a> ')
+                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
+                        }else{
+                            actions.push('<a class="btn btn-success btn-xs ' + publisFlag + '" href="javascript:void(0)" onclick="$.operate.close(\'' + row.id + '\')"><i class="fa fa-close"></i>关闭</a> ')
+                        }
+
+                        return actions.join('');
+                    }
+                }]
+            };
+            $.table.init(options);
+        });
+    </script>
+</body>
+</html>

+ 188 - 0
qmjszx-admin/src/main/resources/templates/system/competition/edit.html

@@ -0,0 +1,188 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<head>
+    <th:block th:include="include :: header('修改赛事发布')" />
+    <th:block th:include="include :: datetimepicker-css" />
+    <th:block th:include="include :: summernote-css" />
+</head>
+<body class="white-bg">
+    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
+        <form class="form-horizontal m" id="form-competition-edit" th:object="${competition}">
+            <input name="id" th:field="*{id}" type="hidden">
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动标题:</label>
+                    <div class="col-sm-8">
+                        <input name="competitionTitle" th:field="*{competitionTitle}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动类型:</label>
+                    <div class="col-sm-8">
+                        <select name="competitionType" class="form-control" th:with="type=${@dict.getType('competition_type')}">
+                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{competitionType}"></option>
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">团队最大人数:</label>
+                    <div class="col-sm-8">
+                        <input name="personMax" th:field="*{personMax}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">最大团队数:</label>
+                    <div class="col-sm-8">
+                        <input name="teamMax" th:field="*{teamMax}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">场地:</label>
+                    <div class="col-sm-8">
+                        <input name="competitionPlace" th:field="*{competitionPlace}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">报名开始时间:</label>
+                    <div class="col-sm-8">
+                        <div class="input-group date">
+                            <input name="applyStartTime" th:value="${#dates.format(competition.applyStartTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
+                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">报名结束时间:</label>
+                    <div class="col-sm-8">
+                        <div class="input-group date">
+                            <input name="applyEndTime" th:value="${#dates.format(competition.applyEndTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
+                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">取消报名截至时间(活动开始前N小时可退款):</label>
+                    <div class="col-sm-8">
+                        <input name="applyBeforeTime" th:field="*{applyBeforeTime}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动上限人数:</label>
+                    <div class="col-sm-8">
+                        <input name="competitionMaximum" th:field="*{competitionMaximum}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动费用(每人):</label>
+                    <div class="col-sm-8">
+                        <input name="competitionExpense" th:field="*{competitionExpense}" class="form-control" type="text">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">活动详情:</label>
+                    <div class="col-sm-8">
+                        <input type="hidden" class="form-control" th:field="*{competitionDetails}">
+                        <div class="summernote" id="competitionDetails"></div>
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-12">
+                <div class="form-group">
+                    <label class="col-sm-3 control-label">报名须知:</label>
+                    <div class="col-sm-8">
+                        <input type="hidden" class="form-control" th:field="*{registrationNotes}">
+                        <div class="summernote" id="registrationNotes"></div>
+                    </div>
+                </div>
+            </div>
+        </form>
+    </div>
+    <th:block th:include="include :: footer" />
+    <th:block th:include="include :: datetimepicker-js" />
+    <th:block th:include="include :: summernote-js" />
+    <script th:inline="javascript">
+        var prefix = ctx + "system/competition";
+        $("#form-competition-edit").validate({
+            focusCleanup: true
+        });
+
+        function submitHandler() {
+            if ($.validate.form()) {
+                $.operate.save(prefix + "/edit", $('#form-competition-edit').serialize());
+            }
+        }
+
+        $("input[name='applyStartTime']").datetimepicker({
+            format: "yyyy-mm-dd",
+            minView: "month",
+            autoclose: true
+        });
+
+        $("input[name='applyEndTime']").datetimepicker({
+            format: "yyyy-mm-dd",
+            minView: "month",
+            autoclose: true
+        });
+
+        $(function() {
+            $('.summernote').each(function(i) {
+                $('#' + this.id).summernote({
+                    lang: 'zh-CN',
+                    dialogsInBody: true,
+                    callbacks: {
+                        onChange: function(contents, $edittable) {
+                            $("input[name='" + this.id + "']").val(contents);
+                        },
+                        onImageUpload: function(files) {
+                            var obj = this;
+                            var data = new FormData();
+                            data.append("file", files[0]);
+                            $.ajax({
+                                type: "post",
+                                url: ctx + "common/upload",
+                                data: data,
+                                cache: false,
+                                contentType: false,
+                                processData: false,
+                                dataType: 'json',
+                                success: function(result) {
+                                    if (result.code == web_status.SUCCESS) {
+                                        $('#' + obj.id).summernote('insertImage', result.url);
+                                    } else {
+                                        $.modal.alertError(result.msg);
+                                    }
+                                },
+                                error: function(error) {
+                                    $.modal.alertWarning("图片上传失败。");
+                                }
+                            });
+                        }
+                    }
+                });
+                var content = $("input[name='" + this.id + "']").val();
+                $('#' + this.id).summernote('code', content);
+            })
+        });
+    </script>
+</body>
+</html>

+ 236 - 0
qmjszx-system/src/main/java/beilv/system/domain/Competition.java

@@ -0,0 +1,236 @@
+package beilv.system.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import beilv.common.annotation.Excel;
+import beilv.common.core.domain.BaseEntity;
+
+/**
+ * 赛事发布对象 competition
+ * 
+ * @author LG
+ * @date 2024-12-31
+ */
+public class Competition extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private Integer id;
+
+    /** 活动标题 */
+    @Excel(name = "活动标题")
+    private String competitionTitle;
+
+    /** 活动类型 */
+    @Excel(name = "活动类型")
+    private String competitionType;
+
+    /** 团队最大人数 */
+    @Excel(name = "团队最大人数")
+    private String personMax;
+
+    /** 最大团队数 */
+    @Excel(name = "最大团队数")
+    private String teamMax;
+
+    /** 场地 */
+    @Excel(name = "场地")
+    private String competitionPlace;
+
+    /** 报名开始时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @Excel(name = "报名开始时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date applyStartTime;
+
+    /** 报名结束时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @Excel(name = "报名结束时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date applyEndTime;
+
+    /** 取消报名截至时间(活动开始前N小时可退款) */
+    @Excel(name = "取消报名截至时间(活动开始前N小时可退款)")
+    private String applyBeforeTime;
+
+    /** 活动上限人数 */
+    @Excel(name = "活动上限人数")
+    private String competitionMaximum;
+
+    /** 活动费用(每人) */
+    @Excel(name = "活动费用(每人)")
+    private Long competitionExpense;
+
+    /** 活动详情 */
+    @Excel(name = "活动详情")
+    private String competitionDetails;
+
+    /** 报名须知 */
+    @Excel(name = "报名须知")
+    private String registrationNotes;
+
+    /** 活动状态 */
+    @Excel(name = "活动状态")
+    private String competitionState;
+
+    public void setId(Integer id) 
+    {
+        this.id = id;
+    }
+
+    public Integer getId() 
+    {
+        return id;
+    }
+
+    public void setCompetitionTitle(String competitionTitle) 
+    {
+        this.competitionTitle = competitionTitle;
+    }
+
+    public String getCompetitionTitle() 
+    {
+        return competitionTitle;
+    }
+
+    public void setCompetitionType(String competitionType) 
+    {
+        this.competitionType = competitionType;
+    }
+
+    public String getCompetitionType() 
+    {
+        return competitionType;
+    }
+
+    public void setPersonMax(String personMax) 
+    {
+        this.personMax = personMax;
+    }
+
+    public String getPersonMax() 
+    {
+        return personMax;
+    }
+
+    public void setTeamMax(String teamMax) 
+    {
+        this.teamMax = teamMax;
+    }
+
+    public String getTeamMax() 
+    {
+        return teamMax;
+    }
+
+    public void setCompetitionPlace(String competitionPlace) 
+    {
+        this.competitionPlace = competitionPlace;
+    }
+
+    public String getCompetitionPlace() 
+    {
+        return competitionPlace;
+    }
+
+    public void setApplyStartTime(Date applyStartTime) 
+    {
+        this.applyStartTime = applyStartTime;
+    }
+
+    public Date getApplyStartTime() 
+    {
+        return applyStartTime;
+    }
+
+    public void setApplyEndTime(Date applyEndTime) 
+    {
+        this.applyEndTime = applyEndTime;
+    }
+
+    public Date getApplyEndTime() 
+    {
+        return applyEndTime;
+    }
+
+    public void setApplyBeforeTime(String applyBeforeTime) 
+    {
+        this.applyBeforeTime = applyBeforeTime;
+    }
+
+    public String getApplyBeforeTime() 
+    {
+        return applyBeforeTime;
+    }
+
+    public void setCompetitionMaximum(String competitionMaximum) 
+    {
+        this.competitionMaximum = competitionMaximum;
+    }
+
+    public String getCompetitionMaximum() 
+    {
+        return competitionMaximum;
+    }
+
+    public void setCompetitionExpense(Long competitionExpense) 
+    {
+        this.competitionExpense = competitionExpense;
+    }
+
+    public Long getCompetitionExpense() 
+    {
+        return competitionExpense;
+    }
+
+    public void setCompetitionDetails(String competitionDetails) 
+    {
+        this.competitionDetails = competitionDetails;
+    }
+
+    public String getCompetitionDetails() 
+    {
+        return competitionDetails;
+    }
+
+    public void setRegistrationNotes(String registrationNotes) 
+    {
+        this.registrationNotes = registrationNotes;
+    }
+
+    public String getRegistrationNotes() 
+    {
+        return registrationNotes;
+    }
+
+    public void setCompetitionState(String competitionState) 
+    {
+        this.competitionState = competitionState;
+    }
+
+    public String getCompetitionState() 
+    {
+        return competitionState;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("competitionTitle", getCompetitionTitle())
+            .append("competitionType", getCompetitionType())
+            .append("personMax", getPersonMax())
+            .append("teamMax", getTeamMax())
+            .append("competitionPlace", getCompetitionPlace())
+            .append("applyStartTime", getApplyStartTime())
+            .append("applyEndTime", getApplyEndTime())
+            .append("applyBeforeTime", getApplyBeforeTime())
+            .append("competitionMaximum", getCompetitionMaximum())
+            .append("competitionExpense", getCompetitionExpense())
+            .append("competitionDetails", getCompetitionDetails())
+            .append("registrationNotes", getRegistrationNotes())
+            .append("competitionState", getCompetitionState())
+            .toString();
+    }
+}

+ 63 - 0
qmjszx-system/src/main/java/beilv/system/mapper/CompetitionMapper.java

@@ -0,0 +1,63 @@
+package beilv.system.mapper;
+
+import java.util.List;
+import beilv.system.domain.Competition;
+
+/**
+ * 赛事发布Mapper接口
+ * 
+ * @author LG
+ * @date 2024-12-31
+ */
+public interface CompetitionMapper 
+{
+    /**
+     * 查询赛事发布
+     * 
+     * @param id 赛事发布主键
+     * @return 赛事发布
+     */
+    public Competition selectCompetitionById(Integer id);
+
+    /**
+     * 查询赛事发布列表
+     * 
+     * @param competition 赛事发布
+     * @return 赛事发布集合
+     */
+    public List<Competition> selectCompetitionList(Competition competition);
+
+    /**
+     * 新增赛事发布
+     * 
+     * @param competition 赛事发布
+     * @return 结果
+     */
+    public int insertCompetition(Competition competition);
+
+    /**
+     * 修改赛事发布
+     * 
+     * @param competition 赛事发布
+     * @return 结果
+     */
+    public int updateCompetition(Competition competition);
+
+    /**
+     * 删除赛事发布
+     * 
+     * @param id 赛事发布主键
+     * @return 结果
+     */
+    public int deleteCompetitionById(Integer id);
+
+    /**
+     * 批量删除赛事发布
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteCompetitionByIds(String[] ids);
+
+    int publishCompetition(Competition competition);
+}

+ 63 - 0
qmjszx-system/src/main/java/beilv/system/service/ICompetitionService.java

@@ -0,0 +1,63 @@
+package beilv.system.service;
+
+import java.util.List;
+
+import beilv.system.domain.Competition;
+
+/**
+ * 赛事发布Service接口
+ *
+ * @author LG
+ * @date 2024-12-31
+ */
+public interface ICompetitionService {
+    /**
+     * 查询赛事发布
+     *
+     * @param id 赛事发布主键
+     * @return 赛事发布
+     */
+    public Competition selectCompetitionById(Integer id);
+
+    /**
+     * 查询赛事发布列表
+     *
+     * @param competition 赛事发布
+     * @return 赛事发布集合
+     */
+    public List<Competition> selectCompetitionList(Competition competition);
+
+    /**
+     * 新增赛事发布
+     *
+     * @param competition 赛事发布
+     * @return 结果
+     */
+    public int insertCompetition(Competition competition);
+
+    /**
+     * 修改赛事发布
+     *
+     * @param competition 赛事发布
+     * @return 结果
+     */
+    public int updateCompetition(Competition competition);
+
+    /**
+     * 批量删除赛事发布
+     *
+     * @param ids 需要删除的赛事发布主键集合
+     * @return 结果
+     */
+    public int deleteCompetitionByIds(String ids);
+
+    /**
+     * 删除赛事发布信息
+     *
+     * @param id 赛事发布主键
+     * @return 结果
+     */
+    public int deleteCompetitionById(Integer id);
+
+    int publishCompetitionById(String id);
+}

+ 103 - 0
qmjszx-system/src/main/java/beilv/system/service/impl/CompetitionServiceImpl.java

@@ -0,0 +1,103 @@
+package beilv.system.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import beilv.system.mapper.CompetitionMapper;
+import beilv.system.domain.Competition;
+import beilv.system.service.ICompetitionService;
+import beilv.common.core.text.Convert;
+
+/**
+ * 赛事发布Service业务层处理
+ *
+ * @author LG
+ * @date 2024-12-31
+ */
+@Service
+public class CompetitionServiceImpl implements ICompetitionService {
+    @Autowired
+    private CompetitionMapper competitionMapper;
+
+    private final static String DAI_FA_BU = "competiton_state_1";
+    private final static String BAO_MING_ZHONG = "competiton_state_2";
+    private final static String BAO_MING_JIE_SHU = "competiton_state_3";
+    private final static String YI_GUAN_BI = "competiton_state_4";
+
+    /**
+     * 查询赛事发布
+     *
+     * @param id 赛事发布主键
+     * @return 赛事发布
+     */
+    @Override
+    public Competition selectCompetitionById(Integer id) {
+        return competitionMapper.selectCompetitionById(id);
+    }
+
+    /**
+     * 查询赛事发布列表
+     *
+     * @param competition 赛事发布
+     * @return 赛事发布
+     */
+    @Override
+    public List<Competition> selectCompetitionList(Competition competition) {
+        return competitionMapper.selectCompetitionList(competition);
+    }
+
+    /**
+     * 新增赛事发布
+     *
+     * @param competition 赛事发布
+     * @return 结果
+     */
+    @Override
+    public int insertCompetition(Competition competition) {
+        competition.setCompetitionState(DAI_FA_BU);
+        competition.setCompetitionMaximum(String.valueOf(Integer.parseInt(competition.getPersonMax()) * Integer.parseInt(competition.getTeamMax())));
+        return competitionMapper.insertCompetition(competition);
+    }
+
+    /**
+     * 修改赛事发布
+     *
+     * @param competition 赛事发布
+     * @return 结果
+     */
+    @Override
+    public int updateCompetition(Competition competition) {
+        return competitionMapper.updateCompetition(competition);
+    }
+
+    /**
+     * 批量删除赛事发布
+     *
+     * @param ids 需要删除的赛事发布主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCompetitionByIds(String ids) {
+        return competitionMapper.deleteCompetitionByIds(Convert.toStrArray(ids));
+    }
+
+    /**
+     * 删除赛事发布信息
+     *
+     * @param id 赛事发布主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCompetitionById(Integer id) {
+        return competitionMapper.deleteCompetitionById(id);
+    }
+
+    @Override
+    public int publishCompetitionById(String id) {
+        Competition competition = new Competition();
+        competition.setId(Integer.valueOf(id));
+        competition.setCompetitionState(BAO_MING_ZHONG);
+        return competitionMapper.publishCompetition(competition);
+    }
+}

+ 114 - 0
qmjszx-system/src/main/resources/mapper/system/CompetitionMapper.xml

@@ -0,0 +1,114 @@
+<?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="beilv.system.mapper.CompetitionMapper">
+    
+    <resultMap type="Competition" id="CompetitionResult">
+        <result property="id"    column="id"    />
+        <result property="competitionTitle"    column="competition_title"    />
+        <result property="competitionType"    column="competition_type"    />
+        <result property="personMax"    column="person_max"    />
+        <result property="teamMax"    column="team_max"    />
+        <result property="competitionPlace"    column="competition_place"    />
+        <result property="applyStartTime"    column="apply_start_time"    />
+        <result property="applyEndTime"    column="apply_end_time"    />
+        <result property="applyBeforeTime"    column="apply_before_time"    />
+        <result property="competitionMaximum"    column="competition_maximum"    />
+        <result property="competitionExpense"    column="competition_expense"    />
+        <result property="competitionDetails"    column="competition_details"    />
+        <result property="registrationNotes"    column="registration_notes"    />
+        <result property="competitionState"    column="competition_state"    />
+    </resultMap>
+
+    <sql id="selectCompetitionVo">
+        select id, competition_title, competition_type, person_max, team_max, competition_place, apply_start_time, apply_end_time, apply_before_time, competition_maximum, competition_expense, competition_details, registration_notes, competition_state from competition
+    </sql>
+
+    <select id="selectCompetitionList" parameterType="Competition" resultMap="CompetitionResult">
+        <include refid="selectCompetitionVo"/>
+        <where>  
+            <if test="competitionTitle != null  and competitionTitle != ''"> and competition_title like concat('%', #{competitionTitle}, '%')</if>
+            <if test="competitionType != null  and competitionType != ''"> and competition_type = #{competitionType}</if>
+            <if test="competitionPlace != null  and competitionPlace != ''"> and competition_place like concat('%', #{competitionPlace}, '%')</if>
+            <if test="applyStartTime != null "> and apply_start_time = #{applyStartTime}</if>
+            <if test="competitionState != null  and competitionState != ''"> and competition_state = #{competitionState}</if>
+        </where>
+    </select>
+    
+    <select id="selectCompetitionById" parameterType="Integer" resultMap="CompetitionResult">
+        <include refid="selectCompetitionVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertCompetition" parameterType="Competition" useGeneratedKeys="true" keyProperty="id">
+        insert into competition
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="competitionTitle != null">competition_title,</if>
+            <if test="competitionType != null">competition_type,</if>
+            <if test="personMax != null">person_max,</if>
+            <if test="teamMax != null">team_max,</if>
+            <if test="competitionPlace != null">competition_place,</if>
+            <if test="applyStartTime != null">apply_start_time,</if>
+            <if test="applyEndTime != null">apply_end_time,</if>
+            <if test="applyBeforeTime != null">apply_before_time,</if>
+            <if test="competitionMaximum != null">competition_maximum,</if>
+            <if test="competitionExpense != null">competition_expense,</if>
+            <if test="competitionDetails != null">competition_details,</if>
+            <if test="registrationNotes != null">registration_notes,</if>
+            <if test="competitionState != null">competition_state,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="competitionTitle != null">#{competitionTitle},</if>
+            <if test="competitionType != null">#{competitionType},</if>
+            <if test="personMax != null">#{personMax},</if>
+            <if test="teamMax != null">#{teamMax},</if>
+            <if test="competitionPlace != null">#{competitionPlace},</if>
+            <if test="applyStartTime != null">#{applyStartTime},</if>
+            <if test="applyEndTime != null">#{applyEndTime},</if>
+            <if test="applyBeforeTime != null">#{applyBeforeTime},</if>
+            <if test="competitionMaximum != null">#{competitionMaximum},</if>
+            <if test="competitionExpense != null">#{competitionExpense},</if>
+            <if test="competitionDetails != null">#{competitionDetails},</if>
+            <if test="registrationNotes != null">#{registrationNotes},</if>
+            <if test="competitionState != null">#{competitionState},</if>
+         </trim>
+    </insert>
+
+    <update id="updateCompetition" parameterType="Competition">
+        update competition
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="competitionTitle != null">competition_title = #{competitionTitle},</if>
+            <if test="competitionType != null">competition_type = #{competitionType},</if>
+            <if test="personMax != null">person_max = #{personMax},</if>
+            <if test="teamMax != null">team_max = #{teamMax},</if>
+            <if test="competitionPlace != null">competition_place = #{competitionPlace},</if>
+            <if test="applyStartTime != null">apply_start_time = #{applyStartTime},</if>
+            <if test="applyEndTime != null">apply_end_time = #{applyEndTime},</if>
+            <if test="applyBeforeTime != null">apply_before_time = #{applyBeforeTime},</if>
+            <if test="competitionMaximum != null">competition_maximum = #{competitionMaximum},</if>
+            <if test="competitionExpense != null">competition_expense = #{competitionExpense},</if>
+            <if test="competitionDetails != null">competition_details = #{competitionDetails},</if>
+            <if test="registrationNotes != null">registration_notes = #{registrationNotes},</if>
+            <if test="competitionState != null">competition_state = #{competitionState},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteCompetitionById" parameterType="Integer">
+        delete from competition where id = #{id}
+    </delete>
+
+    <delete id="deleteCompetitionByIds" parameterType="String">
+        delete from competition where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <update id="publishCompetition" parameterType="Competition">
+        update competition set competition_state = #{competitionState}
+        where id = #{id}
+    </update>
+
+</mapper>