This commit is contained in:
alittlekang 2024-11-28 21:49:46 +08:00
parent 845eafa229
commit 34a13b4be9
6 changed files with 449 additions and 0 deletions

View File

@ -0,0 +1,104 @@
package com.ruoyi.system.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.system.domain.Room;
import com.ruoyi.system.service.IRoomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* roomController
*
* @author ruoyik
* @date 2024-11-28
*/
@RestController
@RequestMapping("/system/room")
public class RoomController extends BaseController
{
@Autowired
private IRoomService roomService;
/**
* 查询room列表
*/
@PreAuthorize("@ss.hasPermi('system:room:list')")
@GetMapping("/list")
public TableDataInfo list(Room room)
{
startPage();
List<Room> list = roomService.selectRoomList(room);
return getDataTable(list);
}
/**
* 导出room列表
*/
@PreAuthorize("@ss.hasPermi('system:room:export')")
@Log(title = "room", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Room room)
{
List<Room> list = roomService.selectRoomList(room);
ExcelUtil<Room> util = new ExcelUtil<Room>(Room.class);
util.exportExcel(response, list, "room数据");
}
/**
* 获取room详细信息
*/
@PreAuthorize("@ss.hasPermi('system:room:query')")
@GetMapping(value = "/{name}")
public AjaxResult getInfo(@PathVariable("name") String name)
{
return success(roomService.selectRoomByName(name));
}
/**
* 新增room
*/
@PreAuthorize("@ss.hasPermi('system:room:add')")
@Log(title = "room", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Room room)
{
return toAjax(roomService.insertRoom(room));
}
/**
* 修改room
*/
@PreAuthorize("@ss.hasPermi('system:room:edit')")
@Log(title = "room", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Room room)
{
return toAjax(roomService.updateRoom(room));
}
/**
* 删除room
*/
@PreAuthorize("@ss.hasPermi('system:room:remove')")
@Log(title = "room", businessType = BusinessType.DELETE)
@DeleteMapping("/{names}")
public AjaxResult remove(@PathVariable String[] names)
{
return toAjax(roomService.deleteRoomByNames(names));
}
}

View File

@ -0,0 +1,66 @@
package com.ruoyi.system.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;
/**
* room对象 room
*
* @author ruoyik
* @date 2024-11-28
*/
public class Room extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String name;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long price;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String introduction;
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setPrice(Long price)
{
this.price = price;
}
public Long getPrice()
{
return price;
}
public void setIntroduction(String introduction)
{
this.introduction = introduction;
}
public String getIntroduction()
{
return introduction;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("name", getName())
.append("price", getPrice())
.append("introduction", getIntroduction())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.Room;
/**
* roomMapper接口
*
* @author ruoyik
* @date 2024-11-28
*/
public interface RoomMapper
{
/**
* 查询room
*
* @param name room主键
* @return room
*/
public Room selectRoomByName(String name);
/**
* 查询room列表
*
* @param room room
* @return room集合
*/
public List<Room> selectRoomList(Room room);
/**
* 新增room
*
* @param room room
* @return 结果
*/
public int insertRoom(Room room);
/**
* 修改room
*
* @param room room
* @return 结果
*/
public int updateRoom(Room room);
/**
* 删除room
*
* @param name room主键
* @return 结果
*/
public int deleteRoomByName(String name);
/**
* 批量删除room
*
* @param names 需要删除的数据主键集合
* @return 结果
*/
public int deleteRoomByNames(String[] names);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Room;
/**
* roomService接口
*
* @author ruoyik
* @date 2024-11-28
*/
public interface IRoomService
{
/**
* 查询room
*
* @param name room主键
* @return room
*/
public Room selectRoomByName(String name);
/**
* 查询room列表
*
* @param room room
* @return room集合
*/
public List<Room> selectRoomList(Room room);
/**
* 新增room
*
* @param room room
* @return 结果
*/
public int insertRoom(Room room);
/**
* 修改room
*
* @param room room
* @return 结果
*/
public int updateRoom(Room room);
/**
* 批量删除room
*
* @param names 需要删除的room主键集合
* @return 结果
*/
public int deleteRoomByNames(String[] names);
/**
* 删除room信息
*
* @param name room主键
* @return 结果
*/
public int deleteRoomByName(String name);
}

View File

@ -0,0 +1,93 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.RoomMapper;
import com.ruoyi.system.domain.Room;
import com.ruoyi.system.service.IRoomService;
/**
* roomService业务层处理
*
* @author ruoyik
* @date 2024-11-28
*/
@Service
public class RoomServiceImpl implements IRoomService
{
@Autowired
private RoomMapper roomMapper;
/**
* 查询room
*
* @param name room主键
* @return room
*/
@Override
public Room selectRoomByName(String name)
{
return roomMapper.selectRoomByName(name);
}
/**
* 查询room列表
*
* @param room room
* @return room
*/
@Override
public List<Room> selectRoomList(Room room)
{
return roomMapper.selectRoomList(room);
}
/**
* 新增room
*
* @param room room
* @return 结果
*/
@Override
public int insertRoom(Room room)
{
return roomMapper.insertRoom(room);
}
/**
* 修改room
*
* @param room room
* @return 结果
*/
@Override
public int updateRoom(Room room)
{
return roomMapper.updateRoom(room);
}
/**
* 批量删除room
*
* @param names 需要删除的room主键
* @return 结果
*/
@Override
public int deleteRoomByNames(String[] names)
{
return roomMapper.deleteRoomByNames(names);
}
/**
* 删除room信息
*
* @param name room主键
* @return 结果
*/
@Override
public int deleteRoomByName(String name)
{
return roomMapper.deleteRoomByName(name);
}
}

View File

@ -0,0 +1,64 @@
<?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.system.mapper.RoomMapper">
<resultMap type="Room" id="RoomResult">
<result property="name" column="name" />
<result property="price" column="price" />
<result property="introduction" column="introduction" />
</resultMap>
<sql id="selectRoomVo">
select name, price, introduction from room
</sql>
<select id="selectRoomList" parameterType="Room" resultMap="RoomResult">
<include refid="selectRoomVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="price != null "> and price = #{price}</if>
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
</where>
</select>
<select id="selectRoomByName" parameterType="String" resultMap="RoomResult">
<include refid="selectRoomVo"/>
where name = #{name}
</select>
<insert id="insertRoom" parameterType="Room">
insert into room
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="price != null">price,</if>
<if test="introduction != null">introduction,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="price != null">#{price},</if>
<if test="introduction != null">#{introduction},</if>
</trim>
</insert>
<update id="updateRoom" parameterType="Room">
update room
<trim prefix="SET" suffixOverrides=",">
<if test="price != null">price = #{price},</if>
<if test="introduction != null">introduction = #{introduction},</if>
</trim>
where name = #{name}
</update>
<delete id="deleteRoomByName" parameterType="String">
delete from room where name = #{name}
</delete>
<delete id="deleteRoomByNames" parameterType="String">
delete from room where name in
<foreach item="name" collection="array" open="(" separator="," close=")">
#{name}
</foreach>
</delete>
</mapper>