初始化
This commit is contained in:
parent
e0f47e6cfa
commit
a4e65eb0b1
|
@ -1,104 +0,0 @@
|
|||
package com.ruoyi.student.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.student.domain.Student;
|
||||
import com.ruoyi.student.service.IStudentService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 学生管理Controller
|
||||
*
|
||||
* @author Maxxie
|
||||
* @date 2024-12-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/student/student")
|
||||
public class StudentController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IStudentService studentService;
|
||||
|
||||
/**
|
||||
* 查询学生管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('student:student:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Student student)
|
||||
{
|
||||
startPage();
|
||||
List<Student> list = studentService.selectStudentList(student);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出学生管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('student:student:export')")
|
||||
@Log(title = "学生管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Student student)
|
||||
{
|
||||
List<Student> list = studentService.selectStudentList(student);
|
||||
ExcelUtil<Student> util = new ExcelUtil<Student>(Student.class);
|
||||
util.exportExcel(response, list, "学生管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学生管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('student:student:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(studentService.selectStudentById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增学生管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('student:student:add')")
|
||||
@Log(title = "学生管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Student student)
|
||||
{
|
||||
return toAjax(studentService.insertStudent(student));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改学生管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('student:student:edit')")
|
||||
@Log(title = "学生管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Student student)
|
||||
{
|
||||
return toAjax(studentService.updateStudent(student));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('student:student:remove')")
|
||||
@Log(title = "学生管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(studentService.deleteStudentByIds(ids));
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package com.ruoyi.student.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;
|
||||
|
||||
/**
|
||||
* 学生管理对象 tb_student
|
||||
*
|
||||
* @author Maxxie
|
||||
* @date 2024-12-04
|
||||
*/
|
||||
public class Student extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 学号 */
|
||||
private String id;
|
||||
|
||||
/** 姓名 */
|
||||
@Excel(name = "姓名")
|
||||
private String name;
|
||||
|
||||
/** 性别 */
|
||||
@Excel(name = "性别")
|
||||
private Long gender;
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/** 头像 */
|
||||
@Excel(name = "头像")
|
||||
private String image;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setGender(Long gender)
|
||||
{
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public Long getGender()
|
||||
{
|
||||
return gender;
|
||||
}
|
||||
public void setBirthday(Date birthday)
|
||||
{
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public Date getBirthday()
|
||||
{
|
||||
return birthday;
|
||||
}
|
||||
public void setImage(String image)
|
||||
{
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("gender", getGender())
|
||||
.append("birthday", getBirthday())
|
||||
.append("image", getImage())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package com.ruoyi.student.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.student.domain.Student;
|
||||
|
||||
/**
|
||||
* 学生管理Mapper接口
|
||||
*
|
||||
* @author Maxxie
|
||||
* @date 2024-12-04
|
||||
*/
|
||||
public interface StudentMapper
|
||||
{
|
||||
/**
|
||||
* 查询学生管理
|
||||
*
|
||||
* @param id 学生管理主键
|
||||
* @return 学生管理
|
||||
*/
|
||||
public Student selectStudentById(String id);
|
||||
|
||||
/**
|
||||
* 查询学生管理列表
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 学生管理集合
|
||||
*/
|
||||
public List<Student> selectStudentList(Student student);
|
||||
|
||||
/**
|
||||
* 新增学生管理
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertStudent(Student student);
|
||||
|
||||
/**
|
||||
* 修改学生管理
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateStudent(Student student);
|
||||
|
||||
/**
|
||||
* 删除学生管理
|
||||
*
|
||||
* @param id 学生管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStudentById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除学生管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStudentByIds(String[] ids);
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package com.ruoyi.student.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.student.domain.Student;
|
||||
|
||||
/**
|
||||
* 学生管理Service接口
|
||||
*
|
||||
* @author Maxxie
|
||||
* @date 2024-12-04
|
||||
*/
|
||||
public interface IStudentService
|
||||
{
|
||||
/**
|
||||
* 查询学生管理
|
||||
*
|
||||
* @param id 学生管理主键
|
||||
* @return 学生管理
|
||||
*/
|
||||
public Student selectStudentById(String id);
|
||||
|
||||
/**
|
||||
* 查询学生管理列表
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 学生管理集合
|
||||
*/
|
||||
public List<Student> selectStudentList(Student student);
|
||||
|
||||
/**
|
||||
* 新增学生管理
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertStudent(Student student);
|
||||
|
||||
/**
|
||||
* 修改学生管理
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateStudent(Student student);
|
||||
|
||||
/**
|
||||
* 批量删除学生管理
|
||||
*
|
||||
* @param ids 需要删除的学生管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStudentByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除学生管理信息
|
||||
*
|
||||
* @param id 学生管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStudentById(String id);
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package com.ruoyi.student.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.student.mapper.StudentMapper;
|
||||
import com.ruoyi.student.domain.Student;
|
||||
import com.ruoyi.student.service.IStudentService;
|
||||
|
||||
/**
|
||||
* 学生管理Service业务层处理
|
||||
*
|
||||
* @author Maxxie
|
||||
* @date 2024-12-04
|
||||
*/
|
||||
@Service
|
||||
public class StudentServiceImpl implements IStudentService
|
||||
{
|
||||
@Autowired
|
||||
private StudentMapper studentMapper;
|
||||
|
||||
/**
|
||||
* 查询学生管理
|
||||
*
|
||||
* @param id 学生管理主键
|
||||
* @return 学生管理
|
||||
*/
|
||||
@Override
|
||||
public Student selectStudentById(String id)
|
||||
{
|
||||
return studentMapper.selectStudentById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询学生管理列表
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 学生管理
|
||||
*/
|
||||
@Override
|
||||
public List<Student> selectStudentList(Student student)
|
||||
{
|
||||
return studentMapper.selectStudentList(student);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增学生管理
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertStudent(Student student)
|
||||
{
|
||||
student.setCreateTime(DateUtils.getNowDate());
|
||||
return studentMapper.insertStudent(student);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改学生管理
|
||||
*
|
||||
* @param student 学生管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateStudent(Student student)
|
||||
{
|
||||
student.setUpdateTime(DateUtils.getNowDate());
|
||||
return studentMapper.updateStudent(student);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除学生管理
|
||||
*
|
||||
* @param ids 需要删除的学生管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteStudentByIds(String[] ids)
|
||||
{
|
||||
return studentMapper.deleteStudentByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生管理信息
|
||||
*
|
||||
* @param id 学生管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteStudentById(String id)
|
||||
{
|
||||
return studentMapper.deleteStudentById(id);
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
<?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.student.mapper.StudentMapper">
|
||||
|
||||
<resultMap type="Student" id="StudentResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="birthday" column="birthday" />
|
||||
<result property="image" column="image" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectStudentVo">
|
||||
select id, name, gender, birthday, image, create_by, create_time, update_by, update_time from tb_student
|
||||
</sql>
|
||||
|
||||
<select id="selectStudentList" parameterType="Student" resultMap="StudentResult">
|
||||
<include refid="selectStudentVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="gender != null "> and gender = #{gender}</if>
|
||||
<if test="params.beginBirthday != null and params.beginBirthday != '' and params.endBirthday != null and params.endBirthday != ''"> and birthday between #{params.beginBirthday} and #{params.endBirthday}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectStudentById" parameterType="String" resultMap="StudentResult">
|
||||
<include refid="selectStudentVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertStudent" parameterType="Student">
|
||||
insert into tb_student
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="birthday != null">birthday,</if>
|
||||
<if test="image != null">image,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="gender != null">#{gender},</if>
|
||||
<if test="birthday != null">#{birthday},</if>
|
||||
<if test="image != null">#{image},</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>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateStudent" parameterType="Student">
|
||||
update tb_student
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="gender != null">gender = #{gender},</if>
|
||||
<if test="birthday != null">birthday = #{birthday},</if>
|
||||
<if test="image != null">image = #{image},</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>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteStudentById" parameterType="String">
|
||||
delete from tb_student where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStudentByIds" parameterType="String">
|
||||
delete from tb_student where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue