【开源】SpringBoot框架开发图书管理系统-三、 源码解析

时间:2024-03-14 17:04:57

3.1 图书馆模块设计

实体类:

@Table(name = "a_library")
@TableName("a_library")
@ApiModel(value = "图书馆")
public class Library extends ZwzBaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "图书馆名称")
    private String title;

    @ApiModelProperty(value = "图书馆地址")
    private String address;

    @ApiModelProperty(value = "门头照片")
    private String image;

    @ApiModelProperty(value = "开业状态")
    private String status;

    @ApiModelProperty(value = "备注")
    private String remark;
}

查询接口:

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询图书馆")
public Result<IPage<Library>> getByPage(@ModelAttribute Library library ,@ModelAttribute PageVo page){
    QueryWrapper<Library> qw = new QueryWrapper<>();
    if(!ZwzNullUtils.isNull(library.getTitle())) {
        qw.like("title",library.getTitle());
    }
    if(!ZwzNullUtils.isNull(library.getAddress())) {
        qw.like("address",library.getAddress());
    }
    IPage<Library> data = iLibraryService.page(PageUtil.initMpPage(page),qw);
    return new ResultUtil<IPage<Library>>().setData(data);
}

3.2 图书类型模块设计

实体类设计:

@Table(name = "a_book_type")
@TableName("a_book_type")
@ApiModel(value = "图书类型")
public class BookType extends ZwzBaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "图书类型")
    private String title;

    @ApiModelProperty(value = "类型状态")
    private String status;

    @ApiModelProperty(value = "排序值")
    private BigDecimal sortOrder;

    @ApiModelProperty(value = "备注")
    private String remark;
}

查询接口:

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询图书类型")
public Result<IPage<BookType>> getByPage(@ModelAttribute BookType bookType ,@ModelAttribute PageVo page){
    QueryWrapper<BookType> qw = new QueryWrapper<>();
    if(!ZwzNullUtils.isNull(bookType.getTitle())) {
        qw.like("title",bookType.getTitle());
    }
    if(!ZwzNullUtils.isNull(bookType.getStatus())) {
        qw.eq("status",bookType.getStatus());
    }
    IPage<BookType> data = iBookTypeService.page(PageUtil.initMpPage(page),qw);
    return new ResultUtil<IPage<BookType>>().setData(data);
}

3.3 图书模块设计

实体类设计:

@Table(name = "a_book")
@TableName("a_book")
@ApiModel(value = "图书")
public class Book extends ZwzBaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "图书名称")
    private String title;

    @ApiModelProperty(value = "出版社")
    private String press;

    @ApiModelProperty(value = "图书类型")
    private String type;

    @ApiModelProperty(value = "ISBN")
    private String isbn;

    @ApiModelProperty(value = "图片")
    private String image;

    @ApiModelProperty(value = "备注")
    private String remark;
}

查询接口:

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询图书")
public Result<IPage<Book>> getByPage(@ModelAttribute Book book ,@ModelAttribute PageVo page){
    QueryWrapper<Book> qw = new QueryWrapper<>();
    if(!ZwzNullUtils.isNull(book.getTitle())) {
        qw.like("title",book.getTitle());
    }
    if(!ZwzNullUtils.isNull(book.getIsbn())) {
        qw.like("isbn",book.getIsbn());
    }
    IPage<Book> data = iBookService.page(PageUtil.initMpPage(page),qw);
    return new ResultUtil<IPage<Book>>().setData(data);
}

3.4 图书借阅模块设计

实体类设计:

@Table(name = "a_book_borrowing")
@TableName("a_book_borrowing")
@ApiModel(value = "图书借阅")
public class BookBorrowing extends ZwzBaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "图书ID")
    private String bookId;

    @ApiModelProperty(value = "图书名称")
    private String bookName;

    @ApiModelProperty(value = "图书ISBN")
    private String bookIsbn;

    @ApiModelProperty(value = "借阅人ID")
    private String userId;

    @ApiModelProperty(value = "借阅人")
    private String userName;

    @ApiModelProperty(value = "借阅时间")
    private String time1;

    @ApiModelProperty(value = "借阅状态")
    private String status;

    @ApiModelProperty(value = "归还时间")
    private String time2;
}

查询接口:

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询图书借阅")
public Result<IPage<BookBorrowing>> getByPage(@ModelAttribute BookBorrowing bookBorrowing ,@ModelAttribute PageVo page){
    QueryWrapper<BookBorrowing> qw = new QueryWrapper<>();
    User currUser = securityUtil.getCurrUser();
    qw.eq("user_id",currUser.getId());
    if(!ZwzNullUtils.isNull(bookBorrowing.getBookName())) {
        qw.like("book_name",bookBorrowing.getBookName());
    }
    if(!ZwzNullUtils.isNull(bookBorrowing.getUserName())) {
        qw.like("user_name",bookBorrowing.getUserName());
    }
    IPage<BookBorrowing> data = iBookBorrowingService.page(PageUtil.initMpPage(page),qw);
    return new ResultUtil<IPage<BookBorrowing>>().setData(data);
}

3.5 公告模块设计

实体类设计:

@Table(name = "a_notice")
@TableName("a_notice")
@ApiModel(value = "公告")
public class Notice extends ZwzBaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "公告标题")
    private String title;

    @ApiModelProperty(value = "公告内容")
    private String content;

    @ApiModelProperty(value = "图片")
    private String image;

    @ApiModelProperty(value = "发布状态")
    private String status;
}

查询接口:

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询公告")
public Result<IPage<Notice>> getByPage(@ModelAttribute Notice notice ,@ModelAttribute PageVo page){
    QueryWrapper<Notice> qw = new QueryWrapper<>();
    if(!ZwzNullUtils.isNull(notice.getTitle())) {
        qw.like("title",notice.getTitle());
    }
    if(!ZwzNullUtils.isNull(notice.getContent())) {
        qw.like("content",notice.getContent());
    }
    IPage<Notice> data = iNoticeService.page(PageUtil.initMpPage(page),qw);
    return new ResultUtil<IPage<Notice>>().setData(data);
}