小程序 微信统计表格_微信小程序简单的数据表格及查询功能

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 15:47   4141   0

简介:

此项目是一个前后端分离的小demo,

开发工具:idea+微信小程序开发工具

前端:界面布局样式和js的跳转

后端:依靠SpringBoot的业务逻辑层

项目的码云地址:

微信开发工具的使用和代码的结构及其含义参考

后端业务逻辑的完成

1.数据库的创建

工具:Navicat

2. dao层及其方法的实现

1>bookinfo的实例化,利用@Entity完成映射

@Entity

@Table(name = "bookinfo")

public class BookinfoEntity {

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

private int bookId;

@Column

private String bookType;

@Column

private String bookName;

@Column

private int bookNum;

@Column

private int bookState;

public int getBookId() {

return bookId;

}

public void setBookId(int bookId) {

this.bookId = bookId;

}

public String getBookType() {

return bookType;

}

public void setBookType(String bookType) {

this.bookType = bookType;

}

public String getBookName() {

return bookName;

}

public void setBookName(String bookName) {

this.bookName = bookName;

}

public int getBookNum() {

return bookNum;

}

public void setBookNum(int bookNum) {

this.bookNum = bookNum;

}

public int getBookState() {

return bookState;

}

public void setBookState(int bookState) {

this.bookState = bookState;

}

}

bookinfoentity

2>bookstate的实例化

@Entity

@Table(name = "bookstate")

public class BookstateEntity {

@Id

private int bookState;

@Column

private String bookStateinfo;

public int getBookState() {

return bookState;

}

public void setBookState(int bookState) {

this.bookState = bookState;

}

public String getBookStateinfo() {

return bookStateinfo;

}

public void setBookStateinfo(String bookStateinfo) {

this.bookStateinfo = bookStateinfo;

}

}

bookstateEntity

3>利用repository实现对对象的持久化操作,是OO的真正实现

@Repository

public interface BookInfoRepository extends JpaRepository {

}

@Repository

public interface BookstateRepository extends JpaRepository {

}

3.service层的实现、

3.1 BookinfoService接口

package com.example.demo.service;

import com.example.demo.vo.BookinfoVo;

import java.util.List;

/**

* Author: wuhen

* Date: 2018/10/9

* Time: 20:40

*/

public interface BookinfoService {

//查询书籍

BookinfoVo findbookOne(Integer bookId);

//查询所有书籍

List findbookAll();

}

BookinfoService

3.2 接口的实现

package com.example.demo.service.impl;

import com.example.demo.entity.BookinfoEntity;

import com.example.demo.entity.BookstateEntity;

import com.example.demo.repository.BookinfoRepository;

import com.example.demo.repository.BookstateRepository;

import com.example.demo.service.BookinfoService;

import com.example.demo.util.BookConverter;

import com.example.demo.vo.BookinfoVo;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.util.ArrayList;

import java.util.List;

/**

* Author: wuhen

* Date: 2018/10/9

* Time: 20:48

*/

@Service

public class BookinfoServiceImpl implements BookinfoService {

@Autowired

private BookinfoRepository bookinfoRepository;

@Autowired

private BookstateRepository bookstateRepository;

BookConverter bookConverter=new BookConverter();

@Override

public BookinfoVo findbookOne(Integer bookId) {

BookinfoEntity bookinfoEntity= bookinfoRepository.findById(bookId).get();

BookstateEntity bookstateEntity = bookstateRepository.findById(bookinfoEntity.getBookState()).get();

BookinfoVo bookinfoVo;

bookinfoVo = bookConverter.convert(bookinfoEntity, BookinfoVo.class);

bookinfoVo.setBookStateinfo(bookstateEntity.getBookStateinfo());

return bookinfoVo;

}

@Override

public List findbookAll() {

List bookinfoEntitys=bookinfoRepository.findAll();

List bookinfoVos=new ArrayList<>();

for (BookinfoEntity bookinfoEntity:bookinfoEntitys)

{

BookinfoVo9.l#-'k)fy9b9k"#ybyfj9k9$ :)"#yfj9k9$  .b9+#[\Y\ey.Ko/# 9aj99/繣y-#ybyyo#k*9o/z(m9/(9K9d#9ml/od b9c%. 99leyoho# 9."&ch9bykf9\ 9l#yd f:#d g -.+yf,9f.idy."f,9f-/g9.. 9.*.+yfb9g,9f dy."+ \T YLY L9.+yfb9g,9f﹥b99i)yb- ]Y\yg`9cc J]Y\y.[\XNhI[\\[\XN]Y\ykhxkhI[\XN#"[\XNj O ]Y\y..b9+]Y\O]Y\yl,y+*]T\9al9ny.b9b*9o 9 z e9S[\]Y\z f.b]Y\y+b9]Y\y+:. #-iI[]]HX\Y\.+yc!y9 ab9."f:/9aiIY[[KW[\9../9. 9iNb9aiI\c!yb,Xh9!.\/oyaiyb,[]]HX\Y\9.9iH [9kyaj9/K9/9/k9k):bm9b*+:+l,y`k+9.#$y.d9k+ : #9.#y+d 9k9m9)ι/k.K 9.#yc)+9)ιk/k'nm.%9l!iy.#z )+ ]\(ygeXN#y//9k O .#y`db 9+9.bn*XY#cyhc [\\f:%*9-iyke,9n.9iyy-k HYX\\\N N X[\\[[:acy QX[\\[b! $y.oX. :"+:`&/o[:acyg+9/kihnyd#y\X[K9.+yoY\Kcc[ K#ybJXK9i.". H ^HX\9c*:eXXiab9g*9/ ZH     9+9ob,:/"#9g*9`9n" NH :a:/c f[\ [\[ZN I[\ [\[ZN9 9- [\\l9ZI[\\o%z* i." 9.*.:`&9.g,g"y.cl%9.+y.+z/k9(yl9 9l$y-"y.l9+ y.:`&-.y: #9kc.:a"'&y+'k."gh/ :`k9c%..`f+K9.) Y\a#y:-.ze g*9`fb!n %+9&K9 9.*`"y. 9.*Y\:` \9acy`+9acy9g*99k9y." 9.*Y\`a.#yd#99k/a+ ]

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP