Roma
世界已黑白,此人已成仙。

年少轻狂,总以为天下事竭力有为。人事尽时,终感力不能及。
posts - 329,comments - 0,views - 13017

1.创建数据表及字段

1
2
3
4
5
6
7
8
9
10
CREATE TABLE hotel_room_type ( 
  -- 房间类型ID,作为主键 
  room_type_id INT PRIMARY KEY AUTO_INCREMENT, 
  -- 房间类型名称 
  room_type_name VARCHAR(50), 
  -- 房间类型描述 
  room_type_description VARCHAR(50), 
  -- 创建时间,默认为当前时间戳 
  create_time DATETIME DEFAULT CURRENT_TIMESTAMP 
);

 2.搭建增删改查

到后台菜单管理新增一个房间类型管理

新建组件文件夹

 将房间类型表导入

 复制对应的domain,mapper,service,controller等测试功能不报错就行

3.完善增删改查

后端添加正则表达式

 前端限制规则

 

 后端完整代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.rome.hotel.data.service.impl;
 
import java.util.List;
import com.rome.hotel.common.utils.DateUtils;
import com.rome.hotel.data.domain.HotelUser;
import com.rome.hotel.data.utils.RegexUtils;
import io.jsonwebtoken.lang.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rome.hotel.data.mapper.HotelRoomTypeMapper;
import com.rome.hotel.data.domain.HotelRoomType;
import com.rome.hotel.data.service.IHotelRoomTypeService;
 
/**
 * 房间类型Service业务层处理
 *
 * @author rome
 * @date 2023-12-21
 */
@Service
public class HotelRoomTypeServiceImpl implements IHotelRoomTypeService
{
    @Autowired
    private HotelRoomTypeMapper hotelRoomTypeMapper;
 
    /**
     * 查询房间类型
     *
     * @param roomTypeId 房间类型主键
     * @return 房间类型
     */
    @Override
    public HotelRoomType selectHotelRoomTypeByRoomTypeId(Long roomTypeId)
    {
        return hotelRoomTypeMapper.selectHotelRoomTypeByRoomTypeId(roomTypeId);
    }
 
    /**
     * 查询房间类型列表
     *
     * @param hotelRoomType 房间类型
     * @return 房间类型
     */
    @Override
    public List<HotelRoomType> selectHotelRoomTypeList(HotelRoomType hotelRoomType)
    {
        return hotelRoomTypeMapper.selectHotelRoomTypeList(hotelRoomType);
    }
 
    /**
     * 新增房间类型
     *
     * @param hotelRoomType 房间类型
     * @return 结果
     */
    @Override
    public int insertHotelRoomType(HotelRoomType hotelRoomType)
    {
//        1.防御性编程
        Assert.notNull(hotelRoomType,"参数为空");
        Assert.state(RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeName())&&RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeDescription()),"内容1到300位");
        hotelRoomType.setCreateTime(DateUtils.getNowDate());
        return hotelRoomTypeMapper.insertHotelRoomType(hotelRoomType);
    }
 
    /**
     * 修改房间类型
     *
     * @param hotelRoomType 房间类型
     * @return 结果
     */
    @Override
    public int updateHotelRoomType(HotelRoomType hotelRoomType)
    {
//        1.防御性编程
        Assert.notNull(hotelRoomType,"参数为空");
        Assert.state(RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeName())&&RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeDescription()),"内容1到300位");
        return hotelRoomTypeMapper.updateHotelRoomType(hotelRoomType);
    }
 
    /**
     * 批量删除房间类型
     *
     * @param roomTypeIds 需要删除的房间类型主键
     * @return 结果
     */
    @Override
    public int deleteHotelRoomTypeByRoomTypeIds(Long[] roomTypeIds)
    {
        for (Long id:roomTypeIds
        ) {
 
            Assert.notNull(hotelRoomTypeMapper.selectHotelRoomTypeByRoomTypeId(id),"参数异常");
        }
        return hotelRoomTypeMapper.deleteHotelRoomTypeByRoomTypeIds(roomTypeIds);
    }
 
    /**
     * 删除房间类型信息
     *
     * @param roomTypeId 房间类型主键
     * @return 结果
     */
    @Override
    public int deleteHotelRoomTypeByRoomTypeId(Long roomTypeId)
    {
        //        1.防御性编程
        HotelRoomType hotelRoomType = hotelRoomTypeMapper.selectHotelRoomTypeByRoomTypeId(roomTypeId);
        Assert.notNull(hotelRoomType,"参数异常");
        return hotelRoomTypeMapper.deleteHotelRoomTypeByRoomTypeId(roomTypeId);
    }
}

  

posted on   罗|马  阅读(48)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

Live2D
欢迎阅读『房间类型表』
点击右上角即可分享
微信分享提示