基于javaweb的水果蔬菜商城批发系统(java+ssm+jsp+jquery+mysql)

基于javaweb的水果蔬菜商城批发系统(java+ssm+jsp+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

20220819204615

20220819204616

20220819204617

20220819204618

20220819204619

20220819204620

基于javaweb+mysql的水果蔬菜商城批发系统(java+SSM+JSP+jQuery+mysql)

项目介绍

本项目分为前后台,前台为普通用户登录,后台为管理员登录;

管理员角色包含以下功能: 管理员登录,管理员管理,网站用户管理,新闻公告管理,果蔬类型管理,城市信息管理,配货点管理,果蔬商品管理,果蔬订单管理,果蔬评价管理等功能。

用户角色包含以下功能: 用户首页,用户登录注册,查看某一个商品,加入购物车,填写配货信息,查看我的订单,查看系统公告,查看销售网络等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;  5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录 用户账号/密码: user/123456 管理员账号/密码:admin/admin

用户和管理员控制层:

/**

  • 用户和管理员控制层

*/

@Controller

public class UserController {

@Resource(name = “userService”)

UserService userService;

@Resource(name = “goodsCarService”)

GoodsCarService goodsCarService;

// @Resource(name = “goodsService”)

// GoodsService goodsService;

@Resource(name = “orderService”)

OrderService orderService;

/**

  • 用户注册

*/

@RequestMapping(“/userRegister”)

@ResponseBody

public Map<String, Object> doReg(String username, String password, String email, HttpServletRequest request) {

Map<String, Object> map = new HashMap<String, Object>();

User u = userService.findUserByUsername(username);

if (u != null) {

map.put(“status”, 1);

map.put(“message”, “注册失败,该账户名已存在”);

} else {

String id = App.getUid();

int dr = 0;

User user = new User(id, username, password, dr, email);

int result = userService.doReg(user);

if (result == 1) {

HttpSession session = request.getSession();

session.setAttribute(“username”, username);

session.setAttribute(“email”, email);

map.put(“status”, 0);

map.put(“message”, “注册成功”);

return map;

/**

  • 用户登录

  • checked 为1 代表记住用户名,为0 代表忘记用户名

*/

@RequestMapping(“/userLogin”)

@ResponseBody

public Map<String, Object> doLogin(String username, String pwd, String checkcode, int checked, HttpServletRequest request) {

Map<String, Object> map = new HashMap<String, Object>();

HttpSession session = request.getSession();

String checkcode_server = (String) session.getAttribute(“CHECKCODE”);

session.removeAttribute(“CHECKCODE”);//为了保证验证码只能使用一次

User u = userService.findUserByUsername(username);

if (u == null || u.getDr() == 1) {

map.put(“status”, 1);

map.put(“message”, “登录失败,请检查信息是否正确”);

} else {

if (u.getPassword().equals(pwd) && checkcode.equalsIgnoreCase(checkcode_server)) {

String userid = u.getId();

List goodscars = goodsCarService.findGoodscarByUserId(userid);

App.goodscarList = goodscars;

session.setAttribute(“goodscarList”, App.goodscarList);

session.setAttribute(“count”, App.goodscarList.size());

session.setAttribute(“username”, username);

session.setAttribute(“email”, u.getEmail());

List orders = new ArrayList();

List ordersEndList = orderService.ordersEndListById(userid);

if (ordersEndList.size()>0){

session.setAttribute(“ordersEndListById”,ordersEndList);

List gcs = orderService.selectOrderByuserId(u.getId());

for (Ordergoods gs : gcs) {

orders.add(gs);

if (orders.size() > 0) {

session.setAttribute(“orders”, orders);

if (checked == 1) {

App.USERNAME = username;

} else if (checked == 0) {

App.USERNAME = null;

map.put(“status”, 0);

map.put(“message”, “登录成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “登录失败,请检查信息是否正确”);

return map;

/**

  • 管理员登录

  • checked 为 1 代表记住用户名和密码,为0 反之

*/

@RequestMapping(“/userAdminLogin”)

@ResponseBody

public Map<String, Object> adminLogin(String username, String password, int checked, HttpServletRequest request) {

HttpSession session = request.getSession();

Map<String, Object> map = new HashMap<String, Object>();

User u = userService.findUserByUsername(username);

if (u == null || u.getDr() == 0) {

map.put(“status”, 1);

map.put(“message”, “登录失败,请检查信息是否正确”);

} else {

if (u.getPassword().equals(password)) {

session.setAttribute(“adminUsername”, username);

session.setAttribute(“adminEmail”, u.getEmail());

if (checked == 1) {

App.ADMIN_USERNAME = username;

App.ADMIN_PASSWORD = password;

} else if (checked == 0) {

App.ADMIN_USERNAME = null;

App.ADMIN_PASSWORD = null;

map.put(“status”, 0);

map.put(“message”, “登录成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “登录失败,请检查信息是否正确”);

return map;

/**

  • 管理员修改密码

*/

@RequestMapping(“/userAdminForgetPwd”)

@ResponseBody

public Map<String, Object> adminForgetPwd(String username, String password, String email, String checkcode, HttpServletRequest request) {

Map<String, Object> map = new HashMap<String, Object>();

HttpSession session = request.getSession();

String checkcode_server = (String) session.getAttribute(“CHECKCODE”);

session.removeAttribute(“CHECKCODE”);//为了保证验证码只能使用一次

User u = userService.findUserByUsername(username);

if (u != null && checkcode.equalsIgnoreCase(checkcode_server) && email.equals(u.getEmail()) && u.getDr() == 1) {

User user = new User(username, password);

int result = userService.updatePassword(user);

if (result == 1) {

map.put(“status”, 0);

map.put(“message”, “修改成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “修改失败,请检查信息是否正确”);

} else {

map.put(“status”, 1);

map.put(“message”, “修改失败,请检查信息是否正确”);

return map;

/**

  • 用户修改密码

*/

@RequestMapping(“/userForgetPwd”)

@ResponseBody

public Map<String, Object> forgetPwd(String username, String password, String email, String checkcode, HttpServletRequest request) {

Map<String, Object> map = new HashMap<String, Object>();

HttpSession session = request.getSession();

String checkcode_server = (String) session.getAttribute(“CHECKCODE”);

session.removeAttribute(“CHECKCODE”);//为了保证验证码只能使用一次

User u = userService.findUserByUsername(username);

if (u != null && checkcode.equalsIgnoreCase(checkcode_server) && email.equals(u.getEmail()) && u.getDr() == 0) {

User user = new User(username, password);

int result = userService.updatePassword(user);

if (result == 1) {

map.put(“status”, 0);

map.put(“message”, “修改成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “修改失败,请检查信息是否正确”);

} else {

map.put(“status”, 1);

map.put(“message”, “修改失败,请检查信息是否正确”);

return map;

/**

  • 用户退出

*/

@RequestMapping(“/userQuit”)

public String userQuit(HttpServletRequest request){

HttpSession session = request.getSession();

String auname = (String) session.getAttribute(“adminUsername”);

if (auname == null){

session.invalidate();

App.goodscarList = null;

App.ADDRESS = null;

HttpSession session1 = request.getSession();

session1.setAttribute(“saveUsername”, App.USERNAME);

}else {

session.removeAttribute(“username”);

session.removeAttribute(“saveUsername”);

session.removeAttribute(“email”);

session.removeAttribute(“goodsBrowse”);

session.removeAttribute(“goodscarList”);

session.removeAttribute(“count”);

session.removeAttribute(“goodscarCount”);

session.removeAttribute(“orders”);

session.removeAttribute(“ordersEndListById”);

App.goodscarList = null;

App.ADDRESS = null;

session.setAttribute(“saveUsername”, App.USERNAME);

return “redirect:toIndex”;

/**

  • 管理员退出

*/

@RequestMapping(“/userAdminQuit”)

public String userAdminQuit(HttpServletRequest request){

HttpSession session = request.getSession();

// session.invalidate();

session.removeAttribute(“adminUsername”);

session.removeAttribute(“adminEmail”);

session.removeAttribute(“saveadminUsername”);

session.removeAttribute(“saveadminPassword”);

session.removeAttribute(“ordersList”);

session.removeAttribute(“ordersWaitList”);

session.removeAttribute(“ordersEndList”);

session.setAttribute(“saveadminUsername”, App.ADMIN_USERNAME);

session.setAttribute(“saveadminPassword”, App.ADMIN_PASSWORD);

return “redirect:toAdminLogin”;

订单管理控制层:

@Controller

public class OrdergoodsController {

@Resource(name = “orderService”)

OrderService orderService;

@Resource(name = “userService”)

UserService userService;

@Resource(name = “goodsCarService”)

GoodsCarService goodsCarService;

@Resource(name = “goodsService”)

GoodsService goodsService;

/**

  • 取消订单

*/

@RequestMapping(“/cancelOrder”)

@ResponseBody

public synchronized Map<String, Object> cancelOrder(String id,String username, HttpServletRequest request) {

Map<String, Object> map = new HashMap<String, Object>();

User us = userService.findUserByUsername(username);

Ordergoods ordergoods = orderService.selectGoodsId(id);

if (us.getDr() == 1){

//管理员确定订单

if (ordergoods != null && ordergoods.getDr() != 1){

int result = orderService.orderEnsure(id);

Ordergoods og = orderService.selectOrderById(id);

Map<String, Object> map2 = new HashMap<String, Object>();

double count = (og.getGoods().getCount()-og.getGoodscar().getCount());

map2.put(“id”,og.getGoods().getId());

map2.put(“count”,count);

int result1 = goodsService.updateGoodsCount(map2);

if (result1 && result11){

HttpSession session = request.getSession();

List ordersWaitList = orderService.ordersWaitList();

session.setAttribute(“ordersWaitList”,ordersWaitList);

map.put(“status”, 0);

map.put(“message”, “发货成功”);

}else {

map.put(“status”, 1);

map.put(“message”, “发货失败”);

}else {

map.put(“status”, 1);

map.put(“message”, “发货失败”);

}else {

//用户确定订单

if (ordergoods != null && ordergoods.getDr() != 3){

int result = orderService.cancelOrder(id);

if (result == 1) {

Ordergoods or = orderService.selectGoodsId(id);

String goodscar_id = or.getGoodscarid();

int info = goodsCarService.updateGoodscarDr(goodscar_id);

if (info == 1) {

HttpSession session = request.getSession();

String uname = (String) session.getAttribute(“username”);

User u = userService.findUserByUsername(uname);

List orders = new ArrayList();

List gcs = orderService.selectOrderByuserId(u.getId());

for (Ordergoods gs : gcs) {

orders.add(gs);

session.setAttribute(“orders”, orders);

List goodscars = goodsCarService.findGoodscarByUserId(u.getId());

App.goodscarList = goodscars;

session.setAttribute(“goodscarList”, App.goodscarList);

session.setAttribute(“count”, App.goodscarList.size());

map.put(“status”, 0);

map.put(“message”, “订单取消成功”);

return map;

map.put(“status”, 1);

map.put(“message”, “订单取消失败”);

return map;

/**

  • 添加地址

*/

@RequestMapping(“/addressOver”)

@ResponseBody

public Map<String, Object> addressOver(String address, String ids, HttpServletRequest request) {

Map<String, Object> map = new HashMap<String, Object>();

String[] gcids = ids.split(“,”);

Map<String, Object> map1 = new HashMap<String, Object>();

map1.put(“address”,address);

map1.put(“gcids”,gcids);

int result = orderService.addAddress(map1);

if (result <= 0){

map.put(“status”, 1);

map.put(“message”, “添加地址失败”);

}else {

App.ADDRESS = address;

HttpSession session = request.getSession();

session.setAttribute(“address”,App.ADDRESS);

map.put(“status”, 0);

map.put(“message”, “添加地址成功”);

return map;

/**

  • 全部的订单列表

*/

@RequestMapping(“/ordersList”)

@ResponseBody

public Map<String, Object> ordersList(HttpServletRequest request){

Map<String, Object> map = new HashMap<String, Object>();

HttpSession session = request.getSession();

List ordersList = orderService.ordersList();

if (ordersList.size()<=0){

map.put(“status”, 1);

map.put(“message”, “暂无订单”);

}else {

session.setAttribute(“ordersList”,ordersList);

map.put(“status”, 0);

map.put(“message”, “订单查询成功”);

return map;

/**

  • 待发货的订单

*/

@RequestMapping(“/ordersWaitList”)

@ResponseBody

public Map<String, Object> ordersWaitList(HttpServletRequest request){

Map<String, Object> map = new HashMap<String, Object>();

HttpSession session = request.getSession();

List ordersWaitList = orderService.ordersWaitList();

if (ordersWaitList.size()<=0){

session.setAttribute(“ordersWaitList”,ordersWaitList);

map.put(“status”, 1);

map.put(“message”, “暂无订单”);

}else {

session.setAttribute(“ordersWaitList”,ordersWaitList);

map.put(“status”, 0);

map.put(“message”, “订单查询成功”);

return map;

/**

  • 已发货的订单

*/

@RequestMapping(“/ordersEndList”)

@ResponseBody

public Map<String, Object> ordersEndList(HttpServletRequest request){

Map<String, Object> map = new HashMap<String, Object>();

HttpSession session = request.getSession();

List ordersEndList = orderService.ordersEndList();

if (ordersEndList.size()<=0){

map.put(“status”, 1);

map.put(“message”, “暂无订单”);

}else {

session.setAttribute(“ordersEndList”,ordersEndList);

map.put(“status”, 0);

map.put(“message”, “订单查询成功”);

return map;

// /**

// * 进行发货

// */

// @RequestMapping(“/orderEnsure”)

// @ResponseBody

// public Map<String, Object> orderEnsure(String id,String reserved1,HttpServletRequest request){

// Map<String, Object> map = new HashMap<String, Object>();

// HttpSession session = request.getSession();

// int result = orderService.orderEnsure(id);

// if (result == 1){

// map.put(“status”, 0);

// map.put(“message”, “发货成功”);

// }else {

// map.put(“status”, 1);

// map.put(“message”, “发货失败”);

// }

// return map;

// }

商品管理控制层:

@Controller

public class GoodsController {

@Resource(name = “goodsService”)

GoodsService goodsService;

List gdsList = null;

List goodsBrowse;

public GoodsController() {

goodsBrowse = new ArrayList();

/**

  • 分页查询商品列表信息

*/

@RequestMapping(“/goodsList”)

@ResponseBody

public Map<String, Object> goodsList(int currentPage, String search) {

Map<String, Object> resultMap = new HashMap<String, Object>();

PageBean pageBean = new PageBean();

int pageSize = 5;

int start = (currentPage - 1) * pageSize;

int size = pageSize;

if (search == “” || search == null) {

Map<String, Object> map = new HashMap<String, Object>();

map.put(“start”,start);

map.put(“size”,size);

List lists = goodsService.findByPage(map);

// List list = goodsService.selectCount();

int count = goodsService.selectCount();

if (count <= 0) {

resultMap.put(“status”, 1);

resultMap.put(“message”, “没有数据”);

resultMap.put(“result”, null);

} else {

int totalCount = count;

double tc = totalCount;

int totalPage = (int) Math.ceil(tc / pageSize);

pageBean.setCurrentage(currentPage);

pageBean.setPageSize(pageSize);

pageBean.setTotalCount(totalCount);

pageBean.setTotalPage(totalPage);

pageBean.setLists(lists);

resultMap.put(“status”, 0);

resultMap.put(“message”, “有数据”);

resultMap.put(“result”, pageBean);

} else {

// String search1 = “”;

// search1 += (“%” + search + “%”);

// System.out.println(search1);

Map<String, Object> map = new HashMap<String, Object>();

map.put(“start”,start);

map.put(“size”,size);

map.put(“search”,search);

List lists = goodsService.findByPageSearch(map);

// List list = goodsService.selectSearchCount(search1);

int count = goodsService.selectSearchCount(search);

if (count <= 0) {

resultMap.put(“status”, 1);

resultMap.put(“message”, “没有数据”);

resultMap.put(“result”, null);

} else {

int totalCount = count;

double tc = totalCount;

int totalPage = (int) Math.ceil(tc / pageSize);

pageBean.setCurrentage(currentPage);

pageBean.setPageSize(pageSize);

pageBean.setTotalCount(totalCount);

pageBean.setTotalPage(totalPage);

pageBean.setLists(lists);

resultMap.put(“status”, 0);

resultMap.put(“message”, “有数据”);

resultMap.put(“result”, pageBean);

return resultMap;

/**

  • 添加商品

*/

@RequestMapping(“/addGoods”)

@ResponseBody

public Map<String, Object> addGoods(MultipartFile file, Goods goods) {

Map<String, Object> map = new HashMap<String, Object>();

try {

//获取文件名

String pname = file.getOriginalFilename();

//获取文件格式

String type = pname.substring(pname.lastIndexOf(“.”));

//重命名

String photo_name = App.getUid() + type;

//将图片存到指定的位置

//windows系统配置图片路径

file.transferTo(new File(“D:\project\fresh\GoodsPhoto”, photo_name));

//mac系统配置图片路径

//file.transferTo(new File(“/Users/hanmeng/Desktop/java源码/Springboot生鲜水果商城/源码/GoodsPhoto”, photo_name));

//将图片信息存入商品对象

goods.setPhoto(photo_name);

//商品id

goods.setId(App.getUid());

//商品状态

goods.setDr(1);

int i = goodsService.addGoods(goods);

if (i == 1) {

map.put(“status”, 0);

map.put(“message”, “添加成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “添加失败”);

} catch (IOException e) {

e.printStackTrace();

return map;

/**

  • 分页查询上架或下架商品列表信息

*/

@RequestMapping(“/goodsTypeList”)

@ResponseBody

public Map<String, Object> goodsTypeList(int currentPage, String search, int typeDr) {

Map<String, Object> resultMap = new HashMap<String, Object>();

PageBean pageBean = new PageBean();

int pageSize = 5;

int start = (currentPage - 1) * pageSize;

int size = pageSize;

if (search == “” || search == null) {

Map<String, Object> map = new HashMap<String, Object>();

map.put(“start”,start);

map.put(“size”,size);

map.put(“typeDr”,typeDr);

List lists = goodsService.findByPageDr(map);

// List list = goodsService.selectCountDr(typeDr);

int count = goodsService.selectCountDr(typeDr);

if (count <= 0) {

resultMap.put(“status”, 1);

resultMap.put(“message”, “没有数据”);

resultMap.put(“result”, null);

} else {

int totalCount = count;

double tc = totalCount;

int totalPage = (int) Math.ceil(tc / pageSize);

pageBean.setCurrentage(currentPage);

pageBean.setPageSize(pageSize);

pageBean.setTotalCount(totalCount);

pageBean.setTotalPage(totalPage);

pageBean.setLists(lists);

resultMap.put(“status”, 0);

resultMap.put(“message”, “有数据”);

resultMap.put(“result”, pageBean);

} else {

// String search1 = “”;

// search1 += (“%” + search + “%”);

Map<String, Object> map = new HashMap<String, Object>();

map.put(“start”,start);

map.put(“size”,size);

map.put(“typeDr”,typeDr);

map.put(“search”,search);

List lists = goodsService.findByPageSearchDr(map);

Map<String, Object> map1 = new HashMap<String, Object>();

map1.put(“typeDr”,typeDr);

map1.put(“search”,search);

// List list = goodsService.selectSearchCountDr(map1);

int count = goodsService.selectSearchCountDr(map1);

if (count <= 0) {

resultMap.put(“status”, 1);

resultMap.put(“message”, “没有数据”);

resultMap.put(“result”, null);

} else {

int totalCount = count;

double tc = totalCount;

int totalPage = (int) Math.ceil(tc / pageSize);

pageBean.setCurrentage(currentPage);

pageBean.setPageSize(pageSize);

pageBean.setTotalCount(totalCount);

pageBean.setTotalPage(totalPage);

pageBean.setLists(lists);

resultMap.put(“status”, 0);

resultMap.put(“message”, “有数据”);

resultMap.put(“result”, pageBean);

return resultMap;

/**

  • 商品上架

*/

@RequestMapping(“/goodsUp”)

@ResponseBody

public Map<String, Object> goodsUp(String id) {

Map<String, Object> map = new HashMap<String, Object>();

int result = goodsService.goodsUp(id);

if (result == 1) {

map.put(“status”, 0);

map.put(“message”, “上架成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “上架失败”);

return map;

/**

  • 商品下架

*/

@RequestMapping(“/goodsDown”)

@ResponseBody

public Map<String, Object> goodsDown(String id) {

Map<String, Object> map = new HashMap<String, Object>();

int result = goodsService.goodsDown(id);

if (result == 1) {

map.put(“status”, 0);

map.put(“message”, “下架成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “下架失败”);

return map;

/**

  • 商品删除

*/

@RequestMapping(“/goodsDelete”)

@ResponseBody

public Map<String, Object> goodsDelete(String id) {

Map<String, Object> map = new HashMap<String, Object>();

int result = goodsService.goodsDelete(id);

if (result == 1) {

map.put(“status”, 0);

map.put(“message”, “删除成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “删除失败”);

return map;

/**

  • 商品批量删除

*/

@RequestMapping(“/deleteAll”)

@ResponseBody

public Map<String, Object> deleteAll(String ids) {

Map<String, Object> map = new HashMap<String, Object>();

String[] id_s = ids.split(“,”);

int result = goodsService.deleteAll(id_s);

if (result >= 1) {

map.put(“status”, 0);

map.put(“message”, “删除成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “删除失败”);

return map;

/**

  • 管理员查看商品详情

*/

@RequestMapping(“/goodsDetail”)

@ResponseBody

public Map<String, Object> goodsDetail(String photo) {

Map<String, Object> map = new HashMap<String, Object>();

Goods goods = goodsService.goodsDetail(photo);

if (goods != null) {

map.put(“status”, 0);

map.put(“message”, “加载成功”);

map.put(“result”, goods);

} else {

map.put(“status”, 1);

map.put(“message”, “加载失败”);

map.put(“result”, null);

return map;

/**

  • 加载商品信息

*/

@RequestMapping(“/loadGoods”)

@ResponseBody

public Map<String, Object> loadGoods(String id) {

Map<String, Object> map = new HashMap<String, Object>();

Goods goods = goodsService.loadGoods(id);

if (goods != null) {

map.put(“status”, 0);

map.put(“message”, “加载编辑成功”);

map.put(“result”, goods);

} else {

map.put(“status”, 1);

map.put(“message”, “加载编辑失败”);

map.put(“result”, null);

return map;

/**

  • 商品编辑

*/

@RequestMapping(“/goodsUpdate”)

@ResponseBody

public Map<String, Object> goodsUpdate(String id, String price, String count) {

Map<String, Object> map = new HashMap<String, Object>();

double price_double = Double.parseDouble(price);

double count_double = Double.parseDouble(count);

Map<String, Object> map1 = new HashMap<String, Object>();

map1.put(“id”,id);

map1.put(“price”,price_double);

map1.put(“count”,count_double);

int result = goodsService.goodsUpdate(map1);

if (result == 1) {

map.put(“status”, 0);

map.put(“message”, “编辑成功”);

} else {

map.put(“status”, 1);

map.put(“message”, “编辑失败”);

return map;

/**

  • 商品主页加载

*/

@RequestMapping(“/indexList”)

@ResponseBody

public Map<String, Object> indexList() {

Map<String, Object> map = new HashMap<String, Object>();

List goodslist = goodsService.indexList();

if (goodslist.size() <= 0) {

map.put(“status”, 1);

map.put(“message”, “暂无上架商品”);

map.put(“result”, null);

} else {

map.put(“status”, 0);

map.put(“message”, “正在加载,请稍后”);

map.put(“result”, goodslist);

return map;

/**

  • 查看更多

*/

// @RequestMapping(“/readMore”)

// public String readMore(String groupid, Model model) {

// List goodslist = goodsService.readMore(groupid);

// if (goodslist.size() <= 0) {

// return “redirect:toIndex”;

// } else {

// List goodsPart = new ArrayList();

// if (goodslist.size()>=2){

// goodsPart.add(goodslist.get(goodslist.size() - 2));

// goodsPart.add(goodslist.get(goodslist.size() - 1));

// }else if((goodslist.size()==1)){

// goodsPart.add(goodslist.get(goodslist.size() - 1));

// }

// model.addAttribute(“groupid”, groupid);

// model.addAttribute(“goodsPart”, goodsPart);

// model.addAttribute(“goodslist”, goodslist);

// }

// return “readmoreShop”;

// }

@RequestMapping(“/readMore”)

@ResponseBody

public Map<String, Object> readMore(String groupid) {

Map<String, Object> map = new HashMap<String, Object>();

List goodslist = goodsService.readMore(groupid);

if (goodslist.size() <= 0) {

map.put(“status”,1);

map.put(“message”,“抱歉没有相关的商品”);

} else {

map.put(“status”,0);

map.put(“message”,“商品展现成功”);

gdsList = goodslist;

return map;

@GetMapping(“/readMoreByMessage”)

public String readMoreByMessage(String groupid, Model model){

List goodslist = goodsService.readMore(groupid);

List goodsPart = new ArrayList();

if (goodslist.size()>=2){

goodsPart.add(goodslist.get(goodslist.size() - 2));

goodsPart.add(goodslist.get(goodslist.size() - 1));

}else if((goodslist.size()==1)){

goodsPart.add(goodslist.get(goodslist.size() - 1));

model.addAttribute(“groupid”, groupid);

model.addAttribute(“goodsPart”, goodsPart);

model.addAttribute(“goodslist”, goodslist);

return “readmoreShop”;

@RequestMapping(“/readMoreSecond”)

public String readMoreSecond(String groupid, Model model){

if (gdsList!=null){

List goodsPart = new ArrayList();

if (gdsList.size()>=2){

goodsPart.add(gdsList.get(gdsList.size() - 2));

goodsPart.add(gdsList.get(gdsList.size() - 1));

}else if((gdsList.size()==1)){

goodsPart.add(gdsList.get(gdsList.size() - 1));

model.addAttribute(“groupid”, groupid);

model.addAttribute(“goodsPart”, goodsPart);

model.addAttribute(“goodslist”, gdsList);

return “readmoreShop”;

return null;

/**

  • 用户查看商品详情

*/

@RequestMapping(“/shopMessage”)

public String shopMessage(String id, Model model, HttpServletRequest request) {

HttpSession session = request.getSession();

Goods goods = goodsService.shopMessage(id);

if (goods == null) {

return “redirect:toIndex”;

} else {

if (goodsBrowse.size() >= 1) {

for (int i = 0; i < goodsBrowse.size(); i++) {

if (goods.getName().equals(goodsBrowse.get(i).getName())) {

goodsBrowse.remove(i);

goodsBrowse.add(goods);

if (goodsBrowse.size() > 4) {

goodsBrowse.remove(0);

session.setAttribute(“goodsBrowse”, goodsBrowse);

String groupid = goods.getGroupid();

List goodslist = goodsService.readMore(groupid);

List goodsNews = new ArrayList();

if (goodslist.size()>=2){

goodsNews.add(goodslist.get(goodslist.size() - 2));

goodsNews.add(goodslist.get(goodslist.size() - 1));

}else if(goodslist.size()==1){

goodsNews.add(goodslist.get(goodslist.size() - 1));

model.addAttribute(“goodsNews”, goodsNews);

model.addAttribute(“goods”, goods);

return “shop_message”;

/**

  • 商品主页搜索

*/

@RequestMapping(“/goodsSearch”)

public String goodsSearch(String search, Model model) {

if (search == “” || search == null) {

return “redirect:toNoPage”;

List goodslist = goodsService.goodsSearch(search);

if (goodslist.size() <= 0) {

return “redirect:toNoPage”;

} else {

model.addAttribute(“goodslist”, goodslist);

return “searchmoreShop”;


网选课系统是一个非常实用的系统,可以方便学生进行选课操作,也可以方便教师进行课程管理。下面是一个基于JavaWeb的网上选课系统的设计思路: 1. 系统架构 该系统采用 B/S 架构,即浏览器/服务器架构。前端使用 HTML、CSS、JavaScript 和 JQuery,后端使用 Java+SSM 框架和 MySQL 数据库。 2. 系统功能 (1)学生模块:学生可以登录系统后进行选课操作,查看已选课程,并对已选课程进行退选操作。 (2)教师模块:教师可以登录系统后进行课程管理操作,包括添加课程、修改课程、删除课程等操作。 (3)管理员模块:管理员可以登录系统后对学生和教师进行管理,包括添加学生、添加教师、修改学生信息、修改教师信息等操作。 (4)公告管理:管理员可以发布公告,学生和教师可以浏览公告。 (5)选课规则管理:管理员可以设置选课规则,例如每个学生最多选择多少门课程,每门课程最多选多少人等。 3. 数据库设计 该系统需要设计以下数据库表: (1)学生表:包括学生编号、学生姓名、学生性别、学生年龄、所在班级等字段。 (2)教师表:包括教师编号、教师姓名、教师性别、所教课程、教龄等字段。 (3)课程表:包括课程编号、课程名称、授课教师、上课时间、选课人数等字段。 (4)选课记录表:包括学生编号、课程编号等字段。 (5)公告表:包括公告编号、公告内容、发布时间等字段。 4. 技术实现 该系统采用 Java+SSM 框架进行实现,其中: (1)后端技术:采用 SpringMVC 框架进行控制器的开发,采用 MyBatis 框架进行数据库操作。 (2)前端技术:采用 HTML、CSS、JavaScript 和 JQuery 进行页面布局和交互效果的实现。 (3)数据库技术:采用 MySQL 数据库进行数据存储和管理。 5. 总结 网上选课系统是一个非常实用的系统,它可以方便学生进行选课操作,也可以方便教师进行课程管理。该系统采用 B/S 架构,采用 Java+SSM 框架进行开发,实现了学生模块、教师模块、管理员模块、公告管理和选课规则管理等功能。在实现时需要注意数据库表的设计和技术实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值