基于javaweb+mysql的springboot网上水果超市商城设计和实现(java+ssm+springboot+redis)

本文介绍基于JavaWeb和MySQL的Spring Boot网上水果超市商城的设计与实现,运行环境为Java≥8、MySQL≥5.7,开发工具多样。阐述了主要技术,如Spring、Redis等,还介绍了前端和后台管理员的主要功能,包括登录、商品管理等,最后提及项目运行工具和数据库设计等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基于javaweb+mysql的springboot网上水果超市商城设计和实现(java+ssm+springboot+redis)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot网上水果超市商城设计和实现(java+ssm+springboot+redis)

主要技术实现:spring、 springmvc、 redis、 springboot、 mybatis 、session、 jquery 、 md5 、bootstarp.js tomcat、、拦截器等。

主要功能实现: 前端:登录、注册、商品分类查看、浏览水果商品、订单管理、发表评论、收藏商品、购物车管理、个人订单管理查看、个人信息查看修改、地址管理等

后台管理员:后台登录、数据统计、系统版本信息等、管理员管理、角色管理、订单管理、通知公告管理、商品种类、和商品详情管理

主要功能截图如下:

用户填写相关信息进行注册:

水果商品数据列表查看:也可以根据关键字搜索水果商品信息

水果商品详情管理:点击可以查看水果商品购买详情数据、可以进行数量操作、加入订单和购物车以及收藏商品和查看排行等功能

我的购物车详情:可以结算以及继续购物和删除购物车信息等操作

订单详情管理:

我的个人信息管理:可以进行密码修改、订单查看管理、收藏查看管理、收获地址管理

我的评论查看:

我的收藏;可以移除收藏

后台管理员端主要实现:

超级管理员admin登录

系统首页:主要功能用户、角色、通知公告信息、商品种类以及商品详情管理和用户管理以及订单信息管理等数据操作。

后台菜单管理:

用户管理:

通知公告列表展示以及内容添加:

后台管理员对水果商品的管理:

上传商品详情信息:

商品评论数据维护:

订单管理和维护:

项目使用eclipse和idea运行、推荐idea、源码架构:

数据库设计ER图:

设计报告:


/**
 * 后台管理系统系统控制器

 *
 */
@RequestMapping("/admin/system")
@Controller
public class SystemController {

	@Autowired
	private AdminMapper adminMapper;
	
	@Autowired
	private AuthorityMapper authorityMapper;
	
	
	/**
	 * 系统登录页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/login",method=RequestMethod.GET)
	public String login(Model model) {
		return "admin/system/login";
	}
	
	/**
	 * 个人信息页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/person_info",method=RequestMethod.GET)
	public String personInfo(Model model) {
		return "admin/system/person_info";

/**
 * 公用的上传类
 */
@RequestMapping("/upload")
@Controller
public class UploadController {

    private String uploadPhotoSufix = ".jpg,.png,.gif,.jpeg";

    private long uploadPhotoMaxSize = 10240;   //大小1024KB

    private String uploadPhotoPath = System.getProperty("user.dir") + "/src/main/resources/upload/photo/";

    private long uploadAttachmentMaxSize = 204800;   //大小204800KB

    private String uploadAttachmentPath = System.getProperty("user.dir") + "/src/main/resources/upload/attachment/";

    private Logger log = LoggerFactory.getLogger(UploadController.class);

    @Autowired
    private AttachmentMapper attachmentMapper;

    /**
     * 图片统一上传类
     *
     * @param photo

/**
 * 后台管理系统公告控制器

 *
 */
@RequestMapping("/admin/announcement")
@Controller
public class AnnouncementController {

	@Autowired
	private IMenuService menuService;
	
	@Autowired 
	private MenuMapper menuMapper;
	
	@Autowired
	private IAnnouncementService announcementService;
	
	@Autowired
	private AdminMapper adminMapper;
	
	@Autowired
	private AuthorityMapper authorityMapper;
	
	/**
	 * 公告列表页面
	 * @param model
    }

    /**
     * 用户注册操作处理
     * @param user
     * @param repassword
     * @param cpacha
     * @param request
     * @return
     */
    @RequestMapping(value="/register",method=RequestMethod.POST)
    @ResponseBody
    public ResponseVo<Boolean> register(User user, String repassword, String cpacha, HttpServletRequest request) {
        return userService.register(user, repassword, cpacha, request);
    }

    /**
     * 用户个人信息修改操作处理
     * @param user
     * @return
     */
    @RequestMapping(value="/update_info",method=RequestMethod.POST)
    @ResponseBody
    public ResponseVo<String> updateInfo(User user){
        return userService.updateInfo(user);
    }

    /**
     * 用户修改密码操作处理
     * @param prePassword
     * @param newPassword
     * @param reNewPassword
     * @param request
     * @return
     */
    @RequestMapping(value="/update_passwd",method=RequestMethod.POST)
    @ResponseBody
    public ResponseVo<Boolean> updatePasswd(String prePassword, String newPassword, String reNewPassword, HttpServletRequest request){
        return userService.updatePasswd(prePassword, newPassword, reNewPassword, request);
    }

}
            e.printStackTrace();
        }
        log.info("图片上传成功,保存位置:" + uploadPhotoPath + filename);
        return ResponseVo.success(filename);

    }

    /**
     * 附件统一上传类
     *
     * @param attachment
     * @return
     */
    @RequestMapping(value = "/upload_attachment", method = RequestMethod.POST)
    @ResponseBody
    public ResponseVo<Attachment> uploadAttachment(@RequestParam(name = "attachment", required = true) MultipartFile attachment, HttpServletRequest request) {
        Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
        String originalFilename = attachment.getOriginalFilename(); //附件名字
        //获取文件后缀
        String suffix = originalFilename.substring(originalFilename.lastIndexOf("."), originalFilename.length());
        //attachment.getSize()单位是B
        if (attachment.getSize() / 1024 > uploadAttachmentMaxSize) {
            CodeMsg codeMsg = CodeMsg.UPLOAD_ATTACHMENT_ERROR;
            codeMsg.setMsg("附件大小不能超过" + (uploadAttachmentMaxSize / 1024) + "M");
            return ResponseVo.errorByMsg(codeMsg);
        }
        //准备保存文件
        File filePath = new File(uploadAttachmentPath);
        if (!filePath.exists()) {
            //若不存在文件夹,则创建一个文件夹
            filePath.mkdir();
        }
        filePath = new File(uploadAttachmentPath + "/" + StringUtil.getFormatterDate(new Date(), "yyyyMMdd"));
        //判断当天日期的文件夹是否存在,若不存在,则创建
        if (!filePath.exists()) {
            //若不存在文件夹,则创建一个文件夹
            filePath.mkdir();
        }
        String filename = StringUtil.getFormatterDate(new Date(), "yyyyMMdd") + "/" + System.currentTimeMillis() + suffix;
        try {
            attachment.transferTo(new File(uploadAttachmentPath + "/" + filename));   //把文件上传
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        //把附件信息写入数据库
        BigDecimal size = new BigDecimal((double) attachment.getSize() / 1024);
        size = size.setScale(2, BigDecimal.ROUND_HALF_EVEN);
        Attachment saveAttachment = new Attachment(null, loginedAdmin.getId(), filename, originalFilename, size); //id,senderid,url,name
		return ResponseVo.success(true);
	}
	

	@RequestMapping(value="/save_person_info",method=RequestMethod.POST)
	@ResponseBody
	public ResponseVo<Boolean> savePersonInfo(Admin admin,HttpServletRequest request){
		if(admin == null) {
			return ResponseVo.errorByMsg(CodeMsg.DATA_ERROR);
		}
		Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
		BeanUtils.copyProperties(admin, loginedAdmin, "id","createTime","updateTime","roleId","state");
		if(adminMapper.updateByPrimaryKeySelective(loginedAdmin) <= 0) {
			return ResponseVo.errorByMsg(CodeMsg.PERSON_INFO_SAVE_ERROR);
		}
		//更新权限
		request.getSession().setAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY, loginedAdmin);
		return ResponseVo.successByMsg(true, "保存个人信息成功!");
	}
	
}

	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(Model model,Integer id) {
		Admin selectByPrimaryKey = adminMapper.selectByPrimaryKey(id);
		if(selectByPrimaryKey == null) {
			return "error/404";
		}
		model.addAttribute("RoleList", roleMapper.selectAll());
		model.addAttribute("editAdmin", selectByPrimaryKey);
		return "admin/admin/edit";
	}
	
	/**
	 * 管理员添加表单处理
	 * @param admin
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public ResponseVo<Boolean> add(Admin admin){
		return adminService.add(admin);
	}
	
	/**
	 * 管理员编辑表单处理
	 * @param admin
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public ResponseVo<Boolean> edit(Admin admin,HttpServletRequest request){
		Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
		ResponseVo<Admin> editAdmin = adminService.edit(admin);
		if(editAdmin.getCode().intValue() == CodeMsg.SUCCESS.getCode()) {
			if(loginedAdmin.getId().intValue() == editAdmin.getData().getId().intValue()) {
				//更新权限
				request.getSession().setAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY, editAdmin.getData());
			}
			return ResponseVo.successByMsg(true, "编辑成功!");
		}else {
			CodeMsg codeMsg = new CodeMsg();
			codeMsg.setCode(editAdmin.getCode());
			codeMsg.setMsg(editAdmin.getMsg());
			return ResponseVo.errorByMsg(codeMsg);
		}
	}
	
	/**
	 * 管理员删除处理
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody

/**

 */

/**
 * 用户service接口实现类

 *
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public ResponseVo<Boolean> isUsernameExist(User user, Long id) {
        User findByUsername = userMapper.findUserByUsername(user.getUsername());
        if(findByUsername != null) {
            if(!findByUsername.getId().equals(id)) {
                return ResponseVo.success(true); //出现重名
            }

    @Autowired
    private AdminMapper adminMapper;

    @Autowired
    private AuthorityMapper authorityMapper;

    @Autowired
    private IUserService userService;

    @Autowired
    private ICommentService commentService;

    /**
     * 用户列表页面
     * @param model
     * @param id
     * @param request
     * @param content
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping(value="/index",method= RequestMethod.GET)
    public String index(Model model, Integer id, HttpServletRequest request, String content,
                        @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                        @RequestParam(required = false, defaultValue = "5") Integer pageSize //每页5个数据
    )  {
        //获取列表展示有关信息
        if(StringUtil.isEmpty(content)) {
            //如果查询信息为空
            model.addAttribute("PageInfo", userService.getUserByPage(pageNum, pageSize).getData());
        }else {
            model.addAttribute("PageInfo", userService.getUserByPageAndContent(pageNum, pageSize, content).getData());
            model.addAttribute("content",content);
        }
        //获取路径上有关信息
        Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id);
        if(selectByPrimaryKey == null) {
            return "error/404";
        }
        Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
        List<Authority> selectByRoleId = authorityMapper.selectByRoleId(loginedAdmin.getRoleId()); //获取当前用户所有权限
        Set<Integer> menuIdSet = selectByRoleId.stream().map(Authority :: getMenuId).collect(Collectors.toSet());//把权限中所有菜单id取出来
        List<Menu> allMenusByStateAndPrimaryKeys = menuMapper.selectByStateAndPrimaryKeys(MenuStateEnum.OPEN.getCode(), menuIdSet);
        model.addAttribute("allAdmins", adminMapper.selectAll());
        model.addAttribute("onThirdMenus", menuService.getThirdMenus(allMenusByStateAndPrimaryKeys).getData());

/**
 * 后台管理系统公告控制器

 *
 */
@RequestMapping("/admin/announcement")
@Controller
public class AnnouncementController {

	@Autowired
	private IMenuService menuService;
	
	@Autowired 
	private MenuMapper menuMapper;
	
	@Autowired
	private IAnnouncementService announcementService;
	
	@Autowired
	private AdminMapper adminMapper;
	
	@Autowired
	private AuthorityMapper authorityMapper;
	
	/**
	 * 公告列表页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(Model model,Integer id,String content,HttpServletRequest request,
			@RequestParam(required = false, defaultValue = "1") Integer pageNum,
			@RequestParam(required = false, defaultValue = "5") Integer pageSize //每页5个数据
			) {
		//获取列表展示有关信息
		if(StringUtil.isEmpty(content)) {
			//如果查询信息为空
			model.addAttribute("PageInfo", announcementService.getAnnouncementByPage(pageNum, pageSize).getData());
		}else {
			model.addAttribute("PageInfo", announcementService.getAnnouncementByPageAndContent(pageNum, pageSize, content).getData());
			model.addAttribute("content",content);
		}
		//获取路径上有关信息
		Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id);
		if(selectByPrimaryKey == null) {

/**
 * 后台管理系统菜单控制器

 *
 */
@RequestMapping("/admin/menu")
@Controller
public class MenuController {

	@Autowired
	private IMenuService menuService;
	
	@Autowired 
	private MenuMapper menuMapper;
	
	@Autowired
	private AuthorityMapper authorityMapper;
	
	
	/**
	 * 菜单列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(Model model,Integer id,HttpServletRequest request) {
		//获取列表展示有关信息
		List<Menu> allMenus = menuMapper.selectAll();
		model.addAttribute("FirstMenus",menuService.getFirstMenus(allMenus).getData());

/**
 * UEditor图片上传
 */
@Controller
@RequestMapping("/ueditor")
public class FileController {

    private String uploadPhotoPath = System.getProperty("user.dir") + "/src/main/resources/upload/photo/";

    @RequestMapping(value = "/file")
    @ResponseBody
    public String file(HttpServletRequest request) {
        String s = "{\n" +
                "            \"imageActionName\": \"uploadimage\",\n" +
                "                \"imageFieldName\": \"file\", \n" +
                "                \"imageMaxSize\": 2048000, \n" +
                "                \"imageAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"], \n" +
                "                \"imageCompressEnable\": true, \n" +
                "                \"imageCompressBorder\": 1600, \n" +
                "                \"imageInsertAlign\": \"none\", \n" +
                "                \"imageUrlPrefix\": \"\",\n" +
                "                \"imagePathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\" }";
        return s;
    }

    @RequestMapping(value = "/imgUpdate")
    @ResponseBody
    public String imgUpdate(MultipartFile file, HttpServletRequest request) throws FileNotFoundException {
        if (file.isEmpty()) {
            return "error";
        }
        // 获取文件名
        String fileName = file.getOriginalFilename();
        // 获取文件的后缀名
        String suffixName = fileName.substring(fileName.lastIndexOf("."));
    public String comment(Model model, Integer id, HttpServletRequest request, String content,
                        @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                        @RequestParam(required = false, defaultValue = "5") Integer pageSize //每页5个数据
    )  {
        //获取列表展示有关信息
        if(StringUtil.isEmpty(content)) {
            //如果查询信息为空
            model.addAttribute("PageInfo", commentService.selectByPage(pageNum, pageSize).getData());
        }else {
            model.addAttribute("PageInfo", commentService.selectByPageAndSearchContent(content, pageNum, pageSize).getData());
            model.addAttribute("content",content);
        }
        //获取路径上有关信息
        Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id);
        if(selectByPrimaryKey == null) {
            return "error/404";
        }
        Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
        List<Authority> selectByRoleId = authorityMapper.selectByRoleId(loginedAdmin.getRoleId()); //获取当前用户所有权限
        Set<Integer> menuIdSet = selectByRoleId.stream().map(Authority :: getMenuId).collect(Collectors.toSet());//把权限中所有菜单id取出来
        List<Menu> allMenusByStateAndPrimaryKeys = menuMapper.selectByStateAndPrimaryKeys(MenuStateEnum.OPEN.getCode(), menuIdSet);
        model.addAttribute("allAdmins", adminMapper.selectAll());
        model.addAttribute("onThirdMenus", menuService.getThirdMenus(allMenusByStateAndPrimaryKeys).getData());
        model.addAttribute("parentMenu", menuMapper.selectByPrimaryKey(selectByPrimaryKey.getParentId()));
        model.addAttribute("currentMenu", selectByPrimaryKey);
        return "admin/user/comment";
    }

    /**
     * 修改用户密码页面
     * @param model
     * @param id
     * @return
     */
    @RequestMapping(value="/edit_passwd",method=RequestMethod.GET)
    public String editPasswd(Model model,Long id) {
        User user = userService.selectByPrimaryKey(id);
        if(user == null) {
            return "error/404";
        }
        model.addAttribute("User", user);

/**
 * 公用的上传类
 */
@RequestMapping("/upload")
@Controller
public class UploadController {

    private String uploadPhotoSufix = ".jpg,.png,.gif,.jpeg";

    private long uploadPhotoMaxSize = 10240;   //大小1024KB

    private String uploadPhotoPath = System.getProperty("user.dir") + "/src/main/resources/upload/photo/";

    private long uploadAttachmentMaxSize = 204800;   //大小204800KB

    private String uploadAttachmentPath = System.getProperty("user.dir") + "/src/main/resources/upload/attachment/";

    private Logger log = LoggerFactory.getLogger(UploadController.class);

    @Autowired
    private AttachmentMapper attachmentMapper;

    /**
     * 图片统一上传类
     *
     * @param photo
     * @return
     */
    @RequestMapping(value = "/upload_photo", method = RequestMethod.POST)
    @ResponseBody
    public ResponseVo<String> uploadPhoto(@RequestParam(name = "photo", required = true) MultipartFile photo) {
        //判断文件类型是否是图片
        String originalFilename = photo.getOriginalFilename();
        //获取文件后缀
        String suffix = originalFilename.substring(originalFilename.lastIndexOf("."), originalFilename.length());
        if (!uploadPhotoSufix.contains(suffix.toLowerCase())) {
            return ResponseVo.errorByMsg(CodeMsg.UPLOAD_PHOTO_SUFFIX_ERROR);
	private AuthorityMapper authorityMapper;
	
	/**
	 * 管理员列表页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(Model model,Integer id,String name,HttpServletRequest request,
			@RequestParam(required = false, defaultValue = "1") Integer pageNum,
			@RequestParam(required = false, defaultValue = "5") Integer pageSize //每页5个数据
			) {
		//获取列表展示有关信息
		if(StringUtil.isEmpty(name)) {
			//如果查询信息为空
			model.addAttribute("PageInfo", adminService.getAdminListByPage(pageNum, pageSize).getData());
		}else {
			model.addAttribute("PageInfo", adminService.getAdminListByPageAndName(pageNum, pageSize, name).getData());
			model.addAttribute("name",name);
		}
		model.addAttribute("RoleList", roleMapper.selectAll());
		//获取路径上有关信息
		Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id);
		if(selectByPrimaryKey == null) {
			return "error/404";
		}
		Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
		List<Authority> selectByRoleId = authorityMapper.selectByRoleId(loginedAdmin.getRoleId()); //获取当前用户所有权限
		Set<Integer> menuIdSet = selectByRoleId.stream().map(Authority :: getMenuId).collect(Collectors.toSet());//把权限中所有菜单id取出来
		List<Menu> allMenusByStateAndPrimaryKeys = menuMapper.selectByStateAndPrimaryKeys(MenuStateEnum.OPEN.getCode(), menuIdSet);
		model.addAttribute("onThirdMenus", menuService.getThirdMenus(allMenusByStateAndPrimaryKeys).getData());
		model.addAttribute("parentMenu", menuMapper.selectByPrimaryKey(selectByPrimaryKey.getParentId()));
		model.addAttribute("currentMenu", selectByPrimaryKey);
		return "admin/admin/index";
	}
	
	/**
	 * 管理员添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model) {
		model.addAttribute("RoleList", roleMapper.selectAll());
		return "admin/admin/add";
	}
	
	/**
	 * 管理员编辑页面
	 * @param model
	 * @param id
	 * @return
            //如果查询信息为空
            model.addAttribute("PageInfo", productCategoryService.getProductCategoryByPage(pageNum, pageSize).getData());
        }else {
            model.addAttribute("PageInfo", productCategoryService.getProductCategoryByPageAndContent(pageNum, pageSize, content).getData());
            model.addAttribute("content",content);
        }
        //获取路径上有关信息
        Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id);
        if(selectByPrimaryKey == null) {
            return "error/404";
        }
        Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
        List<Authority> selectByRoleId = authorityMapper.selectByRoleId(loginedAdmin.getRoleId()); //获取当前用户所有权限
        Set<Integer> menuIdSet = selectByRoleId.stream().map(Authority :: getMenuId).collect(Collectors.toSet());//把权限中所有菜单id取出来
        List<Menu> allMenusByStateAndPrimaryKeys = menuMapper.selectByStateAndPrimaryKeys(MenuStateEnum.OPEN.getCode(), menuIdSet);
        model.addAttribute("allAdmins", adminMapper.selectAll());
        model.addAttribute("onThirdMenus", menuService.getThirdMenus(allMenusByStateAndPrimaryKeys).getData());
        model.addAttribute("parentMenu", menuMapper.selectByPrimaryKey(selectByPrimaryKey.getParentId()));
        model.addAttribute("currentMenu", selectByPrimaryKey);
        return "admin/product_category/index";
    }

    /**
     * 商品种类添加页面
     * @param model
     * @return
     */
    @RequestMapping(value="/add",method=RequestMethod.GET)
    public String add(Model model) {
        return "admin/product_category/add";
    }

    /**
     * 商品种类编辑页面
     * @param model
     * @param id
     * @return
     */
    @RequestMapping(value="/edit",method=RequestMethod.GET)
    public String edit(Model model,Long id) {
        ProductCategory selectByPrimaryKey = productCategoryMapper.selectByPrimaryKey(id);
        if(selectByPrimaryKey == null) {
            return "error/404";
        }
        model.addAttribute("ProductCategory", selectByPrimaryKey);
        return "admin/product_category/edit";
    }

    /**
     * 添加商品种类操作处理
	}
	
	/**
	 * 管理员添加表单处理
	 * @param admin
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public ResponseVo<Boolean> add(Admin admin){
		return adminService.add(admin);
	}
	
	/**
	 * 管理员编辑表单处理
	 * @param admin
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public ResponseVo<Boolean> edit(Admin admin,HttpServletRequest request){
		Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);
		ResponseVo<Admin> editAdmin = adminService.edit(admin);
		if(editAdmin.getCode().intValue() == CodeMsg.SUCCESS.getCode()) {
			if(loginedAdmin.getId().intValue() == editAdmin.getData().getId().intValue()) {
				//更新权限
				request.getSession().setAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY, editAdmin.getData());
			}
			return ResponseVo.successByMsg(true, "编辑成功!");
		}else {
			CodeMsg codeMsg = new CodeMsg();
			codeMsg.setCode(editAdmin.getCode());
			codeMsg.setMsg(editAdmin.getMsg());
			return ResponseVo.errorByMsg(codeMsg);
		}
	}
	
	/**
	 * 管理员删除处理
	 * @param id
	 * @return

/**
 * 后台管理系统菜单控制器

 *
 */
@RequestMapping("/admin/menu")
@Controller
public class MenuController {

	@Autowired
	private IMenuService menuService;
	
	@Autowired 
	private MenuMapper menuMapper;
	
	@Autowired
	private AuthorityMapper authorityMapper;
	
	
	/**
	 * 菜单列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(Model model,Integer id,HttpServletRequest request) {
		//获取列表展示有关信息
		List<Menu> allMenus = menuMapper.selectAll();
		model.addAttribute("FirstMenus",menuService.getFirstMenus(allMenus).getData());
		model.addAttribute("SecondMenus",menuService.getSecondMenus(allMenus).getData());
		model.addAttribute("ThirdMenus",menuService.getThirdMenus(allMenus).getData());
		
		//获取路径上有关信息
		Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id);
		if(selectByPrimaryKey == null) {
			return "error/404";
		}
		Admin loginedAdmin = (Admin) request.getSession().getAttribute(SessionConstant.SESSION_ADMIN_LOGIN_KEY);

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值