python爬虫豆瓣读书top250+数据清洗+数据库+Java后端开发+Echarts数据可视化(四)

之前的博客已经写了python爬取豆瓣读书top250的相关信息和清洗数据、将数据导入数据库并创建相应的数据表,以及进行项目准备工作,接下来开始正式编写后台代码。
如果有没看懂的或是不了解上一部分说的是什么内容的,请看
https://blog.youkuaiyun.com/qq_45804925/article/details/112848887
https://blog.youkuaiyun.com/qq_45804925/article/details/112898570
https://blog.youkuaiyun.com/qq_45804925/article/details/112989112

创建本项目采用的是JavaEE经典三层架构,依次实现对实体类、持久层、业务层、web层、前端页面的开发。
不太了解的话,可以看看我下面的图:在这里插入图片描述
接下来先看一下都需要新建哪些package和相应文件。接下来一步步实现这些。
在这里插入图片描述

依次要实现的分别是关于国家、作者、价格、评分、出版社、出版时间、评价人数的相关数据可视化。

1. 主页面实现效果

在这里插入图片描述

2 各个国家出版图书数量

在这里插入图片描述

2.1 在cn.geo.doubanbook.entity包下创建Country.java类

package cn.geo.doubanbook.entity;

import java.io.Serializable;

/**
 * 各个国家出版的图书数量
 * @author SGG
 *
 */
public class Country implements Serializable{
   
   

	private static final long serialVersionUID = -3474471822110684432L;
	private String country;	
	private Integer num;

	public Country() {
   
   	}
	
	public Country(String country, Integer num) {
   
   
		super();
		this.country = country;
		this.num = num;
	}
	
	@Override
	public String toString() {
   
   
		return "Country [country=" + country + ", num=" + num + "]";
	}

	@Override
	public int hashCode() {
   
   
		final int prime = 31;
		int result = 1;
		result = prime * result + ((country == null) ? 0 : country.hashCode());
		result = prime * result + ((num == null) ? 0 : num.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
   
   
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Country other = (Country) obj;
		if (country == null) {
   
   
			if (other.country != null)
				return false;
		} else if (!country.equals(other.country))
			return false;
		if (num == null) {
   
   
			if (other.num != null)
				return false;
		} else if (!num.equals(other.num))
			return false;
		return true;
	}
	
	public String getCountry() {
   
   
		return country;
	}
	public void setCountry(String country) {
   
   
		this.country = country;
	}
	public Integer getNum() {
   
   
		return num;
	}
	public void setNum(Integer num) {
   
   
		this.num = num;
	}
	
	
}

在这个代码中主要有三步:

  1. 定义两个私有变量
    private String country; private Integer num;
  2. 右键——>source——>无参构造器、带参构造器、get/set方法、hashCode和equals方法、toString方法
    如下图所示:
    在这里插入图片描述
  3. 实现Serializable接口
    PS: 如果单独的实现Serializable接口不会报错,但是会有警报,如下图所示:
    在这里插入图片描述
    选择上图所框出来的即可。

2.2 在cn.geo.doubanbook.dao包下创建CountryDAO.java类

package cn.geo.doubanbook.dao;

import java.sql.*;
import java.util.*;

import cn.geo.doubanbook.entity.Country;
import cn.geo.doubanbook.util.DBUtils;

/**
 * 各个国家出版的图书数量的持久层类
 * @author SGG
 *
 */
public class CountryDAO {
   
   
	
	/**
	 * 查询各个国家出版的图书数量
	 * @return
	 * @throws SQLException
	 */
	public List<Country> listCountry(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值