Browse Source

添加 Seat 相关。

tom 9 months ago
parent
commit
49e08d91bf

+ 37 - 0
pla-sim/01_SQL/02_table/sim_seat.sql

@@ -0,0 +1,37 @@
+/*
+ Navicat Premium Dump SQL
+
+ Source Server         : qdhome.iot321.top-dev
+ Source Server Type    : MySQL
+ Source Server Version : 50740 (5.7.40-log)
+ Source Host           : qdhome.iot321.top:33103
+ Source Schema         : pla-chem-sim-dev-1
+
+ Target Server Type    : MySQL
+ Target Server Version : 50740 (5.7.40-log)
+ File Encoding         : 65001
+
+ Date: 13/12/2024 18:21:38
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for sim_seat
+-- ----------------------------
+DROP TABLE IF EXISTS `sim_seat`;
+CREATE TABLE `sim_seat`  (
+  `seat_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '座ID',
+  `seat_num` int(4) NOT NULL DEFAULT 0 COMMENT '座号',
+  `seat_bind_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '绑定的IP地址',
+  `current_user_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '当前座上学员/用户ID',
+  `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
+  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
+  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
+  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`seat_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-座表' ROW_FORMAT = DYNAMIC;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 98 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/SeatController.java

@@ -0,0 +1,98 @@
+package com.ruoyi.sim.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.sim.domain.Seat;
+import com.ruoyi.sim.service.ISeatService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 座Controller
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@RestController
+@RequestMapping("/sim/seat")
+public class SeatController extends BaseController {
+    @Autowired
+    private ISeatService seatService;
+
+    /**
+     * 查询座列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:seat:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Seat seat) {
+        startPage();
+        List<Seat> list = seatService.selectSeatList(seat);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出座列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:seat:export')")
+    @Log(title = "座", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Seat seat) {
+        List<Seat> list = seatService.selectSeatList(seat);
+        ExcelUtil<Seat> util = new ExcelUtil<Seat>(Seat.class);
+        util.exportExcel(response, list, "座数据");
+    }
+
+    /**
+     * 获取座详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('sim:seat:query')")
+    @GetMapping(value = "/{seatId}")
+    public AjaxResult getInfo(@PathVariable("seatId") Long seatId) {
+        return success(seatService.selectSeatBySeatId(seatId));
+    }
+
+    /**
+     * 新增座
+     */
+    @PreAuthorize("@ss.hasPermi('sim:seat:add')")
+    @Log(title = "座", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Seat seat) {
+        return toAjax(seatService.insertSeat(seat));
+    }
+
+    /**
+     * 修改座
+     */
+    @PreAuthorize("@ss.hasPermi('sim:seat:edit')")
+    @Log(title = "座", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Seat seat) {
+        return toAjax(seatService.updateSeat(seat));
+    }
+
+    /**
+     * 删除座
+     */
+    @PreAuthorize("@ss.hasPermi('sim:seat:remove')")
+    @Log(title = "座", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{seatIds}")
+    public AjaxResult remove(@PathVariable Long[] seatIds) {
+        return toAjax(seatService.deleteSeatBySeatIds(seatIds));
+    }
+}

+ 86 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/Seat.java

@@ -0,0 +1,86 @@
+package com.ruoyi.sim.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 座对象 sim_seat
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public class Seat extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 座ID
+     */
+    private Long seatId;
+
+    /**
+     * 座号
+     */
+    @Excel(name = "座号")
+    private Integer seatNum;
+
+    /**
+     * 绑定的IP地址
+     */
+    @Excel(name = "绑定的IP地址")
+    private String seatBindIp;
+
+    /**
+     * 当前座上学员/用户ID
+     */
+    @Excel(name = "当前座上学员/用户ID")
+    private Long currentUserId;
+
+    public void setSeatId(Long seatId) {
+        this.seatId = seatId;
+    }
+
+    public Long getSeatId() {
+        return seatId;
+    }
+
+    public void setSeatNum(Integer seatNum) {
+        this.seatNum = seatNum;
+    }
+
+    public Integer getSeatNum() {
+        return seatNum;
+    }
+
+    public void setSeatBindIp(String seatBindIp) {
+        this.seatBindIp = seatBindIp;
+    }
+
+    public String getSeatBindIp() {
+        return seatBindIp;
+    }
+
+    public void setCurrentUserId(Long currentUserId) {
+        this.currentUserId = currentUserId;
+    }
+
+    public Long getCurrentUserId() {
+        return currentUserId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("seatId", getSeatId())
+                .append("seatNum", getSeatNum())
+                .append("seatBindIp", getSeatBindIp())
+                .append("currentUserId", getCurrentUserId())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
+    }
+}

+ 62 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/mapper/SeatMapper.java

@@ -0,0 +1,62 @@
+package com.ruoyi.sim.mapper;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Seat;
+
+/**
+ * 座Mapper接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface SeatMapper {
+    /**
+     * 查询座
+     *
+     * @param seatId 座主键
+     * @return 座
+     */
+    public Seat selectSeatBySeatId(Long seatId);
+
+    /**
+     * 查询座列表
+     *
+     * @param seat 座
+     * @return 座集合
+     */
+    public List<Seat> selectSeatList(Seat seat);
+
+    /**
+     * 新增座
+     *
+     * @param seat 座
+     * @return 结果
+     */
+    public int insertSeat(Seat seat);
+
+    /**
+     * 修改座
+     *
+     * @param seat 座
+     * @return 结果
+     */
+    public int updateSeat(Seat seat);
+
+    /**
+     * 删除座
+     *
+     * @param seatId 座主键
+     * @return 结果
+     */
+    public int deleteSeatBySeatId(Long seatId);
+
+    /**
+     * 批量删除座
+     *
+     * @param seatIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteSeatBySeatIds(Long[] seatIds);
+}
+

+ 61 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/ISeatService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.service;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Seat;
+
+/**
+ * 座Service接口
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+public interface ISeatService {
+    /**
+     * 查询座
+     *
+     * @param seatId 座主键
+     * @return 座
+     */
+    public Seat selectSeatBySeatId(Long seatId);
+
+    /**
+     * 查询座列表
+     *
+     * @param seat 座
+     * @return 座集合
+     */
+    public List<Seat> selectSeatList(Seat seat);
+
+    /**
+     * 新增座
+     *
+     * @param seat 座
+     * @return 结果
+     */
+    public int insertSeat(Seat seat);
+
+    /**
+     * 修改座
+     *
+     * @param seat 座
+     * @return 结果
+     */
+    public int updateSeat(Seat seat);
+
+    /**
+     * 批量删除座
+     *
+     * @param seatIds 需要删除的座主键集合
+     * @return 结果
+     */
+    public int deleteSeatBySeatIds(Long[] seatIds);
+
+    /**
+     * 删除座信息
+     *
+     * @param seatId 座主键
+     * @return 结果
+     */
+    public int deleteSeatBySeatId(Long seatId);
+}

+ 90 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/SeatServiceImpl.java

@@ -0,0 +1,90 @@
+package com.ruoyi.sim.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.sim.mapper.SeatMapper;
+import com.ruoyi.sim.domain.Seat;
+import com.ruoyi.sim.service.ISeatService;
+
+/**
+ * 座Service业务层处理
+ *
+ * @author tom
+ * @date 2024-12-13
+ */
+@Service
+public class SeatServiceImpl implements ISeatService {
+    @Autowired
+    private SeatMapper seatMapper;
+
+    /**
+     * 查询座
+     *
+     * @param seatId 座主键
+     * @return 座
+     */
+    @Override
+    public Seat selectSeatBySeatId(Long seatId) {
+        return seatMapper.selectSeatBySeatId(seatId);
+    }
+
+    /**
+     * 查询座列表
+     *
+     * @param seat 座
+     * @return 座
+     */
+    @Override
+    public List<Seat> selectSeatList(Seat seat) {
+        return seatMapper.selectSeatList(seat);
+    }
+
+    /**
+     * 新增座
+     *
+     * @param seat 座
+     * @return 结果
+     */
+    @Override
+    public int insertSeat(Seat seat) {
+        seat.setCreateTime(DateUtils.getNowDate());
+        return seatMapper.insertSeat(seat);
+    }
+
+    /**
+     * 修改座
+     *
+     * @param seat 座
+     * @return 结果
+     */
+    @Override
+    public int updateSeat(Seat seat) {
+        seat.setUpdateTime(DateUtils.getNowDate());
+        return seatMapper.updateSeat(seat);
+    }
+
+    /**
+     * 批量删除座
+     *
+     * @param seatIds 需要删除的座主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSeatBySeatIds(Long[] seatIds) {
+        return seatMapper.deleteSeatBySeatIds(seatIds);
+    }
+
+    /**
+     * 删除座信息
+     *
+     * @param seatId 座主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSeatBySeatId(Long seatId) {
+        return seatMapper.deleteSeatBySeatId(seatId);
+    }
+}

+ 97 - 0
ruoyi-sim/src/main/resources/mapper/sim/SeatMapper.xml

@@ -0,0 +1,97 @@
+<?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.ruoyi.sim.mapper.SeatMapper">
+
+    <resultMap type="Seat" id="SeatResult">
+        <result property="seatId" column="seat_id"/>
+        <result property="seatNum" column="seat_num"/>
+        <result property="seatBindIp" column="seat_bind_ip"/>
+        <result property="currentUserId" column="current_user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <sql id="selectSeatVo">
+        select seat_id,
+               seat_num,
+               seat_bind_ip,
+               current_user_id,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from sim_seat
+    </sql>
+
+    <select id="selectSeatList" parameterType="Seat" resultMap="SeatResult">
+        <include refid="selectSeatVo"/>
+        <where>
+            <if test="seatNum != null ">and seat_num = #{seatNum}</if>
+            <if test="seatBindIp != null  and seatBindIp != ''">and seat_bind_ip = #{seatBindIp}</if>
+            <if test="currentUserId != null ">and current_user_id = #{currentUserId}</if>
+        </where>
+    </select>
+
+    <select id="selectSeatBySeatId" parameterType="Long" resultMap="SeatResult">
+        <include refid="selectSeatVo"/>
+        where seat_id = #{seatId}
+    </select>
+
+    <insert id="insertSeat" parameterType="Seat" useGeneratedKeys="true" keyProperty="seatId">
+        insert into sim_seat
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="seatNum != null">seat_num,</if>
+            <if test="seatBindIp != null and seatBindIp != ''">seat_bind_ip,</if>
+            <if test="currentUserId != null">current_user_id,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="seatNum != null">#{seatNum},</if>
+            <if test="seatBindIp != null and seatBindIp != ''">#{seatBindIp},</if>
+            <if test="currentUserId != null">#{currentUserId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSeat" parameterType="Seat">
+        update sim_seat
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="seatNum != null">seat_num = #{seatNum},</if>
+            <if test="seatBindIp != null and seatBindIp != ''">seat_bind_ip = #{seatBindIp},</if>
+            <if test="currentUserId != null">current_user_id = #{currentUserId},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where seat_id = #{seatId}
+    </update>
+
+    <delete id="deleteSeatBySeatId" parameterType="Long">
+        delete
+        from sim_seat
+        where seat_id = #{seatId}
+    </delete>
+
+    <delete id="deleteSeatBySeatIds" parameterType="String">
+        delete from sim_seat where seat_id in
+        <foreach item="seatId" collection="array" open="(" separator="," close=")">
+            #{seatId}
+        </foreach>
+    </delete>
+</mapper>