✨Feat: 图书管理模块

This commit is contained in:
2025-11-17 16:40:37 +08:00
parent 27cf7c318e
commit 9266029056
28 changed files with 2537 additions and 0 deletions
+6
View File
@@ -16,5 +16,11 @@
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,104 @@
package com.ruoyi.manage.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.manage.domain.Book;
import com.ruoyi.manage.service.IBookService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 书籍Controller
*
* @author ruoyi
* @date 2025-11-17
*/
@RestController
@RequestMapping("/manage/book")
public class BookController extends BaseController
{
@Autowired
private IBookService bookService;
/**
* 查询书籍列表
*/
@PreAuthorize("@ss.hasPermi('manage:book:list')")
@GetMapping("/list")
public TableDataInfo list(Book book)
{
startPage();
List<Book> list = bookService.selectBookList(book);
return getDataTable(list);
}
/**
* 导出书籍列表
*/
@PreAuthorize("@ss.hasPermi('manage:book:export')")
@Log(title = "书籍", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Book book)
{
List<Book> list = bookService.selectBookList(book);
ExcelUtil<Book> util = new ExcelUtil<Book>(Book.class);
util.exportExcel(response, list, "书籍数据");
}
/**
* 获取书籍详细信息
*/
@PreAuthorize("@ss.hasPermi('manage:book:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(bookService.selectBookById(id));
}
/**
* 新增书籍
*/
@PreAuthorize("@ss.hasPermi('manage:book:add')")
@Log(title = "书籍", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Book book)
{
return toAjax(bookService.insertBook(book));
}
/**
* 修改书籍
*/
@PreAuthorize("@ss.hasPermi('manage:book:edit')")
@Log(title = "书籍", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Book book)
{
return toAjax(bookService.updateBook(book));
}
/**
* 删除书籍
*/
@PreAuthorize("@ss.hasPermi('manage:book:remove')")
@Log(title = "书籍", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(bookService.deleteBookByIds(ids));
}
}
@@ -0,0 +1,104 @@
package com.ruoyi.manage.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.manage.domain.Category;
import com.ruoyi.manage.service.ICategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 类别Controller
*
* @author ruoyi
* @date 2025-11-17
*/
@RestController
@RequestMapping("/manage/category")
public class CategoryController extends BaseController
{
@Autowired
private ICategoryService categoryService;
/**
* 查询类别列表
*/
@PreAuthorize("@ss.hasPermi('manage:category:list')")
@GetMapping("/list")
public TableDataInfo list(Category category)
{
startPage();
List<Category> list = categoryService.selectCategoryList(category);
return getDataTable(list);
}
/**
* 导出类别列表
*/
@PreAuthorize("@ss.hasPermi('manage:category:export')")
@Log(title = "类别", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Category category)
{
List<Category> list = categoryService.selectCategoryList(category);
ExcelUtil<Category> util = new ExcelUtil<Category>(Category.class);
util.exportExcel(response, list, "类别数据");
}
/**
* 获取类别详细信息
*/
@PreAuthorize("@ss.hasPermi('manage:category:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(categoryService.selectCategoryById(id));
}
/**
* 新增类别
*/
@PreAuthorize("@ss.hasPermi('manage:category:add')")
@Log(title = "类别", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Category category)
{
return toAjax(categoryService.insertCategory(category));
}
/**
* 修改类别
*/
@PreAuthorize("@ss.hasPermi('manage:category:edit')")
@Log(title = "类别", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Category category)
{
return toAjax(categoryService.updateCategory(category));
}
/**
* 删除类别
*/
@PreAuthorize("@ss.hasPermi('manage:category:remove')")
@Log(title = "类别", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(categoryService.deleteCategoryByIds(ids));
}
}
@@ -0,0 +1,104 @@
package com.ruoyi.manage.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.manage.domain.Region;
import com.ruoyi.manage.service.IRegionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 区域Controller
*
* @author ruoyi
* @date 2025-11-17
*/
@RestController
@RequestMapping("/manage/region")
public class RegionController extends BaseController
{
@Autowired
private IRegionService regionService;
/**
* 查询区域列表
*/
@PreAuthorize("@ss.hasPermi('manage:region:list')")
@GetMapping("/list")
public TableDataInfo list(Region region)
{
startPage();
List<Region> list = regionService.selectRegionList(region);
return getDataTable(list);
}
/**
* 导出区域列表
*/
@PreAuthorize("@ss.hasPermi('manage:region:export')")
@Log(title = "区域", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Region region)
{
List<Region> list = regionService.selectRegionList(region);
ExcelUtil<Region> util = new ExcelUtil<Region>(Region.class);
util.exportExcel(response, list, "区域数据");
}
/**
* 获取区域详细信息
*/
@PreAuthorize("@ss.hasPermi('manage:region:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(regionService.selectRegionById(id));
}
/**
* 新增区域
*/
@PreAuthorize("@ss.hasPermi('manage:region:add')")
@Log(title = "区域", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Region region)
{
return toAjax(regionService.insertRegion(region));
}
/**
* 修改区域
*/
@PreAuthorize("@ss.hasPermi('manage:region:edit')")
@Log(title = "区域", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Region region)
{
return toAjax(regionService.updateRegion(region));
}
/**
* 删除区域
*/
@PreAuthorize("@ss.hasPermi('manage:region:remove')")
@Log(title = "区域", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(regionService.deleteRegionByIds(ids));
}
}
@@ -0,0 +1,181 @@
package com.ruoyi.manage.domain;
import java.math.BigDecimal;
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;
/**
* 书籍对象 lb_book
*
* @author ruoyi
* @date 2025-11-17
*/
public class Book extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 书籍ID */
private Long id;
/** 书籍名称 */
@Excel(name = "书籍名称")
private String bookName;
/** 封面 */
@Excel(name = "封面")
private String cover;
/** 作者 */
@Excel(name = "作者")
private String author;
/** 出版社 */
@Excel(name = "出版社")
private String publisher;
/** 出版日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出版日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date publishDate;
/** 价格 */
@Excel(name = "价格")
private BigDecimal price;
/** 数量 */
@Excel(name = "数量")
private Long quantity;
/** 区域ID */
@Excel(name = "区域ID")
private Long regionId;
/** 类别ID */
@Excel(name = "类别ID")
private Long categoryId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setBookName(String bookName)
{
this.bookName = bookName;
}
public String getBookName()
{
return bookName;
}
public void setCover(String cover)
{
this.cover = cover;
}
public String getCover()
{
return cover;
}
public void setAuthor(String author)
{
this.author = author;
}
public String getAuthor()
{
return author;
}
public void setPublisher(String publisher)
{
this.publisher = publisher;
}
public String getPublisher()
{
return publisher;
}
public void setPublishDate(Date publishDate)
{
this.publishDate = publishDate;
}
public Date getPublishDate()
{
return publishDate;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setQuantity(Long quantity)
{
this.quantity = quantity;
}
public Long getQuantity()
{
return quantity;
}
public void setRegionId(Long regionId)
{
this.regionId = regionId;
}
public Long getRegionId()
{
return regionId;
}
public void setCategoryId(Long categoryId)
{
this.categoryId = categoryId;
}
public Long getCategoryId()
{
return categoryId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("bookName", getBookName())
.append("cover", getCover())
.append("author", getAuthor())
.append("publisher", getPublisher())
.append("publishDate", getPublishDate())
.append("price", getPrice())
.append("quantity", getQuantity())
.append("regionId", getRegionId())
.append("categoryId", getCategoryId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("remark", getRemark())
.toString();
}
}
@@ -0,0 +1,57 @@
package com.ruoyi.manage.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;
/**
* 类别对象 lb_category
*
* @author ruoyi
* @date 2025-11-17
*/
public class Category extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 类别ID */
private Long id;
/** 类别名称 */
@Excel(name = "类别名称")
private String categoryName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setCategoryName(String categoryName)
{
this.categoryName = categoryName;
}
public String getCategoryName()
{
return categoryName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("categoryName", getCategoryName())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("remark", getRemark())
.toString();
}
}
@@ -0,0 +1,57 @@
package com.ruoyi.manage.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;
/**
* 区域对象 lb_region
*
* @author ruoyi
* @date 2025-11-17
*/
public class Region extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 区域ID */
private Long id;
/** 区域名称 */
@Excel(name = "区域名称")
private String regionName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setRegionName(String regionName)
{
this.regionName = regionName;
}
public String getRegionName()
{
return regionName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("regionName", getRegionName())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("remark", getRemark())
.toString();
}
}
@@ -0,0 +1,61 @@
package com.ruoyi.manage.mapper;
import java.util.List;
import com.ruoyi.manage.domain.Book;
/**
* 书籍Mapper接口
*
* @author ruoyi
* @date 2025-11-17
*/
public interface BookMapper
{
/**
* 查询书籍
*
* @param id 书籍主键
* @return 书籍
*/
public Book selectBookById(Long id);
/**
* 查询书籍列表
*
* @param book 书籍
* @return 书籍集合
*/
public List<Book> selectBookList(Book book);
/**
* 新增书籍
*
* @param book 书籍
* @return 结果
*/
public int insertBook(Book book);
/**
* 修改书籍
*
* @param book 书籍
* @return 结果
*/
public int updateBook(Book book);
/**
* 删除书籍
*
* @param id 书籍主键
* @return 结果
*/
public int deleteBookById(Long id);
/**
* 批量删除书籍
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteBookByIds(Long[] ids);
}
@@ -0,0 +1,61 @@
package com.ruoyi.manage.mapper;
import java.util.List;
import com.ruoyi.manage.domain.Category;
/**
* 类别Mapper接口
*
* @author ruoyi
* @date 2025-11-17
*/
public interface CategoryMapper
{
/**
* 查询类别
*
* @param id 类别主键
* @return 类别
*/
public Category selectCategoryById(Long id);
/**
* 查询类别列表
*
* @param category 类别
* @return 类别集合
*/
public List<Category> selectCategoryList(Category category);
/**
* 新增类别
*
* @param category 类别
* @return 结果
*/
public int insertCategory(Category category);
/**
* 修改类别
*
* @param category 类别
* @return 结果
*/
public int updateCategory(Category category);
/**
* 删除类别
*
* @param id 类别主键
* @return 结果
*/
public int deleteCategoryById(Long id);
/**
* 批量删除类别
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCategoryByIds(Long[] ids);
}
@@ -0,0 +1,61 @@
package com.ruoyi.manage.mapper;
import java.util.List;
import com.ruoyi.manage.domain.Region;
/**
* 区域Mapper接口
*
* @author ruoyi
* @date 2025-11-17
*/
public interface RegionMapper
{
/**
* 查询区域
*
* @param id 区域主键
* @return 区域
*/
public Region selectRegionById(Long id);
/**
* 查询区域列表
*
* @param region 区域
* @return 区域集合
*/
public List<Region> selectRegionList(Region region);
/**
* 新增区域
*
* @param region 区域
* @return 结果
*/
public int insertRegion(Region region);
/**
* 修改区域
*
* @param region 区域
* @return 结果
*/
public int updateRegion(Region region);
/**
* 删除区域
*
* @param id 区域主键
* @return 结果
*/
public int deleteRegionById(Long id);
/**
* 批量删除区域
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteRegionByIds(Long[] ids);
}
@@ -0,0 +1,61 @@
package com.ruoyi.manage.service;
import java.util.List;
import com.ruoyi.manage.domain.Book;
/**
* 书籍Service接口
*
* @author ruoyi
* @date 2025-11-17
*/
public interface IBookService
{
/**
* 查询书籍
*
* @param id 书籍主键
* @return 书籍
*/
public Book selectBookById(Long id);
/**
* 查询书籍列表
*
* @param book 书籍
* @return 书籍集合
*/
public List<Book> selectBookList(Book book);
/**
* 新增书籍
*
* @param book 书籍
* @return 结果
*/
public int insertBook(Book book);
/**
* 修改书籍
*
* @param book 书籍
* @return 结果
*/
public int updateBook(Book book);
/**
* 批量删除书籍
*
* @param ids 需要删除的书籍主键集合
* @return 结果
*/
public int deleteBookByIds(Long[] ids);
/**
* 删除书籍信息
*
* @param id 书籍主键
* @return 结果
*/
public int deleteBookById(Long id);
}
@@ -0,0 +1,61 @@
package com.ruoyi.manage.service;
import java.util.List;
import com.ruoyi.manage.domain.Category;
/**
* 类别Service接口
*
* @author ruoyi
* @date 2025-11-17
*/
public interface ICategoryService
{
/**
* 查询类别
*
* @param id 类别主键
* @return 类别
*/
public Category selectCategoryById(Long id);
/**
* 查询类别列表
*
* @param category 类别
* @return 类别集合
*/
public List<Category> selectCategoryList(Category category);
/**
* 新增类别
*
* @param category 类别
* @return 结果
*/
public int insertCategory(Category category);
/**
* 修改类别
*
* @param category 类别
* @return 结果
*/
public int updateCategory(Category category);
/**
* 批量删除类别
*
* @param ids 需要删除的类别主键集合
* @return 结果
*/
public int deleteCategoryByIds(Long[] ids);
/**
* 删除类别信息
*
* @param id 类别主键
* @return 结果
*/
public int deleteCategoryById(Long id);
}
@@ -0,0 +1,61 @@
package com.ruoyi.manage.service;
import java.util.List;
import com.ruoyi.manage.domain.Region;
/**
* 区域Service接口
*
* @author ruoyi
* @date 2025-11-17
*/
public interface IRegionService
{
/**
* 查询区域
*
* @param id 区域主键
* @return 区域
*/
public Region selectRegionById(Long id);
/**
* 查询区域列表
*
* @param region 区域
* @return 区域集合
*/
public List<Region> selectRegionList(Region region);
/**
* 新增区域
*
* @param region 区域
* @return 结果
*/
public int insertRegion(Region region);
/**
* 修改区域
*
* @param region 区域
* @return 结果
*/
public int updateRegion(Region region);
/**
* 批量删除区域
*
* @param ids 需要删除的区域主键集合
* @return 结果
*/
public int deleteRegionByIds(Long[] ids);
/**
* 删除区域信息
*
* @param id 区域主键
* @return 结果
*/
public int deleteRegionById(Long id);
}
@@ -0,0 +1,96 @@
package com.ruoyi.manage.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.manage.mapper.BookMapper;
import com.ruoyi.manage.domain.Book;
import com.ruoyi.manage.service.IBookService;
/**
* 书籍Service业务层处理
*
* @author ruoyi
* @date 2025-11-17
*/
@Service
public class BookServiceImpl implements IBookService
{
@Autowired
private BookMapper bookMapper;
/**
* 查询书籍
*
* @param id 书籍主键
* @return 书籍
*/
@Override
public Book selectBookById(Long id)
{
return bookMapper.selectBookById(id);
}
/**
* 查询书籍列表
*
* @param book 书籍
* @return 书籍
*/
@Override
public List<Book> selectBookList(Book book)
{
return bookMapper.selectBookList(book);
}
/**
* 新增书籍
*
* @param book 书籍
* @return 结果
*/
@Override
public int insertBook(Book book)
{
book.setCreateTime(DateUtils.getNowDate());
return bookMapper.insertBook(book);
}
/**
* 修改书籍
*
* @param book 书籍
* @return 结果
*/
@Override
public int updateBook(Book book)
{
book.setUpdateTime(DateUtils.getNowDate());
return bookMapper.updateBook(book);
}
/**
* 批量删除书籍
*
* @param ids 需要删除的书籍主键
* @return 结果
*/
@Override
public int deleteBookByIds(Long[] ids)
{
return bookMapper.deleteBookByIds(ids);
}
/**
* 删除书籍信息
*
* @param id 书籍主键
* @return 结果
*/
@Override
public int deleteBookById(Long id)
{
return bookMapper.deleteBookById(id);
}
}
@@ -0,0 +1,96 @@
package com.ruoyi.manage.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.manage.mapper.CategoryMapper;
import com.ruoyi.manage.domain.Category;
import com.ruoyi.manage.service.ICategoryService;
/**
* 类别Service业务层处理
*
* @author ruoyi
* @date 2025-11-17
*/
@Service
public class CategoryServiceImpl implements ICategoryService
{
@Autowired
private CategoryMapper categoryMapper;
/**
* 查询类别
*
* @param id 类别主键
* @return 类别
*/
@Override
public Category selectCategoryById(Long id)
{
return categoryMapper.selectCategoryById(id);
}
/**
* 查询类别列表
*
* @param category 类别
* @return 类别
*/
@Override
public List<Category> selectCategoryList(Category category)
{
return categoryMapper.selectCategoryList(category);
}
/**
* 新增类别
*
* @param category 类别
* @return 结果
*/
@Override
public int insertCategory(Category category)
{
category.setCreateTime(DateUtils.getNowDate());
return categoryMapper.insertCategory(category);
}
/**
* 修改类别
*
* @param category 类别
* @return 结果
*/
@Override
public int updateCategory(Category category)
{
category.setUpdateTime(DateUtils.getNowDate());
return categoryMapper.updateCategory(category);
}
/**
* 批量删除类别
*
* @param ids 需要删除的类别主键
* @return 结果
*/
@Override
public int deleteCategoryByIds(Long[] ids)
{
return categoryMapper.deleteCategoryByIds(ids);
}
/**
* 删除类别信息
*
* @param id 类别主键
* @return 结果
*/
@Override
public int deleteCategoryById(Long id)
{
return categoryMapper.deleteCategoryById(id);
}
}
@@ -0,0 +1,96 @@
package com.ruoyi.manage.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.manage.mapper.RegionMapper;
import com.ruoyi.manage.domain.Region;
import com.ruoyi.manage.service.IRegionService;
/**
* 区域Service业务层处理
*
* @author ruoyi
* @date 2025-11-17
*/
@Service
public class RegionServiceImpl implements IRegionService
{
@Autowired
private RegionMapper regionMapper;
/**
* 查询区域
*
* @param id 区域主键
* @return 区域
*/
@Override
public Region selectRegionById(Long id)
{
return regionMapper.selectRegionById(id);
}
/**
* 查询区域列表
*
* @param region 区域
* @return 区域
*/
@Override
public List<Region> selectRegionList(Region region)
{
return regionMapper.selectRegionList(region);
}
/**
* 新增区域
*
* @param region 区域
* @return 结果
*/
@Override
public int insertRegion(Region region)
{
region.setCreateTime(DateUtils.getNowDate());
return regionMapper.insertRegion(region);
}
/**
* 修改区域
*
* @param region 区域
* @return 结果
*/
@Override
public int updateRegion(Region region)
{
region.setUpdateTime(DateUtils.getNowDate());
return regionMapper.updateRegion(region);
}
/**
* 批量删除区域
*
* @param ids 需要删除的区域主键
* @return 结果
*/
@Override
public int deleteRegionByIds(Long[] ids)
{
return regionMapper.deleteRegionByIds(ids);
}
/**
* 删除区域信息
*
* @param id 区域主键
* @return 结果
*/
@Override
public int deleteRegionById(Long id)
{
return regionMapper.deleteRegionById(id);
}
}
@@ -0,0 +1,111 @@
<?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.manage.mapper.BookMapper">
<resultMap type="Book" id="BookResult">
<result property="id" column="id" />
<result property="bookName" column="book_name" />
<result property="cover" column="cover" />
<result property="author" column="author" />
<result property="publisher" column="publisher" />
<result property="publishDate" column="publish_date" />
<result property="price" column="price" />
<result property="quantity" column="quantity" />
<result property="regionId" column="region_id" />
<result property="categoryId" column="category_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectBookVo">
select id, book_name, cover, author, publisher, publish_date, price, quantity, region_id, category_id, create_time, update_time, create_by, update_by, remark from lb_book
</sql>
<select id="selectBookList" parameterType="Book" resultMap="BookResult">
<include refid="selectBookVo"/>
<where>
<if test="bookName != null and bookName != ''"> and book_name like concat('%', #{bookName}, '%')</if>
<if test="author != null and author != ''"> and author like concat('%', #{author}, '%')</if>
<if test="regionId != null "> and region_id = #{regionId}</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if>
</where>
</select>
<select id="selectBookById" parameterType="Long" resultMap="BookResult">
<include refid="selectBookVo"/>
where id = #{id}
</select>
<insert id="insertBook" parameterType="Book" useGeneratedKeys="true" keyProperty="id">
insert into lb_book
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bookName != null and bookName != ''">book_name,</if>
<if test="cover != null">cover,</if>
<if test="author != null and author != ''">author,</if>
<if test="publisher != null and publisher != ''">publisher,</if>
<if test="publishDate != null">publish_date,</if>
<if test="price != null">price,</if>
<if test="quantity != null">quantity,</if>
<if test="regionId != null">region_id,</if>
<if test="categoryId != null">category_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bookName != null and bookName != ''">#{bookName},</if>
<if test="cover != null">#{cover},</if>
<if test="author != null and author != ''">#{author},</if>
<if test="publisher != null and publisher != ''">#{publisher},</if>
<if test="publishDate != null">#{publishDate},</if>
<if test="price != null">#{price},</if>
<if test="quantity != null">#{quantity},</if>
<if test="regionId != null">#{regionId},</if>
<if test="categoryId != null">#{categoryId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateBook" parameterType="Book">
update lb_book
<trim prefix="SET" suffixOverrides=",">
<if test="bookName != null and bookName != ''">book_name = #{bookName},</if>
<if test="cover != null">cover = #{cover},</if>
<if test="author != null and author != ''">author = #{author},</if>
<if test="publisher != null and publisher != ''">publisher = #{publisher},</if>
<if test="publishDate != null">publish_date = #{publishDate},</if>
<if test="price != null">price = #{price},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="regionId != null">region_id = #{regionId},</if>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBookById" parameterType="Long">
delete from lb_book where id = #{id}
</delete>
<delete id="deleteBookByIds" parameterType="String">
delete from lb_book where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
@@ -0,0 +1,76 @@
<?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.manage.mapper.CategoryMapper">
<resultMap type="Category" id="CategoryResult">
<result property="id" column="id" />
<result property="categoryName" column="category_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectCategoryVo">
select id, category_name, create_time, update_time, create_by, update_by, remark from lb_category
</sql>
<select id="selectCategoryList" parameterType="Category" resultMap="CategoryResult">
<include refid="selectCategoryVo"/>
<where>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
</where>
</select>
<select id="selectCategoryById" parameterType="Long" resultMap="CategoryResult">
<include refid="selectCategoryVo"/>
where id = #{id}
</select>
<insert id="insertCategory" parameterType="Category" useGeneratedKeys="true" keyProperty="id">
insert into lb_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateCategory" parameterType="Category">
update lb_category
<trim prefix="SET" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCategoryById" parameterType="Long">
delete from lb_category where id = #{id}
</delete>
<delete id="deleteCategoryByIds" parameterType="String">
delete from lb_category where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
@@ -0,0 +1,76 @@
<?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.manage.mapper.RegionMapper">
<resultMap type="Region" id="RegionResult">
<result property="id" column="id" />
<result property="regionName" column="region_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectRegionVo">
select id, region_name, create_time, update_time, create_by, update_by, remark from lb_region
</sql>
<select id="selectRegionList" parameterType="Region" resultMap="RegionResult">
<include refid="selectRegionVo"/>
<where>
<if test="regionName != null and regionName != ''"> and region_name like concat('%', #{regionName}, '%')</if>
</where>
</select>
<select id="selectRegionById" parameterType="Long" resultMap="RegionResult">
<include refid="selectRegionVo"/>
where id = #{id}
</select>
<insert id="insertRegion" parameterType="Region" useGeneratedKeys="true" keyProperty="id">
insert into lb_region
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="regionName != null and regionName != ''">region_name,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="regionName != null and regionName != ''">#{regionName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateRegion" parameterType="Region">
update lb_region
<trim prefix="SET" suffixOverrides=",">
<if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteRegionById" parameterType="Long">
delete from lb_region where id = #{id}
</delete>
<delete id="deleteRegionByIds" parameterType="String">
delete from lb_region where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>