Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)

一、项目简述

本系统功能包括:

一:商品模块:商品添加、规格设置,商品上下架等

二:订单模块:下单、购物车、支付,发货、收货、退款 等

三:用户模块:登陆、注册等

四:其他等

二、项目运行

环境配置:

1.1 springframework4.3.7.RELEASE

1.2 mybatis3.1.0、MyBatis-Plus 3.1.0

1.3 shirol.3.2

1.4 servlet3.1.0

1.5 druid1.0.28

1.6 weixin-java-mp3.2.0

1.7 MybatisPlus3.1.0

1.8 lombok等等。

项目技术:

2.1 Vue2.5.1

2.2 iview

2.3 layer3.0.3

2.4 jquery2.2.4

2.5 bootstrap3.3.7等等。

Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)_第1张图片

 Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)_第2张图片

Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)_第3张图片

Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)_第4张图片

Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)_第5张图片

Java项目:(小程序)超豪华在线点餐系统(weixin-java-mp+VUE+iview+bootstrap)_第6张图片

 

商品分类模块controller:

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

    @Autowired
    private CategoryService categoryService;

    @RequestMapping("/list")
    public String list(Model model){
        List 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";
    }
}

后台登陆控制层:

/**
 * 后台登陆
 */
@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";
        }
    }


}

管理员controller控制层:

/**
 * 管理员controller
 */
@Controller
@RequestMapping("/config")
public class UserController {
    @Autowired
    UserRoleService userRoleService;
    @Autowired
    UserService userService;
    @Autowired
    RoleService roleService;


    @RequestMapping("/enableStatus")
    @ResponseBody
    public String enableStatus(@RequestParam(value = "name") String name){
        return userService.enableStatus(name);
    }

    @RequestMapping("/stopStatus")
    @ResponseBody
    public String stopStatus(@RequestParam(value = "name") String name){
        return userService.stopStatus(name);
    }

    @RequestMapping("/adminAdd")
    public String adminadd(Model model){
        List list = roleService.list();
        model.addAttribute("rolelist",list);
        return "syspage/admin-add";
    }

    @RequestMapping("/listUser")
    public String list(Model model, Page page){

        PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询
        List us= userService.list();
        int total = (int) new PageInfo<>(us).getTotal();//总条数
        page.setTotal(total);

        model.addAttribute("us", us);//所有用户
        model.addAttribute("total",total);

        Map> user_roles = new HashMap<>();
        //每个用户对应的权限
        for (User user : us) {
            List roles=roleService.listRoles(user);
            user_roles.put(user, roles);
        }
        model.addAttribute("user_roles", user_roles);
 
        return "syspage/admin-list";
    }

    /**
     * 修改管理员角色
     * @param model
     * @param id
     * @return
     */
    @RequestMapping("/editUser")
    public String edit(Model model,Long id){
        List rs = roleService.list();
        model.addAttribute("rs", rs);      
        User user =userService.get(id);
        model.addAttribute("user", user);
        //当前拥有的角色
        List roles =roleService.listRoles(user);
        model.addAttribute("currentRoles", roles);
         
        return "syspage/admin-edit";
    }

    @RequestMapping("deleteUser")
    public String delete(Model model,long id){
        userService.delete(id);
        return "redirect:listUser";
    }

    @RequestMapping("updateUser")
    public String update(User user, long[] roleIds){
        userRoleService.setRoles(user,roleIds);
         
        String password=user.getPassword();
        //如果在修改的时候没有设置密码,就表示不改动密码
        if(user.getPassword().length()!=0) {
            String salt = new SecureRandomNumberGenerator().nextBytes().toString();
            int times = 2;
            String algorithmName = "md5";
            String encodedPassword = new SimpleHash(algorithmName,password,salt,times).toString();
            user.setSalt(salt);
            user.setPassword(encodedPassword);
        }
        else
            user.setPassword(null);
         
        userService.update(user);
 
        return "redirect:listUser";
 
    }
 
    @RequestMapping("addUser")
    public String add(User user,long[] roleIds){

        String salt = new SecureRandomNumberGenerator().nextBytes().toString();//生成随机数
        int times = 2;
        String algorithmName = "md5";
          
        String encodedPassword = new SimpleHash(algorithmName,user.getPassword(),salt,times).toString();
         
        User u = new User();
        u.setName(user.getName());
        u.setPassword(encodedPassword);
        u.setSalt(salt);
        u.setStatus(1);
        u.setAddress(user.getAddress());
        u.setPhone(user.getPhone());
        userService.add(u);

        userRoleService.setRoles(u,roleIds);
         
        return "redirect:listUser";
    }
 
}

你可能感兴趣的:(Java毕业设计项目实战篇,java,maven,mysql,weixin-java-mp,bootstrap)