Explorar el Código

创建 table sim_add_on_user 相关。

tom hace 5 meses
padre
commit
1ee177e3bd

+ 35 - 0
pla-sim/01_SQL/02_table/sim_add_on_user.sql

@@ -0,0 +1,35 @@
+/*
+ Navicat Premium Dump SQL
+
+ Source Server         : qdhome.iot321.top
+ Source Server Type    : MySQL
+ Source Server Version : 50740 (5.7.40-log)
+ Source Host           : qdhome.iot321.top:33003
+ Source Schema         : pla-chem-sim-dev-1
+
+ Target Server Type    : MySQL
+ Target Server Version : 50740 (5.7.40-log)
+ File Encoding         : 65001
+
+ Date: 11/12/2024 00:40:48
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for sim_add_on_user
+-- ----------------------------
+DROP TABLE IF EXISTS `sim_add_on_user`;
+CREATE TABLE `sim_add_on_user`  (
+  `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+  `major_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '专业ID',
+  `createBy` 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 (`user_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/AddOnUserController.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.AddOnUser;
+import com.ruoyi.sim.service.IAddOnUserService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 用户附加Controller
+ *
+ * @author tom
+ * @date 2024-12-11
+ */
+@RestController
+@RequestMapping("/sim/add_on_user")
+public class AddOnUserController extends BaseController {
+    @Autowired
+    private IAddOnUserService addOnUserService;
+
+    /**
+     * 查询用户附加列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:add_on_user:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(AddOnUser addOnUser) {
+        startPage();
+        List<AddOnUser> list = addOnUserService.selectAddOnUserList(addOnUser);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出用户附加列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:add_on_user:export')")
+    @Log(title = "用户附加", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, AddOnUser addOnUser) {
+        List<AddOnUser> list = addOnUserService.selectAddOnUserList(addOnUser);
+        ExcelUtil<AddOnUser> util = new ExcelUtil<AddOnUser>(AddOnUser.class);
+        util.exportExcel(response, list, "用户附加数据");
+    }
+
+    /**
+     * 获取用户附加详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('sim:add_on_user:query')")
+    @GetMapping(value = "/{userId}")
+    public AjaxResult getInfo(@PathVariable("userId") Long userId) {
+        return success(addOnUserService.selectAddOnUserByUserId(userId));
+    }
+
+    /**
+     * 新增用户附加
+     */
+    @PreAuthorize("@ss.hasPermi('sim:add_on_user:add')")
+    @Log(title = "用户附加", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody AddOnUser addOnUser) {
+        return toAjax(addOnUserService.insertAddOnUser(addOnUser));
+    }
+
+    /**
+     * 修改用户附加
+     */
+    @PreAuthorize("@ss.hasPermi('sim:add_on_user:edit')")
+    @Log(title = "用户附加", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody AddOnUser addOnUser) {
+        return toAjax(addOnUserService.updateAddOnUser(addOnUser));
+    }
+
+    /**
+     * 删除用户附加
+     */
+    @PreAuthorize("@ss.hasPermi('sim:add_on_user:remove')")
+    @Log(title = "用户附加", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{userIds}")
+    public AjaxResult remove(@PathVariable Long[] userIds) {
+        return toAjax(addOnUserService.deleteAddOnUserByUserIds(userIds));
+    }
+}

+ 56 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/AddOnUser.java

@@ -0,0 +1,56 @@
+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_add_on_user
+ *
+ * @author tom
+ * @date 2024-12-11
+ */
+public class AddOnUser extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 专业ID
+     */
+    @Excel(name = "专业ID")
+    private Long majorId;
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setMajorId(Long majorId) {
+        this.majorId = majorId;
+    }
+
+    public Long getMajorId() {
+        return majorId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("userId", getUserId())
+                .append("majorId", getMajorId())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
+    }
+}

+ 61 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/mapper/AddOnUserMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.mapper;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.AddOnUser;
+
+/**
+ * 用户附加Mapper接口
+ *
+ * @author tom
+ * @date 2024-12-11
+ */
+public interface AddOnUserMapper {
+    /**
+     * 查询用户附加
+     *
+     * @param userId 用户附加主键
+     * @return 用户附加
+     */
+    public AddOnUser selectAddOnUserByUserId(Long userId);
+
+    /**
+     * 查询用户附加列表
+     *
+     * @param addOnUser 用户附加
+     * @return 用户附加集合
+     */
+    public List<AddOnUser> selectAddOnUserList(AddOnUser addOnUser);
+
+    /**
+     * 新增用户附加
+     *
+     * @param addOnUser 用户附加
+     * @return 结果
+     */
+    public int insertAddOnUser(AddOnUser addOnUser);
+
+    /**
+     * 修改用户附加
+     *
+     * @param addOnUser 用户附加
+     * @return 结果
+     */
+    public int updateAddOnUser(AddOnUser addOnUser);
+
+    /**
+     * 删除用户附加
+     *
+     * @param userId 用户附加主键
+     * @return 结果
+     */
+    public int deleteAddOnUserByUserId(Long userId);
+
+    /**
+     * 批量删除用户附加
+     *
+     * @param userIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteAddOnUserByUserIds(Long[] userIds);
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.service;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.AddOnUser;
+
+/**
+ * 用户附加Service接口
+ *
+ * @author tom
+ * @date 2024-12-11
+ */
+public interface IAddOnUserService {
+    /**
+     * 查询用户附加
+     *
+     * @param userId 用户附加主键
+     * @return 用户附加
+     */
+    public AddOnUser selectAddOnUserByUserId(Long userId);
+
+    /**
+     * 查询用户附加列表
+     *
+     * @param addOnUser 用户附加
+     * @return 用户附加集合
+     */
+    public List<AddOnUser> selectAddOnUserList(AddOnUser addOnUser);
+
+    /**
+     * 新增用户附加
+     *
+     * @param addOnUser 用户附加
+     * @return 结果
+     */
+    public int insertAddOnUser(AddOnUser addOnUser);
+
+    /**
+     * 修改用户附加
+     *
+     * @param addOnUser 用户附加
+     * @return 结果
+     */
+    public int updateAddOnUser(AddOnUser addOnUser);
+
+    /**
+     * 批量删除用户附加
+     *
+     * @param userIds 需要删除的用户附加主键集合
+     * @return 结果
+     */
+    public int deleteAddOnUserByUserIds(Long[] userIds);
+
+    /**
+     * 删除用户附加信息
+     *
+     * @param userId 用户附加主键
+     * @return 结果
+     */
+    public int deleteAddOnUserByUserId(Long userId);
+}

+ 90 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/AddOnUserServiceImpl.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.AddOnUserMapper;
+import com.ruoyi.sim.domain.AddOnUser;
+import com.ruoyi.sim.service.IAddOnUserService;
+
+/**
+ * 用户附加Service业务层处理
+ *
+ * @author tom
+ * @date 2024-12-11
+ */
+@Service
+public class AddOnUserServiceImpl implements IAddOnUserService {
+    @Autowired
+    private AddOnUserMapper addOnUserMapper;
+
+    /**
+     * 查询用户附加
+     *
+     * @param userId 用户附加主键
+     * @return 用户附加
+     */
+    @Override
+    public AddOnUser selectAddOnUserByUserId(Long userId) {
+        return addOnUserMapper.selectAddOnUserByUserId(userId);
+    }
+
+    /**
+     * 查询用户附加列表
+     *
+     * @param addOnUser 用户附加
+     * @return 用户附加
+     */
+    @Override
+    public List<AddOnUser> selectAddOnUserList(AddOnUser addOnUser) {
+        return addOnUserMapper.selectAddOnUserList(addOnUser);
+    }
+
+    /**
+     * 新增用户附加
+     *
+     * @param addOnUser 用户附加
+     * @return 结果
+     */
+    @Override
+    public int insertAddOnUser(AddOnUser addOnUser) {
+        addOnUser.setCreateTime(DateUtils.getNowDate());
+        return addOnUserMapper.insertAddOnUser(addOnUser);
+    }
+
+    /**
+     * 修改用户附加
+     *
+     * @param addOnUser 用户附加
+     * @return 结果
+     */
+    @Override
+    public int updateAddOnUser(AddOnUser addOnUser) {
+        addOnUser.setUpdateTime(DateUtils.getNowDate());
+        return addOnUserMapper.updateAddOnUser(addOnUser);
+    }
+
+    /**
+     * 批量删除用户附加
+     *
+     * @param userIds 需要删除的用户附加主键
+     * @return 结果
+     */
+    @Override
+    public int deleteAddOnUserByUserIds(Long[] userIds) {
+        return addOnUserMapper.deleteAddOnUserByUserIds(userIds);
+    }
+
+    /**
+     * 删除用户附加信息
+     *
+     * @param userId 用户附加主键
+     * @return 结果
+     */
+    @Override
+    public int deleteAddOnUserByUserId(Long userId) {
+        return addOnUserMapper.deleteAddOnUserByUserId(userId);
+    }
+}

+ 80 - 0
ruoyi-sim/src/main/resources/mapper/sim/AddOnUserMapper.xml

@@ -0,0 +1,80 @@
+<?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.AddOnUserMapper">
+
+    <resultMap type="AddOnUser" id="AddOnUserResult">
+        <result property="userId" column="user_id"/>
+        <result property="majorId" column="major_id"/>
+        <result property="createBy" column="createBy"/>
+        <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="selectAddOnUserVo">
+        select user_id, major_id, createBy, create_time, update_by, update_time, remark
+        from sim_add_on_user
+    </sql>
+
+    <select id="selectAddOnUserList" parameterType="AddOnUser" resultMap="AddOnUserResult">
+        <include refid="selectAddOnUserVo"/>
+        <where>
+            <if test="majorId != null ">and major_id = #{majorId}</if>
+            <if test="createBy != null  and createBy != ''">and createBy = #{createBy}</if>
+        </where>
+    </select>
+
+    <select id="selectAddOnUserByUserId" parameterType="Long" resultMap="AddOnUserResult">
+        <include refid="selectAddOnUserVo"/>
+        where user_id = #{userId}
+    </select>
+
+    <insert id="insertAddOnUser" parameterType="AddOnUser" useGeneratedKeys="true" keyProperty="userId">
+        insert into sim_add_on_user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="majorId != null">major_id,</if>
+            <if test="createBy != null">createBy,</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="majorId != null">#{majorId},</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="updateAddOnUser" parameterType="AddOnUser">
+        update sim_add_on_user
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="majorId != null">major_id = #{majorId},</if>
+            <if test="createBy != null">createBy = #{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 user_id = #{userId}
+    </update>
+
+    <delete id="deleteAddOnUserByUserId" parameterType="Long">
+        delete
+        from sim_add_on_user
+        where user_id = #{userId}
+    </delete>
+
+    <delete id="deleteAddOnUserByUserIds" parameterType="String">
+        delete from sim_add_on_user where user_id in
+        <foreach item="userId" collection="array" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+    </delete>
+</mapper>