1. 获取代码:

自助获取:

点我去下载

2. 技术栈

后端
Spring + SpringMVC + Mybatis
前端
layui+jsp+jquery

3. 开发环境

IntellJ Idea + Tomact9 + MySQL5.7 + JDK1.8 + Maven3.5

4. 系统功能

杨校老师之基于SSM开发的校园点餐配送系统_SSM入门案例

5. 预览效果

杨校老师之基于SSM开发的校园点餐配送系统_SSM入门案例_02

杨校老师之基于SSM开发的校园点餐配送系统_intellij-idea_03

杨校老师之基于SSM开发的校园点餐配送系统_intellij-idea_04


6.部分源码

package org.mryang.schoolorder.controller;

import org.mryang.schoolorder.pojo.User;
import org.mryang.schoolorder.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* 后台登陆
*/
@Controller
@RequestMapping("")
public class LoginController {

@Autowired
UserService userService;

@RequestMapping(value="/login",method= RequestMethod.POST)
public String login(Model model, String name, String password){//throws ParseException
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(name,password);
try {
subject.login(token);
User us = userService.getByName(name);
String lastLoginTime = "";
if(us!=null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//上次时间
Date time = us.getLasttime();
lastLoginTime = sdf.format(time);
//新时间
String format = sdf.format(new Date());
//string转date 不处理时间格式会不理想
ParsePosition pos = new ParsePosition(0);
Date strtodate = sdf.parse(format, pos);
us.setLasttime(strtodate);
userService.update(us);
}
if (us.getStatus()==1){
Session session=subject.getSession();
session.setAttribute("subject", subject);
session.setAttribute("lastLoginTime",lastLoginTime);
return "redirect:index";
}else {
model.addAttribute("error", "账号已被停用!");
return "/login";
}

} catch (AuthenticationException e) {
model.addAttribute("error", "验证失败!");
return "/login";
}
}
}
package org.mryang.schoolorder.controller;

import org.mryang.schoolorder.pojo.Category;
import org.mryang.schoolorder.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;

/**
* 商品分类模块controller
*/
@Controller
@RequestMapping("/category")
public class CategoryController {

@Autowired
private CategoryService categoryService;

@RequestMapping("/list")
public String list(Model model){
List<Category> list = categoryService.list();
model.addAttribute("list",list);
model.addAttribute("size",list.size());
return "productmodule/category-list";
}

@RequestMapping("/addCategory")
public String add(@RequestParam(value = "name")String name){
Category category = new Category();
category.setName(name);
categoryService.save(category);
return "productmodule/category-list";
}

@RequestMapping("/delCategory")
public String del(@RequestParam(value = "id")int id){
categoryService.del(id);
return "redirect:list";
}

@RequestMapping("/editCategory")
public String edit(@RequestParam(value = "id")int id, Model model){
Category category = categoryService.get(id);
model.addAttribute("category",category);
return "productmodule/category-edit";
}

@RequestMapping("/updateCategory")
public String update(Category category, Model model){
categoryService.update(category);
return "redirect:list";
}
}
package org.mryang.schoolorder.service;

import org.mryang.schoolorder.pojo.Customer;
/**
* 会员业务逻辑层接口,继承 增删改查业务逻辑接口
* 降低偶合
*/
public interface CustomerService extends CrudService<Customer>{

/**
* 返回登陆的用户
* @param customer
* @return
*/
public Customer foreLogin(Customer customer);

/**
* 设置会员
* @param id
*/
public void shezhihuiyuan(int id);



}
package org.mryang.schoolorder.service.impl;

import org.mryang.schoolorder.dao.CategoryMapper;
import org.mryang.schoolorder.pojo.Category;
import org.mryang.schoolorder.service.CategoryService;
import org.mryang.schoolorder.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

@Autowired
private CategoryMapper categoryMapper;
@Autowired
private ProductService productService;

@Override
public List<Category> list() {
List<Category> categoryList = categoryMapper.selectByExample(null);
return categoryList;
}

@Override
public void save(Category category) {
categoryMapper.insert(category);
}

@Override
public void del(int id) {
boolean cunzai = productService.findProByCid(id);
if(!cunzai){
categoryMapper.deleteByPrimaryKey(id);
}
}

@Override
public Category get(int id) {
return categoryMapper.selectByPrimaryKey(id);
}

@Override
public void update(Category category) {
categoryMapper.updateByPrimaryKeySelective(category);
}
}

作者: 杨校

分享是快乐的,也见证了个人成长历程,文章大多都是工作经验总结以及平时学习积累,基于自身认知不足之处在所难免,也请大家指正,共同进步。