public interface IBookService extends IService<Book> { }
@Service public class BookService extends ServiceImpl<BookDao, Book> implements IBookService { }
public interface IBookService extends IService<Book> { Boolean insertBook(Book book); }
@Service public class BookService extends ServiceImpl<BookDao, Book> implements IBookService { @Autowired private BookDao bookDao; @Override public Boolean insertBook(Book book) { return bookDao.insert(book) > 0; } }
前后端数据协议:表现层返回结果的模型类,用与后端与前端进行数据格式统一。一般由表示有无异常的flag(Boolean)和表示数据结果的data(Object)组成,但不固定。
@Data public class R { private Boolean flag; private Object data; }
针对返回数据的不同情况,重载模型类的构造方法,实现数据一致性
@Data public class R { private Boolean flag; private Object data; public R(){} public R(Boolean flag){ this.flag = flag; } public R(Boolean flag,Object data){ this.flag = flag; this.data = data; } }