基于javaweb+mysql的ssm+maven校园共享自行车管理系统(java+ssm+jsp+easyui+bootstrap+mysql)

基于javaweb+mysql的ssm+maven校园共享自行车管理系统(java+ssm+jsp+easyui+bootstrap+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SSM+Maven校园共享自行车管理系统(java+ssm+jsp+easyui+bootstrap+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+EasyUI+BootStrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录

    //删除分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(Integer cid){
        return categoryService.deleteById(cid);
    }

    //回显分类的表单数据
    @RequestMapping("/loadForm")
    @ResponseBody
    public Category loadForm(Integer cid){
        return categoryService.findById(cid);
    }

}
package com.webike.web;

/**
 */
@Controller
@RequestMapping("/place")
public class PlaceController {

    @Autowired
    private PlaceService placeService;

    //跳转到  place 页面
    @RequestMapping("/placeManage")
    public String placeMange(){
        return "place";
            String path = FileUtil.uploadImage(studentIcon, "studentIcon", request);
            if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
            student.setsIcon(path);
        }

        student.setsCreateTime(new Date());
        student.setsUpdateTime(new Date());
        if(student.getsSex() == null) student.setsSex("男");
        try{
            int   i = studentMapper.insertSelective(student);
            return    i > 0 ?  new JsonResult(true, ResultEnum.ADD_SUCCESS)
                    : new JsonResult(false, ResultEnum.ADD_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.REPEAT_ERROR);
        }
    }

    @Override
    public JsonResult removeById(Integer sid) {
        if(sid == null) return new JsonResult(false, ResultEnum.DELETE_FAIL);
        int i = studentMapper.deleteByPrimaryKey(sid);
        return i > 0 ? new JsonResult(true, ResultEnum.DELETE_SUCCESS) : new JsonResult(false, ResultEnum.DELETE_FAIL);
    }

    @Override
    public Student findById(Integer sid) {
        if(sid != null){
            return studentMapper.selectByPrimaryKey(sid);
        }
        return null;
    }

    @Override
    public JsonResult update(MultipartFile studentIcon,Student student,HttpServletRequest request) {
        try{
            if(!studentIcon.isEmpty()){
                //更新首先要先删除原来的文件
                if(student.getsIcon() != null){
                    File file = new File(request.getServletContext().getRealPath("/" + student.getsIcon()));
                //    if(file != null) file.delete();
                }
                String path = FileUtil.uploadImage(studentIcon, "studentIcon", request);
                if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
                student.setsIcon(path);
            }
            student.setsUpdateTime(new Date());
            int i = studentMapper.updateByPrimaryKeySelective(student);
            return i > 0 ? new JsonResult(false, ResultEnum.UPDATE_SUCCESS)
                    : new JsonResult(false, ResultEnum.UPDATE_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;

    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
        if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
            return bikeService.update(bikeIcon,bike,request);
    }

    //showAll bike
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Bike> show(Integer page, Integer rows){
        return bikeService.findAllToPage(page,rows);
    }

    //删除单车和更新单车的分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(String bids,String cids){
        return bikeService.deleteById(bids,cids);
    }
    //点击修改回显bike弹出表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Bike loadForm(Integer bid){
        return bikeService.findById(bid);
    }

    //回显bike分类
    @RequestMapping(value = "/loadCategory",method = RequestMethod.POST)
    @ResponseBody
    public List<Category> loadCategory(){
        return categoryService.findAll();
    }
            e.printStackTrace();
//            throw new RuntimeException(e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return new JsonResult(false,ResultEnum.SYSTEM_ERROR);
        }
    }

    @Override
    public Bike findById(Integer bid) {
        return bikeMapper.selectByPrimaryKey(bid);
    }

}
package com.webike.service.impl;

/**
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Autowired
    private PlaceMapper placeMapper;
    @Override
    public String checkUserPwd(Admin admin) {
        String password = MD5Util.getMD5(admin.getaPassword());
        Admin realAdmin = findByUsername(admin.getaUsername());
        if(realAdmin != null ){
            if(password.equals(realAdmin.getaPassword())){
                return "成功";

/**
 */
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;

    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
        if(orders.getOid() == null) return ordersService.add(orders);
            return ordersService.update(orders);
    }

    //点击修改按钮,加载订单表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Orders loadForm(Integer oid){
        return ordersService.findById(oid);
    }

    //显示所有的订单
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Orders> show(Integer page, Integer rows){
        return ordersService.findAllToPage(page,rows);
    }

    //删除订单
    @RequestMapping("/remove")
    @ResponseBody
    public JsonResult remove(Integer oid,Integer oBid,String oState){
        return ordersService.deleteById(oid,oBid,oState);
    }

}
package com.webike.utils;

/**
 */
public class FileUtil {
    /**
     *
     * @param multipartFile 上传的文件
     * @param saveDir  在images文件夹下面的哪个文件夹
     * @param request
     * @return 返回一个文件路径 如果null则上传失败
     */
    public static String uploadImage(MultipartFile multipartFile,String saveDir, HttpServletRequest request){
            String path = FileUtil.uploadImage(adminIcon, "adminIcon", request);
            if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
            admin.setaIcon(path);
        }
        if(admin.getaRole() == null) admin.setaRole(RoleEnum.MANAGER.getMassage());
        admin.setaPassword(MD5Util.getMD5(admin.getaPassword()));
        admin.setaCreateTime(new Date());
        admin.setaUpdateTime(new Date());
        try{
            int  row = adminMapper.insertSelective(admin);
            return row > 0 ? new JsonResult(true, ResultEnum.ADD_SUCCESS)
                    : new JsonResult(false, ResultEnum.ADD_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.REPEAT_ERROR);
        }
    }

    @Override
    public JsonResult update(MultipartFile adminIcon, Admin admin, HttpServletRequest request) {
        try{
            if(!adminIcon.isEmpty()){
                //更新首先要先删除原来的文件
                if(admin.getaIcon() != null){
                    File file = new File(request.getServletContext().getRealPath("/" + admin.getaIcon()));
               //     if(file != null) file.delete();
                }
                String path = FileUtil.uploadImage(adminIcon, "adminIcon", request);
                if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
                admin.setaIcon(path);
            }
            admin.setaUpdateTime(new Date());
            int i = adminMapper.updateByPrimaryKeySelective(admin);
            return i > 0 ? new JsonResult(false, ResultEnum.UPDATE_SUCCESS)
                    : new JsonResult(false, ResultEnum.UPDATE_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        }
    }

}
package com.webike.web;

/**
 */
@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    //跳转到student管理 jsp页面
    @RequestMapping("/studentManage")
    public String studentManage(){
        return "student";
    }

    //添加或更新一个学生
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult add(MultipartFile studentIcon, Student student, HttpServletRequest request){
        if(student.getSid() == null || "".equals(student.getSid()))
        return studentService.add(studentIcon,student,request);
        return studentService.update(studentIcon,student,request);
    }

    //显示所有的学生
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Student> show(Integer page,Integer rows){
        return studentService.findAllToPage(page,rows);
    }
            return false;
        }
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

    }
}
package com.webike.web;

/**
 */
@Controller
@RequestMapping("/orders")
public class OrdersController {

    @Autowired
    OrdersService ordersService;

    //跳转到租赁管理页面
    @RequestMapping("/ordersManage")
    public  String ordersMange(){
        return "orders";
    }

    //添加或修改订单
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public JsonResult addOrUpdate(Orders orders){
        if(orders.getOid() == null) return ordersService.add(orders);

/**
 */
@Service
public class BikeControllerImpl implements BikeService {
    @Autowired
    private BikeMapper bikeMapper;

    @Autowired
    private CategoryService categoryService;

    //事务控制 该单车分类剩余量+1
    @Transactional
    @Override
    public JsonResult add(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount) {
        if(!bikeIcon.isEmpty()){
            String path = FileUtil.uploadImage(bikeIcon, "bikeIcon", request);
            if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
            bike.setbIcon(path);
        }
        bike.setbState(BikeStateEnum.AVAILABLE.getState());
        bike.setbCreateTime(new Date());
        bike.setbUpdateTime(new Date());
        try{
            int row = 0;
            for (int i = 0; i < bCount; i++) {
                row += bikeMapper.insertSelective(bike);
            }
            if(row == bCount){
                return categoryService.updateRemainById(bike.getbCid(),bCount) ?
                        new JsonResult(true, ResultEnum.ADD_SUCCESS):new JsonResult(false, ResultEnum.ADD_FAIL);
            }else{
                throw new RuntimeException();
            }
        }catch (Exception e){
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return new JsonResult(false,ResultEnum.SYSTEM_ERROR);
     *
     * @param multipartFile 上传的文件
     * @param saveDir  在images文件夹下面的哪个文件夹
     * @param request
     * @return 返回一个文件路径 如果null则上传失败
     */
    public static String uploadImage(MultipartFile multipartFile,String saveDir, HttpServletRequest request){
            if(!multipartFile.getContentType().startsWith("image/"))
                return null;
            String filename = multipartFile.getOriginalFilename();
            String type = filename.substring(filename.lastIndexOf("."));
            String newFilename = UUIDUtil.getUUIDByTime()+type;
            String path = request.getServletContext().getRealPath("/images/"+saveDir)+"/"+newFilename;
            try{
                FileCopyUtils.copy(multipartFile.getInputStream(), new FileOutputStream(path));
                return "images/"+saveDir+"/"+newFilename;
            }catch (IOException e){
                e.printStackTrace();
                return null;
            }

    }
}
package com.webike.service;

/**
 */
public interface AdminService {

    //验证登陆
    public String checkUserPwd(Admin admin);

    //更新
    public boolean upDate(Admin admin);

    //
    public Admin findByUsername(String username);

    //显示所有用户用PageBean封装
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        }
    }

    @Override
    public Page<Bike> findAllToPage(Integer page, Integer rows) {
        Page<Bike> bPage = new Page<>();
        List<Bike> lists = bikeMapper.findToPage((page-1)*rows,rows);
        bPage.setRows(lists);
        bPage.setTotal(bikeMapper.countByExample(new BikeExample()));
        return bPage;
    }
    //事务控制 该单车的分类剩余量减size
    @Transactional
    @Override
    public JsonResult deleteById(String bids,String cids) {
        try{
            String[] bidList = bids.split(",");
            String[] cidList = cids.split(",");

            int row = 0;
            for (int i = 0; i < bidList.length; i++) {
                row += bikeMapper.deleteByPrimaryKey(Integer.parseInt(bidList[i]));
            }
            if(row == bidList.length){ //更新分类表的剩余数量
                HashMap<String, Integer> cidMap = ArithmeticUtil.getElementForTimes(cidList);
                Set<Map.Entry<String, Integer>> entries = cidMap.entrySet();
                for (Map.Entry<String, Integer> entry : entries) {
                    boolean isSuccess = categoryService.updateRemainById(Integer.parseInt(entry.getKey()), - entry.getValue());
                    if(!isSuccess) throw new RuntimeException();
                }
                return new JsonResult(true, ResultEnum.DELETE_SUCCESS);
            }else{
                throw new RuntimeException();
            }
        }catch (Exception e){
            e.printStackTrace();
//            throw new RuntimeException(e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return new JsonResult(false,ResultEnum.SYSTEM_ERROR);
        }
    }

    @Override
    public Bike findById(Integer bid) {
        return bikeMapper.selectByPrimaryKey(bid);
    }

}
    }
    //修改提交的密码
    @RequestMapping("/submitResetPwd")
    @ResponseBody
    public JsonResult submitResetPwd(String password, String newPassword,HttpSession httpSession){
        Admin admin = (Admin) httpSession.getAttribute("admin");
        if(!admin.getaPassword().equals(MD5Util.getMD5(password)))
            return new JsonResult(false,ResultEnum.OLD_PASSWORD_ERROR);
        admin.setaPassword(MD5Util.getMD5(newPassword));
        admin.setaUpdateTime(new Date());
        boolean isSuccess = adminService.upDate(admin);
        if(isSuccess) return new JsonResult(isSuccess, ResultEnum.UPDATE_SUCCESS);
        return new JsonResult(isSuccess, ResultEnum.UPDATE_FAIL);
    }

    //跳转到用户管理页面

    @RequestMapping("/adminManage")
    public String adminMange(){
        return "admin";
    }

    //显示用户页面
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Admin> showAll(Integer page, Integer rows){
        return adminService.findAllToPage(page,rows);
    }

    //删除用户
    @RequestMapping("/remove")
    @ResponseBody
    public JsonResult remove(Integer aid){
        return adminService.deleteById(aid);
    }

    // 加载服务点到表单下拉框 loadPlace
    @RequestMapping("/loadPlace")
    @ResponseBody
    public List<Place> loadPlace(){
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;

    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
        if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
            return bikeService.update(bikeIcon,bike,request);
    }

    //showAll bike
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Bike> show(Integer page, Integer rows){
        return bikeService.findAllToPage(page,rows);
    }

    //删除单车和更新单车的分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(String bids,String cids){
        return bikeService.deleteById(bids,cids);
    }
    //点击修改回显bike弹出表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Bike loadForm(Integer bid){
        return bikeService.findById(bid);
    }
       return categoryService.findAll();
    }

    //添加或更新分类 addOrUpdate
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(Category category){
        if(category == null) return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        if(category.getCid() == null ) return categoryService.add(category);
        return categoryService.update(category);
    }

    //删除分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(Integer cid){
        return categoryService.deleteById(cid);
    }

    //回显分类的表单数据
    @RequestMapping("/loadForm")
    @ResponseBody
    public Category loadForm(Integer cid){
        return categoryService.findById(cid);
    }

}
package com.webike.web;

/**
 */
@Controller
@RequestMapping("/place")
public class PlaceController {

    @Autowired
    private PlaceService placeService;

/**
 */
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;

    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
        if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
            return bikeService.update(bikeIcon,bike,request);
    }

    //showAll bike
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Bike> show(Integer page, Integer rows){
        return bikeService.findAllToPage(page,rows);
    }

    //删除单车和更新单车的分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(String bids,String cids){
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;

    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
        if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
            return bikeService.update(bikeIcon,bike,request);
    }

    //showAll bike
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Bike> show(Integer page, Integer rows){
        return bikeService.findAllToPage(page,rows);
    }

    //删除单车和更新单车的分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(String bids,String cids){
        return bikeService.deleteById(bids,cids);
    }
    //点击修改回显bike弹出表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Bike loadForm(Integer bid){
        return bikeService.findById(bid);
    }

    //回显bike分类
    @RequestMapping(value = "/loadCategory",method = RequestMethod.POST)
    @ResponseBody
    public List<Category> loadCategory(){
        return categoryService.findAll();
    }


}
package com.webike.web;

/**
 */
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;

    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

        }
    }

    @Override
    public JsonResult update(MultipartFile adminIcon, Admin admin, HttpServletRequest request) {
        try{
            if(!adminIcon.isEmpty()){
                //更新首先要先删除原来的文件
                if(admin.getaIcon() != null){
                    File file = new File(request.getServletContext().getRealPath("/" + admin.getaIcon()));
               //     if(file != null) file.delete();
                }
                String path = FileUtil.uploadImage(adminIcon, "adminIcon", request);
                if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
                admin.setaIcon(path);
            }
            admin.setaUpdateTime(new Date());
            int i = adminMapper.updateByPrimaryKeySelective(admin);
            return i > 0 ? new JsonResult(false, ResultEnum.UPDATE_SUCCESS)
                    : new JsonResult(false, ResultEnum.UPDATE_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        }
    }

}
package com.webike.web;

            admin.setaPassword(null);
            adminService.upDate(admin);
            return "redirect:index";
        }

        model.addAttribute("msg",message);
        return "forward:/login.jsp";
    }
    //退出登陆
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:/login.jsp";
    }

    //跳转到修改密码的页面
    @RequestMapping("/rePassword")
    public String rePassword(){
        return "rePassword";
    }
    //修改提交的密码
    @RequestMapping("/submitResetPwd")
    @ResponseBody
    public JsonResult submitResetPwd(String password, String newPassword,HttpSession httpSession){
        Admin admin = (Admin) httpSession.getAttribute("admin");
        if(!admin.getaPassword().equals(MD5Util.getMD5(password)))
            return new JsonResult(false,ResultEnum.OLD_PASSWORD_ERROR);
        admin.setaPassword(MD5Util.getMD5(newPassword));
        admin.setaUpdateTime(new Date());
        boolean isSuccess = adminService.upDate(admin);
        if(isSuccess) return new JsonResult(isSuccess, ResultEnum.UPDATE_SUCCESS);
        return new JsonResult(isSuccess, ResultEnum.UPDATE_FAIL);
    }

    //跳转到用户管理页面

    @RequestMapping("/adminManage")
    public String adminMange(){
        return "admin";
    }

    //显示用户页面
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Admin> showAll(Integer page, Integer rows){
        return adminService.findAllToPage(page,rows);
    }

    //删除用户
    @RequestMapping("/remove")
    @ResponseBody
    public JsonResult remove(Integer aid){
        return adminService.deleteById(aid);
    @RequestMapping("/loadPlace")
    @ResponseBody
    public List<Place> loadPlace(){
        return adminService.loadPlace();
    }

    //回显用户表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Admin loadForm(String username){
        Admin admin = adminService.findByUsername(username);
        return admin;
    }

    //addOrUpdate
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile adminIcon, Admin admin, HttpServletRequest request){
        if(admin.getAid() == null) return adminService.add(adminIcon,admin,request);
        return adminService.update(adminIcon,admin,request);

    }

}
package com.webike.service.impl;


    //跳转到用户管理页面

    @RequestMapping("/adminManage")
    public String adminMange(){
        return "admin";
    }

    //显示用户页面
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Admin> showAll(Integer page, Integer rows){
        return adminService.findAllToPage(page,rows);
    }

    //删除用户
    @RequestMapping("/remove")
    @ResponseBody
    public JsonResult remove(Integer aid){
        return adminService.deleteById(aid);
    }

    // 加载服务点到表单下拉框 loadPlace
    @RequestMapping("/loadPlace")
    @ResponseBody
    public List<Place> loadPlace(){
        return adminService.loadPlace();
    }

    //回显用户表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Admin loadForm(String username){
        Admin admin = adminService.findByUsername(username);
        return admin;
    }

    //addOrUpdate
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile adminIcon, Admin admin, HttpServletRequest request){
        if(admin.getAid() == null) return adminService.add(adminIcon,admin,request);
        return adminService.update(adminIcon,admin,request);
                if(path == null) return new JsonResult(false, ResultEnum.UPLOAD_TYPE_ERROR);
                student.setsIcon(path);
            }
            student.setsUpdateTime(new Date());
            int i = studentMapper.updateByPrimaryKeySelective(student);
            return i > 0 ? new JsonResult(false, ResultEnum.UPDATE_SUCCESS)
                    : new JsonResult(false, ResultEnum.UPDATE_FAIL);
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult(false, ResultEnum.SYSTEM_ERROR);
        }

    }

}
package com.webike.web;

/**
 */
@Controller
@RequestMapping("/bike")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    @Autowired
    private CategoryService categoryService;
    //回显用户表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Admin loadForm(String username){
        Admin admin = adminService.findByUsername(username);
        return admin;
    }

    //addOrUpdate
    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile adminIcon, Admin admin, HttpServletRequest request){
        if(admin.getAid() == null) return adminService.add(adminIcon,admin,request);
        return adminService.update(adminIcon,admin,request);

    }

}
package com.webike.service.impl;


    //跳转到 bike管理页面
    @RequestMapping("/bikeManage")
    public String bikeManage(){
        return "bike";
    }

    //添加或更新bike
    @RequestMapping(value = "/addOrUpdate",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult addOrUpdate(MultipartFile bikeIcon, Bike bike, HttpServletRequest request,Integer bCount){
        if(bCount != null) return bikeService.add(bikeIcon,bike,request,bCount);
            return bikeService.update(bikeIcon,bike,request);
    }

    //showAll bike
    @RequestMapping("/showAll")
    @ResponseBody
    public Page<Bike> show(Integer page, Integer rows){
        return bikeService.findAllToPage(page,rows);
    }

    //删除单车和更新单车的分类
    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    @ResponseBody
    public JsonResult remove(String bids,String cids){
        return bikeService.deleteById(bids,cids);
    }
    //点击修改回显bike弹出表单
    @RequestMapping("/loadForm")
    @ResponseBody
    public Bike loadForm(Integer bid){
        return bikeService.findById(bid);
    }

    //回显bike分类
    @RequestMapping(value = "/loadCategory",method = RequestMethod.POST)
    @ResponseBody
    public List<Category> loadCategory(){
        return categoryService.findAll();
    }

}
package com.webike.web;

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值