图书管理系统(基于SpringBoot + MyBatisPlus + Restful + Vue + Jquery + Axios )

一、pojo数据载体准备

@Component
@Data
public class Book {
    @TableId
    private Integer id;
    private String name;
    private String type;
    private String author;
    private String publisher;
    @TableField("is_delete")
    private Integer deleted;
}

二、mapper数据接口映射配置

@Repository
public interface BookMapper extends BaseMapper {
}

三、service

BookService业务接口

public interface BookService extends IService {
}

BookServiceImpl业务实现

@Service
public class BookServiceImpl extends ServiceImpl implements BookService {
}

四、controller控制器

@RestController
@RequestMapping("/books")
public class BookController {
    @Autowired
    private BookService bookService;

    @PostMapping
    public void save(@RequestBody Book book){
        bookService.save(book);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Integer id){
        bookService.removeById(id);
    }

    @DeleteMapping
    public void deleteByIds(@RequestBody int[] ids){
        bookService.removeBatchByIds(Collections.singleton(ids));
    }

    @PutMapping
    public void update(@RequestBody Book book){
        bookService.updateById(book);
    }

    @GetMapping("/{id}")
    public Book getById(@PathVariable Integer id){
        return bookService.getById(id);
    }

   @GetMapping
    public List getAll(){
        return bookService.list();
    }
}

五、配置文件

# TODO 配置数据源相关信息
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/my_db_01?useSSL=false
    username: root
    password: 100863
    type: com.zaxxer.hikari.HikariDataSource
  main:
    banner-mode: off
mybatis-plus:
  global-config:
    db-config:
      table-prefix: tbl_
      logic-delete-field: is_delete
      logic-not-delete-value: 0
      logic-delete-value: 1
    banner: false

六、前端代码

# html

   

添加新图书

书名
类型
作者
出版社
批量删除 确定 取消 确定 取消

# js

 
    
    
    
    
    
    

七、启动

@SpringBootApplication
@MapperScan("cn.itaxu.mapper")
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

 

八、效果展示

图书管理系统(基于SpringBoot + MyBatisPlus + Restful + Vue + Jquery + Axios )_第1张图片

图书管理系统(基于SpringBoot + MyBatisPlus + Restful + Vue + Jquery + Axios )_第2张图片

图书管理系统(基于SpringBoot + MyBatisPlus + Restful + Vue + Jquery + Axios )_第3张图片

结语:

是不是比之前写的更加的简洁了,这就是MyBatisPlus + SpringBoot的强大,真的是简化了开发效率,让你亲身体验快速开发。最后祝看到这篇文章的小伙伴们越来越好,希望这篇文章能够帮助到你!!! 需要源码的可以私信我

你可能感兴趣的:(spring,boot,restful,vue.js)