完美兼容RuoYi-Vue代码生成,生成的单表mybatis代码运行正常

This commit is contained in:
dataprince 2023-07-09 16:43:54 +08:00
parent 5d5e8c04c2
commit 256095f3f0
15 changed files with 977 additions and 4 deletions

2
.gitignore vendored
View File

@ -46,3 +46,5 @@ nbdist/
!*/build/*.java !*/build/*.java
!*/build/*.html !*/build/*.html
!*/build/*.xml !*/build/*.xml
.flattened-pom.xml

View File

@ -177,6 +177,13 @@
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<!-- demo模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-demo</artifactId>
<version>${revision}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -211,6 +218,7 @@
<flattenMode>resolveCiFriendliesOnly</flattenMode> <flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration> </configuration>
<executions> <executions>
<!-- enable flattening -->
<execution> <execution>
<id>flatten</id> <id>flatten</id>
<phase>process-resources</phase> <phase>process-resources</phase>
@ -218,6 +226,7 @@
<goal>flatten</goal> <goal>flatten</goal>
</goals> </goals>
</execution> </execution>
<!-- ensure proper cleanup -->
<execution> <execution>
<id>flatten.clean</id> <id>flatten.clean</id>
<phase>clean</phase> <phase>clean</phase>

View File

@ -62,6 +62,12 @@
<artifactId>ruoyi-generator</artifactId> <artifactId>ruoyi-generator</artifactId>
</dependency> </dependency>
<!-- demo模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-demo</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -134,4 +134,4 @@ xss:
# 排除链接(多个用逗号分隔) # 排除链接(多个用逗号分隔)
excludes: /system/notice excludes: /system/notice
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /system/*,/monitor/*,/tool/*,/demo/*

View File

@ -16,7 +16,10 @@
</description> </description>
<dependencies> <dependencies>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,104 @@
package com.ruoyi.demo.controller;
import java.util.List;
import jakarta.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.demo.domain.DemoStudent;
import com.ruoyi.demo.service.IDemoStudentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 学生信息单表(mb)Controller
*
* @author 数据小王子
* @date 2023-07-09
*/
@RestController
@RequestMapping("/demo/student")
public class DemoStudentController extends BaseController
{
@Autowired
private IDemoStudentService demoStudentService;
/**
* 查询学生信息单表(mb)列表
*/
@PreAuthorize("@ss.hasPermi('demo:student:list')")
@GetMapping("/list")
public TableDataInfo list(DemoStudent demoStudent)
{
startPage();
List<DemoStudent> list = demoStudentService.selectDemoStudentList(demoStudent);
return getDataTable(list);
}
/**
* 导出学生信息单表(mb)列表
*/
@PreAuthorize("@ss.hasPermi('demo:student:export')")
@Log(title = "学生信息单表(mb)", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DemoStudent demoStudent)
{
List<DemoStudent> list = demoStudentService.selectDemoStudentList(demoStudent);
ExcelUtil<DemoStudent> util = new ExcelUtil<DemoStudent>(DemoStudent.class);
util.exportExcel(response, list, "学生信息单表(mb)数据");
}
/**
* 获取学生信息单表(mb)详细信息
*/
@PreAuthorize("@ss.hasPermi('demo:student:query')")
@GetMapping(value = "/{studentId}")
public AjaxResult getInfo(@PathVariable("studentId") Long studentId)
{
return success(demoStudentService.selectDemoStudentByStudentId(studentId));
}
/**
* 新增学生信息单表(mb)
*/
@PreAuthorize("@ss.hasPermi('demo:student:add')")
@Log(title = "学生信息单表(mb)", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DemoStudent demoStudent)
{
return toAjax(demoStudentService.insertDemoStudent(demoStudent));
}
/**
* 修改学生信息单表(mb)
*/
@PreAuthorize("@ss.hasPermi('demo:student:edit')")
@Log(title = "学生信息单表(mb)", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DemoStudent demoStudent)
{
return toAjax(demoStudentService.updateDemoStudent(demoStudent));
}
/**
* 删除学生信息单表(mb)
*/
@PreAuthorize("@ss.hasPermi('demo:student:remove')")
@Log(title = "学生信息单表(mb)", businessType = BusinessType.DELETE)
@DeleteMapping("/{studentIds}")
public AjaxResult remove(@PathVariable Long[] studentIds)
{
return toAjax(demoStudentService.deleteDemoStudentByStudentIds(studentIds));
}
}

View File

@ -0,0 +1,124 @@
package com.ruoyi.demo.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 com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 学生信息单表(mb)对象 demo_student
*
* @author 数据小王子
* @date 2023-07-09
*/
public class DemoStudent extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private Long studentId;
/** 学生名称 */
@Excel(name = "学生名称")
private String studentName;
/** 年龄 */
@Excel(name = "年龄")
private Long studentAge;
/** 爱好0代码 1音乐 2电影 */
@Excel(name = "爱好", readConverterExp = "0=代码,1=音乐,2=电影")
private String studentHobby;
/** 性别1男 2女 3未知 */
@Excel(name = "性别", readConverterExp = "1=男,2=女,3=未知")
private String studentSex;
/** 状态0正常 1停用 */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String studentStatus;
/** 生日 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date studentBirthday;
public void setStudentId(Long studentId)
{
this.studentId = studentId;
}
public Long getStudentId()
{
return studentId;
}
public void setStudentName(String studentName)
{
this.studentName = studentName;
}
public String getStudentName()
{
return studentName;
}
public void setStudentAge(Long studentAge)
{
this.studentAge = studentAge;
}
public Long getStudentAge()
{
return studentAge;
}
public void setStudentHobby(String studentHobby)
{
this.studentHobby = studentHobby;
}
public String getStudentHobby()
{
return studentHobby;
}
public void setStudentSex(String studentSex)
{
this.studentSex = studentSex;
}
public String getStudentSex()
{
return studentSex;
}
public void setStudentStatus(String studentStatus)
{
this.studentStatus = studentStatus;
}
public String getStudentStatus()
{
return studentStatus;
}
public void setStudentBirthday(Date studentBirthday)
{
this.studentBirthday = studentBirthday;
}
public Date getStudentBirthday()
{
return studentBirthday;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("studentId", getStudentId())
.append("studentName", getStudentName())
.append("studentAge", getStudentAge())
.append("studentHobby", getStudentHobby())
.append("studentSex", getStudentSex())
.append("studentStatus", getStudentStatus())
.append("studentBirthday", getStudentBirthday())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.demo.mapper;
import java.util.List;
import com.ruoyi.demo.domain.DemoStudent;
/**
* 学生信息单表(mb)Mapper接口
*
* @author 数据小王子
* @date 2023-07-09
*/
public interface DemoStudentMapper
{
/**
* 查询学生信息单表(mb)
*
* @param studentId 学生信息单表(mb)主键
* @return 学生信息单表(mb)
*/
public DemoStudent selectDemoStudentByStudentId(Long studentId);
/**
* 查询学生信息单表(mb)列表
*
* @param demoStudent 学生信息单表(mb)
* @return 学生信息单表(mb)集合
*/
public List<DemoStudent> selectDemoStudentList(DemoStudent demoStudent);
/**
* 新增学生信息单表(mb)
*
* @param demoStudent 学生信息单表(mb)
* @return 结果
*/
public int insertDemoStudent(DemoStudent demoStudent);
/**
* 修改学生信息单表(mb)
*
* @param demoStudent 学生信息单表(mb)
* @return 结果
*/
public int updateDemoStudent(DemoStudent demoStudent);
/**
* 删除学生信息单表(mb)
*
* @param studentId 学生信息单表(mb)主键
* @return 结果
*/
public int deleteDemoStudentByStudentId(Long studentId);
/**
* 批量删除学生信息单表(mb)
*
* @param studentIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteDemoStudentByStudentIds(Long[] studentIds);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.demo.service;
import java.util.List;
import com.ruoyi.demo.domain.DemoStudent;
/**
* 学生信息单表(mb)Service接口
*
* @author 数据小王子
* @date 2023-07-09
*/
public interface IDemoStudentService
{
/**
* 查询学生信息单表(mb)
*
* @param studentId 学生信息单表(mb)主键
* @return 学生信息单表(mb)
*/
public DemoStudent selectDemoStudentByStudentId(Long studentId);
/**
* 查询学生信息单表(mb)列表
*
* @param demoStudent 学生信息单表(mb)
* @return 学生信息单表(mb)集合
*/
public List<DemoStudent> selectDemoStudentList(DemoStudent demoStudent);
/**
* 新增学生信息单表(mb)
*
* @param demoStudent 学生信息单表(mb)
* @return 结果
*/
public int insertDemoStudent(DemoStudent demoStudent);
/**
* 修改学生信息单表(mb)
*
* @param demoStudent 学生信息单表(mb)
* @return 结果
*/
public int updateDemoStudent(DemoStudent demoStudent);
/**
* 批量删除学生信息单表(mb)
*
* @param studentIds 需要删除的学生信息单表(mb)主键集合
* @return 结果
*/
public int deleteDemoStudentByStudentIds(Long[] studentIds);
/**
* 删除学生信息单表(mb)信息
*
* @param studentId 学生信息单表(mb)主键
* @return 结果
*/
public int deleteDemoStudentByStudentId(Long studentId);
}

View File

@ -0,0 +1,93 @@
package com.ruoyi.demo.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.demo.mapper.DemoStudentMapper;
import com.ruoyi.demo.domain.DemoStudent;
import com.ruoyi.demo.service.IDemoStudentService;
/**
* 学生信息单表(mb)Service业务层处理
*
* @author 数据小王子
* @date 2023-07-09
*/
@Service
public class DemoStudentServiceImpl implements IDemoStudentService
{
@Autowired
private DemoStudentMapper demoStudentMapper;
/**
* 查询学生信息单表(mb)
*
* @param studentId 学生信息单表(mb)主键
* @return 学生信息单表(mb)
*/
@Override
public DemoStudent selectDemoStudentByStudentId(Long studentId)
{
return demoStudentMapper.selectDemoStudentByStudentId(studentId);
}
/**
* 查询学生信息单表(mb)列表
*
* @param demoStudent 学生信息单表(mb)
* @return 学生信息单表(mb)
*/
@Override
public List<DemoStudent> selectDemoStudentList(DemoStudent demoStudent)
{
return demoStudentMapper.selectDemoStudentList(demoStudent);
}
/**
* 新增学生信息单表(mb)
*
* @param demoStudent 学生信息单表(mb)
* @return 结果
*/
@Override
public int insertDemoStudent(DemoStudent demoStudent)
{
return demoStudentMapper.insertDemoStudent(demoStudent);
}
/**
* 修改学生信息单表(mb)
*
* @param demoStudent 学生信息单表(mb)
* @return 结果
*/
@Override
public int updateDemoStudent(DemoStudent demoStudent)
{
return demoStudentMapper.updateDemoStudent(demoStudent);
}
/**
* 批量删除学生信息单表(mb)
*
* @param studentIds 需要删除的学生信息单表(mb)主键
* @return 结果
*/
@Override
public int deleteDemoStudentByStudentIds(Long[] studentIds)
{
return demoStudentMapper.deleteDemoStudentByStudentIds(studentIds);
}
/**
* 删除学生信息单表(mb)信息
*
* @param studentId 学生信息单表(mb)主键
* @return 结果
*/
@Override
public int deleteDemoStudentByStudentId(Long studentId)
{
return demoStudentMapper.deleteDemoStudentByStudentId(studentId);
}
}

View File

@ -0,0 +1,77 @@
<?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.demo.mapper.DemoStudentMapper">
<resultMap type="DemoStudent" id="DemoStudentResult">
<result property="studentId" column="student_id" />
<result property="studentName" column="student_name" />
<result property="studentAge" column="student_age" />
<result property="studentHobby" column="student_hobby" />
<result property="studentSex" column="student_sex" />
<result property="studentStatus" column="student_status" />
<result property="studentBirthday" column="student_birthday" />
</resultMap>
<sql id="selectDemoStudentVo">
select student_id, student_name, student_age, student_hobby, student_sex, student_status, student_birthday from demo_student
</sql>
<select id="selectDemoStudentList" parameterType="DemoStudent" resultMap="DemoStudentResult">
<include refid="selectDemoStudentVo"/>
<where>
<if test="studentName != null and studentName != ''"> and student_name like concat('%', #{studentName}, '%')</if>
<if test="studentAge != null "> and student_age = #{studentAge}</if>
</where>
</select>
<select id="selectDemoStudentByStudentId" parameterType="Long" resultMap="DemoStudentResult">
<include refid="selectDemoStudentVo"/>
where student_id = #{studentId}
</select>
<insert id="insertDemoStudent" parameterType="DemoStudent" useGeneratedKeys="true" keyProperty="studentId">
insert into demo_student
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="studentName != null and studentName != ''">student_name,</if>
<if test="studentAge != null">student_age,</if>
<if test="studentHobby != null and studentHobby != ''">student_hobby,</if>
<if test="studentSex != null and studentSex != ''">student_sex,</if>
<if test="studentStatus != null and studentStatus != ''">student_status,</if>
<if test="studentBirthday != null">student_birthday,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="studentName != null and studentName != ''">#{studentName},</if>
<if test="studentAge != null">#{studentAge},</if>
<if test="studentHobby != null and studentHobby != ''">#{studentHobby},</if>
<if test="studentSex != null and studentSex != ''">#{studentSex},</if>
<if test="studentStatus != null and studentStatus != ''">#{studentStatus},</if>
<if test="studentBirthday != null">#{studentBirthday},</if>
</trim>
</insert>
<update id="updateDemoStudent" parameterType="DemoStudent">
update demo_student
<trim prefix="SET" suffixOverrides=",">
<if test="studentName != null and studentName != ''">student_name = #{studentName},</if>
<if test="studentAge != null">student_age = #{studentAge},</if>
<if test="studentHobby != null and studentHobby != ''">student_hobby = #{studentHobby},</if>
<if test="studentSex != null and studentSex != ''">student_sex = #{studentSex},</if>
<if test="studentStatus != null and studentStatus != ''">student_status = #{studentStatus},</if>
<if test="studentBirthday != null">student_birthday = #{studentBirthday},</if>
</trim>
where student_id = #{studentId}
</update>
<delete id="deleteDemoStudentByStudentId" parameterType="Long">
delete from demo_student where student_id = #{studentId}
</delete>
<delete id="deleteDemoStudentByStudentIds" parameterType="String">
delete from demo_student where student_id in
<foreach item="studentId" collection="array" open="(" separator="," close=")">
#{studentId}
</foreach>
</delete>
</mapper>

View File

@ -1,9 +1,9 @@
# 代码生成 # 代码生成
gen: gen:
# 作者 # 作者
author: ruoyi author: 数据小王子
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: com.ruoyi.system packageName: com.ruoyi.demo
# 自动去除表前缀默认是false # 自动去除表前缀默认是false
autoRemovePre: false autoRemovePre: false
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔) # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询学生信息单表(mb)列表
export function listStudent(query) {
return request({
url: '/demo/student/list',
method: 'get',
params: query
})
}
// 查询学生信息单表(mb)详细
export function getStudent(studentId) {
return request({
url: '/demo/student/' + studentId,
method: 'get'
})
}
// 新增学生信息单表(mb)
export function addStudent(data) {
return request({
url: '/demo/student',
method: 'post',
data: data
})
}
// 修改学生信息单表(mb)
export function updateStudent(data) {
return request({
url: '/demo/student',
method: 'put',
data: data
})
}
// 删除学生信息单表(mb)
export function delStudent(studentId) {
return request({
url: '/demo/student/' + studentId,
method: 'delete'
})
}

View File

@ -0,0 +1,339 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="学生名称" prop="studentName">
<el-input
v-model="queryParams.studentName"
placeholder="请输入学生名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="年龄" prop="studentAge">
<el-input
v-model="queryParams.studentAge"
placeholder="请输入年龄"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['demo:student:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['demo:student:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['demo:student:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['demo:student:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="studentList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="studentId" />
<el-table-column label="学生名称" align="center" prop="studentName" />
<el-table-column label="年龄" align="center" prop="studentAge" />
<el-table-column label="爱好" align="center" prop="studentHobby">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_student_hobby" :value="scope.row.studentHobby"/>
</template>
</el-table-column>
<el-table-column label="性别" align="center" prop="studentSex">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_user_sex" :value="scope.row.studentSex"/>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="studentStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_student_status" :value="scope.row.studentStatus"/>
</template>
</el-table-column>
<el-table-column label="生日" align="center" prop="studentBirthday" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.studentBirthday, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['demo:student:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['demo:student:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改学生信息单表(mb)对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="学生名称" prop="studentName">
<el-input v-model="form.studentName" placeholder="请输入学生名称" />
</el-form-item>
<el-form-item label="年龄" prop="studentAge">
<el-input v-model="form.studentAge" placeholder="请输入年龄" />
</el-form-item>
<el-form-item label="爱好" prop="studentHobby">
<el-select v-model="form.studentHobby" placeholder="请选择爱好">
<el-option
v-for="dict in dict.type.sys_student_hobby"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="性别" prop="studentSex">
<el-select v-model="form.studentSex" placeholder="请选择性别">
<el-option
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="studentStatus">
<el-radio-group v-model="form.studentStatus">
<el-radio
v-for="dict in dict.type.sys_student_status"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="生日" prop="studentBirthday">
<el-date-picker clearable
v-model="form.studentBirthday"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择生日">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listStudent, getStudent, delStudent, addStudent, updateStudent } from "@/api/demo/student";
export default {
name: "Student",
dicts: ['sys_user_sex', 'sys_student_status', 'sys_student_hobby'],
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
// (mb)
studentList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
studentName: null,
studentAge: null,
},
//
form: {},
//
rules: {
studentName: [
{ required: true, message: "学生名称不能为空", trigger: "blur" }
],
studentAge: [
{ required: true, message: "年龄不能为空", trigger: "blur" }
],
studentHobby: [
{ required: true, message: "爱好不能为空", trigger: "change" }
],
studentSex: [
{ required: true, message: "性别不能为空", trigger: "change" }
],
studentStatus: [
{ required: true, message: "状态不能为空", trigger: "change" }
],
studentBirthday: [
{ required: true, message: "生日不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询学生信息单表(mb)列表 */
getList() {
this.loading = true;
listStudent(this.queryParams).then(response => {
this.studentList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
studentId: null,
studentName: null,
studentAge: null,
studentHobby: null,
studentSex: null,
studentStatus: null,
studentBirthday: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.studentId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加学生信息单表(mb)";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const studentId = row.studentId || this.ids
getStudent(studentId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改学生信息单表(mb)";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.studentId != null) {
updateStudent(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addStudent(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const studentIds = row.studentId || this.ids;
this.$modal.confirm('是否确认删除学生信息单表(mb)编号为"' + studentIds + '"的数据项?').then(function() {
return delStudent(studentIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('demo/student/export', {
...this.queryParams
}, `student_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -1,3 +1,53 @@
-- udate to Ruoyi-Flex V4.1.1: -- udate to Ruoyi-Flex V4.1.1:
ALTER TABLE `gen_table_column` ALTER TABLE `gen_table_column`
CHANGE COLUMN `table_id` `table_id` BIGINT NOT NULL COMMENT '归属表编号' AFTER `column_id`; CHANGE COLUMN `table_id` `table_id` BIGINT NOT NULL COMMENT '归属表编号' AFTER `column_id`;
-- 测试菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('测试菜单', '0', '99', 'test', null, 1, 0, 'M', '0', '0', null, 'people', 'admin', sysdate(), '', null, '测试菜单');
-- 表 demo_student 结构定义
CREATE TABLE IF NOT EXISTS `demo_student` (
`student_id` int NOT NULL AUTO_INCREMENT COMMENT '编号',
`student_name` varchar(30) COLLATE utf8mb4_bin DEFAULT '' COMMENT '学生名称',
`student_age` int DEFAULT NULL COMMENT '年龄',
`student_hobby` varchar(30) COLLATE utf8mb4_bin DEFAULT '' COMMENT '爱好0代码 1音乐 2电影',
`student_sex` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '1' COMMENT '性别1男 2女 3未知',
`student_status` char(1) COLLATE utf8mb4_bin DEFAULT '0' COMMENT '状态0正常 1停用',
`student_birthday` datetime DEFAULT NULL COMMENT '生日',
PRIMARY KEY (`student_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='学生信息单表';
-- 学生信息单表 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生信息单表(mb)', '2018', '1', 'student', 'demo/student/index', 1, 0, 'C', '0', '0', 'demo:student:list', '#', 'admin', sysdate(), '', null, '学生信息单表(mb)菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生信息单表(mb)查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'demo:student:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生信息单表(mb)新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'demo:student:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生信息单表(mb)修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'demo:student:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生信息单表(mb)删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'demo:student:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生信息单表(mb)导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'demo:student:export', '#', 'admin', sysdate(), '', null, '');
-- 插入gen_table数据
INSERT INTO `gen_table` (`table_id`, `table_name`, `table_comment`, `sub_table_name`, `sub_table_fk_name`, `class_name`, `tpl_category`, `package_name`, `module_name`, `business_name`, `function_name`, `function_author`, `gen_type`, `gen_path`, `options`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES
(1, 'demo_student', '学生信息表', NULL, NULL, 'DemoStudent', 'crud', 'com.ruoyi.demo', 'demo', 'student', '学生信息单表(mb)', '数据小王子', '0', '/', '{"parentMenuId":"2018"}', 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53', '生成mybatis语法单表代码');
-- 插入gen_table_column数据
INSERT INTO `gen_table_column` (`column_id`, `table_id`, `column_name`, `column_comment`, `column_type`, `java_type`, `java_field`, `is_pk`, `is_increment`, `is_required`, `is_insert`, `is_edit`, `is_list`, `is_query`, `query_type`, `html_type`, `dict_type`, `sort`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES
(1, 1, 'student_id', '编号', 'int', 'Long', 'studentId', '1', '1', NULL, '1', NULL, NULL, NULL, 'EQ', 'input', '', 1, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53'),
(2, 1, 'student_name', '学生名称', 'varchar(30)', 'String', 'studentName', '0', '0', '1', '1', '1', '1', '1', 'LIKE', 'input', '', 2, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53'),
(3, 1, 'student_age', '年龄', 'int', 'Long', 'studentAge', '0', '0', '1', '1', '1', '1', '1', 'EQ', 'input', '', 3, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53'),
(4, 1, 'student_hobby', '爱好0代码 1音乐 2电影', 'varchar(30)', 'String', 'studentHobby', '0', '0', '1', '1', '1', '1', '0', 'EQ', 'select', 'sys_student_hobby', 4, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53'),
(5, 1, 'student_sex', '性别1男 2女 3未知', 'char(1)', 'String', 'studentSex', '0', '0', '1', '1', '1', '1', '0', 'EQ', 'select', 'sys_user_sex', 5, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53'),
(6, 1, 'student_status', '状态0正常 1停用', 'char(1)', 'String', 'studentStatus', '0', '0', '1', '1', '1', '1', '0', 'EQ', 'radio', 'sys_student_status', 6, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53'),
(7, 1, 'student_birthday', '生日', 'datetime', 'Date', 'studentBirthday', '0', '0', '1', '1', '1', '1', '0', 'EQ', 'datetime', '', 7, 'admin', '2023-06-03 21:44:19', '', '2023-07-09 12:14:53');