From 34a13b4be971c178f076e86e696289ea10471dcf Mon Sep 17 00:00:00 2001 From: alittlekang <2546110334@qq.com> Date: Thu, 28 Nov 2024 21:49:46 +0800 Subject: [PATCH] room --- .../controller/controller/RoomController.java | 104 ++++++++++++++++++ .../java/com/ruoyi/system/domain/Room.java | 66 +++++++++++ .../com/ruoyi/system/mapper/RoomMapper.java | 61 ++++++++++ .../ruoyi/system/service/IRoomService.java | 61 ++++++++++ .../system/service/impl/RoomServiceImpl.java | 93 ++++++++++++++++ .../resources/mapper/system/RoomMapper.xml | 64 +++++++++++ 6 files changed, 449 insertions(+) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/controller/controller/RoomController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/Room.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/RoomMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/IRoomService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RoomServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/system/RoomMapper.xml diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/controller/RoomController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/controller/RoomController.java new file mode 100644 index 0000000..63078c1 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/controller/RoomController.java @@ -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 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 list = roomService.selectRoomList(room); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Room.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Room.java new file mode 100644 index 0000000..fa26b5a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Room.java @@ -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(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RoomMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RoomMapper.java new file mode 100644 index 0000000..89c0cb5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RoomMapper.java @@ -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 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRoomService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRoomService.java new file mode 100644 index 0000000..36285d7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRoomService.java @@ -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 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RoomServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RoomServiceImpl.java new file mode 100644 index 0000000..d6cf8af --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RoomServiceImpl.java @@ -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 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); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/RoomMapper.xml b/ruoyi-system/src/main/resources/mapper/system/RoomMapper.xml new file mode 100644 index 0000000..ecc74d3 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/RoomMapper.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + select name, price, introduction from room + + + + + + + + insert into room + + name, + price, + introduction, + + + #{name}, + #{price}, + #{introduction}, + + + + + update room + + price = #{price}, + introduction = #{introduction}, + + where name = #{name} + + + + delete from room where name = #{name} + + + + delete from room where name in + + #{name} + + + \ No newline at end of file