Quellcode durchsuchen

major 基本CURD实现。

tom vor 5 Monaten
Ursprung
Commit
ad91ecd52b

+ 31 - 0
pla-sim/01_SQL/02_table/sim_major.sql

@@ -0,0 +1,31 @@
+/*
+ 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: 10/12/2024 23:48:40
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for sim_major
+-- ----------------------------
+DROP TABLE IF EXISTS `sim_major`;
+CREATE TABLE `sim_major`  (
+  `major_id` bigint(20) NOT NULL DEFAULT 0 AUTO_INCREMENT COMMENT '专业ID',
+  `major_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '专业名称',
+  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`major_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-专业表' ROW_FORMAT = DYNAMIC;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 106 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/sim/MajorController.java

@@ -0,0 +1,106 @@
+package com.ruoyi.web.controller.sim;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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.Major;
+import com.ruoyi.sim.service.IMajorService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * sim-专业Controller
+ *
+ * @author tom
+ * @date 2024-12-10
+ */
+@Api("专业管理")
+@RestController
+@RequestMapping("/sim/major")
+public class MajorController extends BaseController {
+    @Autowired
+    private IMajorService majorService;
+
+    /**
+     * 查询sim-专业列表
+     */
+    @ApiOperation("查询sim-专业列表")
+    // @PreAuthorize("@ss.hasPermi('sim:major:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Major major) {
+        startPage();
+        List<Major> list = majorService.selectMajorList(major);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出sim-专业列表
+     */
+    @PreAuthorize("@ss.hasPermi('sim:major:export')")
+    @Log(title = "sim-专业", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Major major) {
+        List<Major> list = majorService.selectMajorList(major);
+        ExcelUtil<Major> util = new ExcelUtil<Major>(Major.class);
+        util.exportExcel(response, list, "sim-专业数据");
+    }
+
+    /**
+     * 获取sim-专业详细信息
+     */
+    @ApiOperation("获取sim-专业详细信息")
+    // @PreAuthorize("@ss.hasPermi('sim:major:query')")
+    @GetMapping(value = "/{majorId}")
+    public AjaxResult getInfo(@PathVariable("majorId") Long majorId) {
+        return success(majorService.selectMajorByMajorId(majorId));
+    }
+
+    /**
+     * 新增sim-专业
+     */
+    @ApiOperation("新增sim-专业")
+    // @PreAuthorize("@ss.hasPermi('sim:major:add')")
+    @Log(title = "sim-专业", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Major major) {
+        return toAjax(majorService.insertMajor(major));
+    }
+
+    /**
+     * 修改sim-专业
+     */
+    @ApiOperation("修改sim-专业")
+    // @PreAuthorize("@ss.hasPermi('sim:major:edit')")
+    @Log(title = "sim-专业", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Major major) {
+        return toAjax(majorService.updateMajor(major));
+    }
+
+    /**
+     * 删除sim-专业
+     */
+    @ApiOperation("删除sim-专业")
+    // @PreAuthorize("@ss.hasPermi('sim:major:remove')")
+    @Log(title = "sim-专业", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{majorIds}")
+    public AjaxResult remove(@PathVariable Long[] majorIds) {
+        return toAjax(majorService.deleteMajorByMajorIds(majorIds));
+    }
+}

+ 52 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/Major.java

@@ -0,0 +1,52 @@
+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-专业对象 sim_major
+ *
+ * @author tom
+ * @date 2024-12-10
+ */
+public class Major extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 专业ID
+     */
+    private Long majorId;
+
+    /**
+     * 专业名称
+     */
+    @Excel(name = "专业名称")
+    private String majorName;
+
+    public void setMajorId(Long majorId) {
+        this.majorId = majorId;
+    }
+
+    public Long getMajorId() {
+        return majorId;
+    }
+
+    public void setMajorName(String majorName) {
+        this.majorName = majorName;
+    }
+
+    public String getMajorName() {
+        return majorName;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("majorId", getMajorId())
+                .append("majorName", getMajorName())
+                .append("remark", getRemark())
+                .toString();
+    }
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.mapper;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Major;
+
+/**
+ * sim-专业Mapper接口
+ *
+ * @author tom
+ * @date 2024-12-10
+ */
+public interface MajorMapper {
+    /**
+     * 查询sim-专业
+     *
+     * @param majorId sim-专业主键
+     * @return sim-专业
+     */
+    public Major selectMajorByMajorId(Long majorId);
+
+    /**
+     * 查询sim-专业列表
+     *
+     * @param major sim-专业
+     * @return sim-专业集合
+     */
+    public List<Major> selectMajorList(Major major);
+
+    /**
+     * 新增sim-专业
+     *
+     * @param major sim-专业
+     * @return 结果
+     */
+    public int insertMajor(Major major);
+
+    /**
+     * 修改sim-专业
+     *
+     * @param major sim-专业
+     * @return 结果
+     */
+    public int updateMajor(Major major);
+
+    /**
+     * 删除sim-专业
+     *
+     * @param majorId sim-专业主键
+     * @return 结果
+     */
+    public int deleteMajorByMajorId(Long majorId);
+
+    /**
+     * 批量删除sim-专业
+     *
+     * @param majorIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteMajorByMajorIds(Long[] majorIds);
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.sim.service;
+
+import java.util.List;
+
+import com.ruoyi.sim.domain.Major;
+
+/**
+ * sim-专业Service接口
+ *
+ * @author tom
+ * @date 2024-12-10
+ */
+public interface IMajorService {
+    /**
+     * 查询sim-专业
+     *
+     * @param majorId sim-专业主键
+     * @return sim-专业
+     */
+    public Major selectMajorByMajorId(Long majorId);
+
+    /**
+     * 查询sim-专业列表
+     *
+     * @param major sim-专业
+     * @return sim-专业集合
+     */
+    public List<Major> selectMajorList(Major major);
+
+    /**
+     * 新增sim-专业
+     *
+     * @param major sim-专业
+     * @return 结果
+     */
+    public int insertMajor(Major major);
+
+    /**
+     * 修改sim-专业
+     *
+     * @param major sim-专业
+     * @return 结果
+     */
+    public int updateMajor(Major major);
+
+    /**
+     * 批量删除sim-专业
+     *
+     * @param majorIds 需要删除的sim-专业主键集合
+     * @return 结果
+     */
+    public int deleteMajorByMajorIds(Long[] majorIds);
+
+    /**
+     * 删除sim-专业信息
+     *
+     * @param majorId sim-专业主键
+     * @return 结果
+     */
+    public int deleteMajorByMajorId(Long majorId);
+}

+ 87 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/MajorServiceImpl.java

@@ -0,0 +1,87 @@
+package com.ruoyi.sim.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.sim.mapper.MajorMapper;
+import com.ruoyi.sim.domain.Major;
+import com.ruoyi.sim.service.IMajorService;
+
+/**
+ * sim-专业Service业务层处理
+ *
+ * @author tom
+ * @date 2024-12-10
+ */
+@Service
+public class MajorServiceImpl implements IMajorService {
+    @Autowired
+    private MajorMapper majorMapper;
+
+    /**
+     * 查询sim-专业
+     *
+     * @param majorId sim-专业主键
+     * @return sim-专业
+     */
+    @Override
+    public Major selectMajorByMajorId(Long majorId) {
+        return majorMapper.selectMajorByMajorId(majorId);
+    }
+
+    /**
+     * 查询sim-专业列表
+     *
+     * @param major sim-专业
+     * @return sim-专业
+     */
+    @Override
+    public List<Major> selectMajorList(Major major) {
+        return majorMapper.selectMajorList(major);
+    }
+
+    /**
+     * 新增sim-专业
+     *
+     * @param major sim-专业
+     * @return 结果
+     */
+    @Override
+    public int insertMajor(Major major) {
+        return majorMapper.insertMajor(major);
+    }
+
+    /**
+     * 修改sim-专业
+     *
+     * @param major sim-专业
+     * @return 结果
+     */
+    @Override
+    public int updateMajor(Major major) {
+        return majorMapper.updateMajor(major);
+    }
+
+    /**
+     * 批量删除sim-专业
+     *
+     * @param majorIds 需要删除的sim-专业主键
+     * @return 结果
+     */
+    @Override
+    public int deleteMajorByMajorIds(Long[] majorIds) {
+        return majorMapper.deleteMajorByMajorIds(majorIds);
+    }
+
+    /**
+     * 删除sim-专业信息
+     *
+     * @param majorId sim-专业主键
+     * @return 结果
+     */
+    @Override
+    public int deleteMajorByMajorId(Long majorId) {
+        return majorMapper.deleteMajorByMajorId(majorId);
+    }
+}

+ 63 - 0
ruoyi-sim/src/main/resources/mapper/sim/MajorMapper.xml

@@ -0,0 +1,63 @@
+<?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.MajorMapper">
+
+    <resultMap type="Major" id="MajorResult">
+        <result property="majorId" column="major_id"/>
+        <result property="majorName" column="major_name"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <sql id="selectMajorVo">
+        select major_id, major_name, remark
+        from sim_major
+    </sql>
+
+    <select id="selectMajorList" parameterType="Major" resultMap="MajorResult">
+        <include refid="selectMajorVo"/>
+        <where>
+            <if test="majorName != null  and majorName != ''">and major_name like concat('%', #{majorName}, '%')</if>
+        </where>
+    </select>
+
+    <select id="selectMajorByMajorId" parameterType="Long" resultMap="MajorResult">
+        <include refid="selectMajorVo"/>
+        where major_id = #{majorId}
+    </select>
+
+    <insert id="insertMajor" parameterType="Major" useGeneratedKeys="true" keyProperty="majorId">
+        insert into sim_major
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="majorName != null and majorName != ''">major_name,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="majorName != null and majorName != ''">#{majorName},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+    <update id="updateMajor" parameterType="Major">
+        update sim_major
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="majorName != null and majorName != ''">major_name = #{majorName},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where major_id = #{majorId}
+    </update>
+
+    <delete id="deleteMajorByMajorId" parameterType="Long">
+        delete
+        from sim_major
+        where major_id = #{majorId}
+    </delete>
+
+    <delete id="deleteMajorByMajorIds" parameterType="String">
+        delete from sim_major where major_id in
+        <foreach item="majorId" collection="array" open="(" separator="," close=")">
+            #{majorId}
+        </foreach>
+    </delete>
+</mapper>