package com.example.bookshop.controller;
import com.example.bookshop.entity.books;
import com.example.bookshop.entity.orders;
import com.example.bookshop.entity.messages;
import com.example.bookshop.entity.adminorder;
import com.example.bookshop.entity.userinfo;
import com.example.bookshop.entity.types;
import com.example.bookshop.entity.nations;
import com.example.bookshop.entity.writers;
import com.example.bookshop.entity.press;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
/**
* 这部分是最开始创建项目时,为了测试项目能否正常运行写的一个测试
*
* 访问http://localhost:8080/hello/springboot 可在页面看见:HelloWord
*
* */
@Controller
@RequestMapping(value = {"/"})
public class HelloController {
@Autowired
private JdbcTemplate jdbcTemplate;
@RequestMapping("/")
public String Index(Model model,HttpServletRequest request) {
String sql = "select * from books";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper);
model.addAttribute("hello",books);
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "index";
}
@RequestMapping("/all")
public String all(Model model,HttpServletRequest request) {
String sql = "select * from books";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper);
model.addAttribute("hello",books);
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "all";
}
@RequestMapping("/category")
public String category(Model model,HttpServletRequest request) {
//获取全部分类
String sql = "select distinct(Type) from books";
RowMapper<types> rowMapper=new BeanPropertyRowMapper<types>(types.class);
List<types> types= jdbcTemplate.query(sql, rowMapper);
model.addAttribute("types",types);
//获取全部作者
String sql2 = "select * from author";
RowMapper<writers> rowMapper2=new BeanPropertyRowMapper<writers>(writers.class);
List<writers> con= jdbcTemplate.query(sql2, rowMapper2);
model.addAttribute("authors",con);
//获取全部出版社
String sql4 = "select * from press";
RowMapper<press> rowMapper4=new BeanPropertyRowMapper<press>(press.class);
List<press> press= jdbcTemplate.query(sql4, rowMapper4);
model.addAttribute("press",press);
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "category";
}
//具体的某个分类页面
@RequestMapping(value="/cate")
public String cate(@RequestParam("id")String id, Model model,HttpServletRequest request) {
String sql = "select * from books where Type=? ";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper,id);
model.addAttribute("hello",books);//添加一个值为"hello thymeleaf"的hello变量到视图
//获取用户名
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "all";
}
@RequestMapping(value="/cateau")
public String cateau(@RequestParam("au")int au, Model model,HttpServletRequest request) {
String sql = "select * from books where authorid=? ";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper,au);
model.addAttribute("hello",books);//添加一个值为"hello thymeleaf"的hello变量到视图
//获取用户名
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "all";
}
@RequestMapping(value="/catepress")
public String catepress(@RequestParam("id")int id, Model model,HttpServletRequest request) {
String sql = "select * from books where pressid=? ";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper,id);
model.addAttribute("hello",books);//添加一个值为"hello thymeleaf"的hello变量到视图
//获取用户名
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "all";
}
@RequestMapping(value="/catena")
public String catena(@RequestParam("id")String id, Model model,HttpServletRequest request) {
String sql = "select * from books where Nation=? ";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper,id);
model.addAttribute("hello",books);//添加一个值为"hello thymeleaf"的hello变量到视图
//获取用户名
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "all";
}
@RequestMapping(value="/search")
public String search(@RequestParam("text")String text, Model model,HttpServletRequest request) {
String sql = "select * from books where Title like ? or Brief like ?";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
List<books> books= jdbcTemplate.query(sql, rowMapper,"%"+text+"%","%"+text+"%");
model.addAttribute("hello",books);
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId()); // 取值
map.put("message", request.getSession().getAttribute("session_user"));
model.addAttribute("user",map.get("message"));
return "search";
}
@RequestMapping(value="/detail")
public String detail(@RequestParam("id")int id, Model model,HttpServletRequest request) {
String sql = "select books.* ,author.Nation,author.Author,press.Press from books,author,press where books.authorid=author.ID and books.pressid=press.ID and books.ID=?";
RowMapper<books> rowMapper=new BeanPropertyRowMapper<books>(books.class);
books book= jdbcTemplate.queryForObject(sql, rowMapper,id);
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot mybatis mysql ssmk框架+sql脚本 网上书店 springboot
资源推荐
资源详情
资源评论
收起资源包目录
网上书店 springboot mybatis mysql ssmk框架 (271个子文件)
HelloController.class 15KB
UserLoginController.class 5KB
adminorder.class 4KB
userLoginInterceptor.class 2KB
books.class 2KB
userinfo.class 2KB
sessionInterceptor.class 2KB
DelTagsUtil.class 1KB
author.class 1KB
User.class 1KB
UserLoginService.class 1KB
testArr.class 1KB
messages.class 1KB
writers.class 1KB
orders.class 1012B
order.class 1009B
userMapper.class 868B
BookshopApplication.class 848B
press.class 775B
nations.class 584B
types.class 579B
BookshopApplicationTests.class 551B
Single.class 526B
booksController.class 334B
booksService.class 319B
mvnw.cmd 7KB
bootstrap.css 188KB
bootstrap.css 188KB
bootstrap.min.css 152KB
bootstrap.min.css 152KB
bootstrap-grid.css 63KB
bootstrap-grid.css 63KB
bootstrap-grid.min.css 47KB
bootstrap-grid.min.css 47KB
bootstrap-reboot.css 5KB
bootstrap-reboot.css 5KB
bootstrap-reboot.min.css 4KB
bootstrap-reboot.min.css 4KB
.gitignore 395B
.gitignore 190B
add.html 10KB
add.html 10KB
index.html 7KB
index.html 7KB
detail.html 6KB
detail.html 6KB
myhome.html 5KB
myhome.html 5KB
register.html 4KB
register.html 4KB
all.html 4KB
all.html 4KB
category.html 4KB
category.html 4KB
adminorder.html 4KB
adminorder.html 4KB
allorder.html 4KB
allorder.html 4KB
userLogin.html 4KB
userLogin.html 4KB
search.html 4KB
search.html 4KB
admin.html 3KB
admin.html 3KB
searcha.html 3KB
searcha.html 3KB
loginError.html 188B
loginError.html 188B
base.html 123B
base.html 123B
bookshop.iml 11KB
maven-wrapper.jar 61KB
HelloController.java 18KB
UserLoginController.java 5KB
adminorder.java 2KB
DelTagsUtil.java 2KB
userLoginInterceptor.java 2KB
sessionInterceptor.java 2KB
userMapper.java 1KB
books.java 1KB
userinfo.java 1KB
UserLoginService.java 949B
author.java 920B
testArr.java 885B
User.java 787B
messages.java 653B
writers.java 618B
orders.java 512B
order.java 511B
BookshopApplication.java 421B
Single.java 342B
press.java 300B
BookshopApplicationTests.java 223B
nations.java 211B
types.java 189B
booksController.java 75B
booksService.java 69B
4.jpg 286KB
4.jpg 286KB
5.jpg 286KB
共 271 条
- 1
- 2
- 3
资源评论
青铜状态
- 粉丝: 0
- 资源: 57
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 蓝zapro.apk
- chromedriver-linux64.zip
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功