diff --git a/src/main/java/com/guwan/backend/entity/BookCategory.java b/src/main/java/com/guwan/backend/entity/BookCategory.java new file mode 100644 index 0000000..2c49171 --- /dev/null +++ b/src/main/java/com/guwan/backend/entity/BookCategory.java @@ -0,0 +1,30 @@ +package com.guwan.backend.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import lombok.Data; + +/** + * + * @TableName book_category + */ +@TableName(value ="book_category") +@Data +public class BookCategory implements Serializable { + /** + * + */ + @TableId + private Integer id; + + /** + * + */ + private String categoryName; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/guwan/backend/generator/controller/BookCategoryController.java b/src/main/java/com/guwan/backend/generator/controller/BookCategoryController.java new file mode 100644 index 0000000..dcba706 --- /dev/null +++ b/src/main/java/com/guwan/backend/generator/controller/BookCategoryController.java @@ -0,0 +1,92 @@ +package com.guwan.backend.generator.controller; + +import com.guwan.backend.common.Result; + +import com.guwan.backend.entity.BookCategory; +import com.guwan.backend.service.BookCategoryService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * (BookCategory)表控制层 + * + * @author makejava + * @since 2024-12-20 17:44:07 + */ +@RestController +@RequestMapping("bookCategory") +public class BookCategoryController { + /** + * 服务对象 + */ + @Autowired + private BookCategoryService bookCategoryService; + + /** + * 分页查询 + * + * @param bookCategory 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @GetMapping + public Result> queryByPage(BookCategory bookCategory, PageRequest pageRequest) { + // return Result.success(this.bookCategoryService.queryByPage(bookCategory, pageRequest)); + + return Result.success(); + + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + public Result queryById(@PathVariable("id") Integer id) { + // return Result.success(this.bookCategoryService.queryById(id)); + return Result.success(); + } + + /** + * 新增数据 + * + * @param bookCategory 实体 + * @return 新增结果 + */ + @PostMapping + public Result add(BookCategory bookCategory) { + // return Result.success(this.bookCategoryService.insert(bookCategory)); + return Result.success(); + } + + /** + * 编辑数据 + * + * @param bookCategory 实体 + * @return 编辑结果 + */ + @PutMapping + public Result edit(BookCategory bookCategory) { + //return Result.success(this.bookCategoryService.update(bookCategory)); + return Result.success(); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping + public Result deleteById(Integer id) { + // return Result.success(this.bookCategoryService.deleteById(id)); + return Result.success(); + } + +} + diff --git a/src/main/java/com/guwan/backend/mapper/BookCategoryMapper.java b/src/main/java/com/guwan/backend/mapper/BookCategoryMapper.java new file mode 100644 index 0000000..3694355 --- /dev/null +++ b/src/main/java/com/guwan/backend/mapper/BookCategoryMapper.java @@ -0,0 +1,18 @@ +package com.guwan.backend.mapper; + +import com.guwan.backend.entity.BookCategory; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author 12455 +* @description 针对表【book_category】的数据库操作Mapper +* @createDate 2024-12-20 17:04:09 +* @Entity com.guwan.backend.entity.BookCategory +*/ +public interface BookCategoryMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/guwan/backend/service/BookCategoryService.java b/src/main/java/com/guwan/backend/service/BookCategoryService.java new file mode 100644 index 0000000..c414aad --- /dev/null +++ b/src/main/java/com/guwan/backend/service/BookCategoryService.java @@ -0,0 +1,13 @@ +package com.guwan.backend.service; + +import com.guwan.backend.entity.BookCategory; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author 12455 +* @description 针对表【book_category】的数据库操作Service +* @createDate 2024-12-20 17:04:09 +*/ +public interface BookCategoryService extends IService { + +} diff --git a/src/main/java/com/guwan/backend/service/impl/BookCategoryServiceImpl.java b/src/main/java/com/guwan/backend/service/impl/BookCategoryServiceImpl.java new file mode 100644 index 0000000..9c07d01 --- /dev/null +++ b/src/main/java/com/guwan/backend/service/impl/BookCategoryServiceImpl.java @@ -0,0 +1,22 @@ +package com.guwan.backend.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.guwan.backend.entity.BookCategory; +import com.guwan.backend.service.BookCategoryService; +import com.guwan.backend.mapper.BookCategoryMapper; +import org.springframework.stereotype.Service; + +/** +* @author 12455 +* @description 针对表【book_category】的数据库操作Service实现 +* @createDate 2024-12-20 17:04:09 +*/ +@Service +public class BookCategoryServiceImpl extends ServiceImpl + implements BookCategoryService{ + +} + + + + diff --git a/src/main/java/com/guwan/backend/websocket/LiveWebSocketHandler.java b/src/main/java/com/guwan/backend/websocket/LiveWebSocketHandler.java deleted file mode 100644 index 88e6244..0000000 --- a/src/main/java/com/guwan/backend/websocket/LiveWebSocketHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -//package com.guwan.backend.websocket; -// -//import com.alibaba.fastjson.JSON; -//import com.guwan.backend.entity.LiveMessage; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.stereotype.Component; -//import org.springframework.web.socket.CloseStatus; -//import org.springframework.web.socket.TextMessage; -//import org.springframework.web.socket.WebSocketSession; -//import org.springframework.web.socket.handler.TextWebSocketHandler; -// -//import java.io.IOException; -//import java.util.Map; -//import java.util.Set; -//import java.util.concurrent.ConcurrentHashMap; -//import java.util.concurrent.ConcurrentHashSet; -// -//@Slf4j -//@Component -//public class LiveWebSocketHandler extends TextWebSocketHandler { -// -// private static final Map> roomSessions = new ConcurrentHashMap<>(); -// private static final Map userSessions = new ConcurrentHashMap<>(); -// -// @Override -// public void afterConnectionEstablished(WebSocketSession session) { -// String roomId = getRoomId(session); -// String userId = getUserId(session); -// -// // 加入房间 -// roomSessions.computeIfAbsent(roomId, k -> new ConcurrentHashSet<>()).add(session); -// userSessions.put(userId, session); -// -// // 广播进入消息 -// broadcastMessage(roomId, createEnterMessage(userId)); -// } -// -// @Override -// public void handleTextMessage(WebSocketSession session, TextMessage message) { -// String roomId = getRoomId(session); -// LiveMessage liveMessage = JSON.parseObject(message.getPayload(), LiveMessage.class); -// -// // 处理不同类型的消息 -// switch (liveMessage.getType()) { -// case "CHAT": -// broadcastMessage(roomId, message); -// break; -// case "GIFT": -// handleGiftMessage(roomId, liveMessage); -// break; -// case "LIKE": -// handleLikeMessage(roomId, liveMessage); -// break; -// } -// } -// -// @Override -// public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { -// String roomId = getRoomId(session); -// String userId = getUserId(session); -// -// // 离开房间 -// roomSessions.get(roomId).remove(session); -// userSessions.remove(userId); -// -// // 广播离开消息 -// broadcastMessage(roomId, createLeaveMessage(userId)); -// } -// -// private void broadcastMessage(String roomId, TextMessage message) { -// Set sessions = roomSessions.get(roomId); -// if (sessions != null) { -// sessions.forEach(session -> { -// try { -// session.sendMessage(message); -// } catch (IOException e) { -// log.error("发送消息失败", e); -// } -// }); -// } -// } -//} \ No newline at end of file diff --git a/src/main/resources/mapper/BookCategoryMapper.xml b/src/main/resources/mapper/BookCategoryMapper.xml new file mode 100644 index 0000000..fc154bc --- /dev/null +++ b/src/main/resources/mapper/BookCategoryMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + id,category_name + + diff --git a/src/main/resources/templates/vm/controller.java.vm b/src/main/resources/templates/vm/controller.java.vm new file mode 100644 index 0000000..0e0e7f7 --- /dev/null +++ b/src/main/resources/templates/vm/controller.java.vm @@ -0,0 +1,100 @@ +##定义初始变量 +#set($tableName = $tool.append($tableInfo.name, "Controller")) +##设置回调 +$!callback.setFileName($tool.append($tableName, ".java")) +$!callback.setSavePath($tool.append($tableInfo.savePath, "/controller")) +##拿到主键 +#if(!$tableInfo.pkColumn.isEmpty()) + #set($pk = $tableInfo.pkColumn.get(0)) +#end + +#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller; + +import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; +import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import org.springframework.beans.factory.annotation.Autowired; + +/** + * $!{tableInfo.comment}($!{tableInfo.name})表控制层 + * + * @author $!author + * @since $!time.currTime() + */ +@RestController +@RequestMapping("$!tool.firstLowerCase($tableInfo.name)") +public class $!{tableName} { +/** + * 服务对象 + */ +@Autowired +private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service; + +/** + * 分页查询 + * + * @param $!{tool.firstLowerCase($tableInfo.name)} 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ +@GetMapping +public Result> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) { + // return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryByPage($!{tool.firstLowerCase($tableInfo.name)}, pageRequest)); + + return Result.success(); + +} + +/** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ +@GetMapping("{id}") +public Result<$!{tableInfo.name}> queryById(@PathVariable("id") $!pk.shortType id) { + // return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id)); + return Result.success(); +} + +/** + * 新增数据 + * + * @param $!{tool.firstLowerCase($tableInfo.name)} 实体 + * @return 新增结果 + */ +@PostMapping +public Result<$!{tableInfo.name}> add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) { + // return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)})); + return Result.success(); +} + +/** + * 编辑数据 + * + * @param $!{tool.firstLowerCase($tableInfo.name)} 实体 + * @return 编辑结果 + */ +@PutMapping +public Result<$!{tableInfo.name}> edit($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) { + //return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.update($!{tool.firstLowerCase($tableInfo.name)})); + return Result.success(); +} + +/** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ +@DeleteMapping +public Result deleteById($!pk.shortType id) { + // return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id)); + return Result.success(); +} + +}