基于javaweb+mysql的springboot宠物领养寄养商城系统(java+springboot+html+bootstrap+mysql+maven)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot宠物领养寄养商城系统(java+springboot+html+bootstrap+mysql+maven)
项目介绍
管理员角色: 用户管理、角色管理、菜单管理、宠物信息、视频管理、在线留言、宠物用品管理、 常见问题管理、购物车、商城订单、领养订单、寄养订单
用户角色: 领养宠物、寄养宠物、视频秀、买家秀、在线留言、加入购物车、 购买、商城订单、领养订单、寄养订单
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;
技术栈
-
后端:SpringBoot+Mybatis
-
前端:HTML+CSS+Bootstrap+jQuery
使用说明
运行项目,登录地址:http://localhost:8089/login
管理员: admin/admin123
普通账户: liming/123456
*/
@RequiresPermissions("system:post:add")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated Post post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
return toAjax(postService.insertPost(post));
}
/**
* 修改岗位
*/
@GetMapping("/edit/{postId}")
public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
{
mmap.put("post", postService.selectPostById(postId));
return prefix + "/edit";
}
/**
* 修改保存岗位
*/
@RequiresPermissions("system:post:edit")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated Post post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
return toAjax(postService.updatePost(post));
}
/**
* 校验岗位名称
*/
@PostMapping("/checkPostNameUnique")
/**
* 进入寄养宠物界面
* @param mmap
* @return
*/
@GetMapping("/parkPet")
public String parkPet(ModelMap mmap){
// 获取当前登陆人信息
User user = ShiroUtils.getSysUser();
if (user == null) {
return "login";
}
mmap.put("userName", user.getUserName());
return prefix + "/parkPet";
}
@GetMapping("/list/{typeId}")
public String list(@PathVariable("typeId") Long typeId, ModelMap mmap) {
User user = ShiroUtils.getSysUser();
if (user != null) {
mmap.put("userName", user.getUserName());
} else {
mmap.put("userName", null);
}
Type type = new Type();
type.setTypeStatus("0");
List<Type> typeList = typeService.selectTypeList(type);
mmap.put("typeList", typeList);
Product productCondition = new Product();
productCondition.setProductType("宠物信息");
List<Product> productList = productService.selectProductList(productCondition);
mmap.put("productList", productList);
Type currentType = typeService.selectTypeById(typeId);
mmap.put("currentType", currentType);
return prefix + "/list";
}
@GetMapping("/product/{productId}")
public String product(@PathVariable("productId") Long productId, ModelMap mmap) {
User user = ShiroUtils.getSysUser();
if (user != null) {
mmap.put("userName", user.getUserName());
public List<Menu> list(Menu menu)
{
List<Menu> menuList = menuService.selectMenuList(menu);
return menuList;
}
/**
* 删除菜单
*/
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}")
@ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.selectCountMenuByParentId(menuId) > 0)
{
return AjaxResult.warn("存在子菜单,不允许删除");
}
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
{
return AjaxResult.warn("菜单已分配,不允许删除");
}
return toAjax(menuService.deleteMenuById(menuId));
}
/**
* 新增
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
Menu menu = null;
if (0L != parentId)
{
menu = menuService.selectMenuById(parentId);
}
else
{
menu = new Menu();
menu.setMenuId(0L);
menu.setMenuName("主目录");
List<SysRecycleOrder> list = sysRecycleOrderService.selectSysRecycleOrderList(sysRecycleOrder);
return getDataTable(list);
}
/**
* 新增回收订单信息
*/
@GetMapping("/add")
public String add()
{
// 获取当前登陆人信息
User user = ShiroUtils.getSysUser();
if(user == null){
return "login";
}
return prefix + "/add";
}
/**
* 新增保存回收订单信息
*/
@Log(title = "回收订单信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysRecycleOrder sysRecycleOrder)
{
// 获取当前登陆人信息
User user = ShiroUtils.getSysUser();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
sysRecycleOrder.setOrderNumber(format.format(new Date()));
sysRecycleOrder.setUserId(user.getUserId());
sysRecycleOrder.setStatus("待领养");
sysRecycleOrderService.insertSysRecycleOrder(sysRecycleOrder);
return AjaxResult.success(sysRecycleOrder.getOrderNumber());
}
/**
* 修改回收订单信息
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
SysRecycleOrder sysRecycleOrder = sysRecycleOrderService.selectSysRecycleOrderById(id);
mmap.put("sysRecycleOrder", sysRecycleOrder);
return prefix + "/edit";
}
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}
}
/**
* 获取IP方法
*
*/
public class IpUtils
{
public static String getIpAddr(HttpServletRequest request)
{
if (request == null)
{
return "unknown";
}
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
{
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
{
ip = request.getHeader("X-Forwarded-For");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
{
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
{
ip = request.getHeader("X-Real-IP");
}
private String prefix = "system/order";
@Autowired
private IOrderService orderService;
@Autowired
private IRoleService roleService;
@Autowired
private IProductService productService;
@Autowired
private IUserService userService;
@Autowired
private ICartService cartService;
@RequiresPermissions("system:order:view")
@GetMapping()
public String order(ModelMap mmap)
{
User user = ShiroUtils.getSysUser();
String roleString = roleService.selectRoleKeys(user.getUserId()).toString();
if(roleString.contains("admin")){
mmap.put("loginRole", "admin");
}else if(roleString.contains("seller")){
mmap.put("loginRole", "seller");
}else{
mmap.put("loginRole", "buyer");
}
return prefix + "/order";
}
/**
* 查询订单管理列表
*/
@RequiresPermissions("system:order:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(Order order)
{
User user = ShiroUtils.getSysUser();
String roleString = roleService.selectRoleKeys(user.getUserId()).toString();
startPage();
List<DictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
}
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(DictType dictType)
{
List<DictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<DictType> util = new ExcelUtil<DictType>(DictType.class);
return util.exportExcel(list, "字典类型");
}
/**
* 新增字典类型
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存字典类型
*/
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated DictType dict)
{
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
return toAjax(dictTypeService.insertDictType(dict));
}
/**
* 修改字典类型
*/
@GetMapping("/edit/{dictId}")
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
{
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
return prefix + "/edit";
}
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
{
mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/edit";
}
/**
* 修改保存菜单
*/
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:menu:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated Menu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
return toAjax(menuService.updateMenu(menu));
}
/**
* 选择菜单图标
*/
@GetMapping("/icon")
public String icon()
{
return prefix + "/icon";
}
/**
* 校验菜单名称
*/
@PostMapping("/checkMenuNameUnique")
@ResponseBody
public String checkMenuNameUnique(Menu menu)
{
return menuService.checkMenuNameUnique(menu);
}
/**
* 加载角色菜单列表树
/**
* 寄养订单管理Controller
*
*/
@Controller
@RequestMapping("/system/parkPetOrder")
public class SysParkpetOrderController extends BaseController
{
private String prefix = "system/parkPetOrder";
@Autowired
private ISysParkpetOrderService sysParkpetOrderService;
@Autowired
private IProductService productService;
@GetMapping("/parkPetOrderList")
public String parkPetOrderList(){
return prefix + "/order";
}
@GetMapping("/order")
public String order(ModelMap mmap)
{
User user = ShiroUtils.getSysUser();
if (user != null) {
mmap.put("userName", user.getUserName());
}
Product product = new Product();
product.setProductType("宠物信息");
product.setPetType("售卖");
@RequiresPermissions("system:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@GetMapping("/resetPwd/{userId}")
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
{
mmap.put("user", userService.selectUserById(userId));
return prefix + "/resetPwd";
}
@RequiresPermissions("system:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwdSave(User user)
{
userService.checkUserAllowed(user);
if (userService.resetUserPwd(user) > 0)
{
if (ShiroUtils.getUserId() == user.getUserId())
{
setSysUser(userService.selectUserById(user.getUserId()));
}
return success();
}
return error();
}
@RequiresPermissions("system:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(userService.deleteUserByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
return toAjax(orderService.updateOrder(order));
}
@GetMapping("/confirmStatus/{orderId}")
@ResponseBody
public AjaxResult confirmStatus(@PathVariable("orderId") Long orderId, ModelMap mmap)
{
Order order = orderService.selectOrderById(orderId);
order.setOrderStatus("2");
return toAjax(orderService.updateOrder(order));
}
@GetMapping("/sendStatus/{orderId}")
@ResponseBody
public AjaxResult sendStatus(@PathVariable("orderId") Long orderId, ModelMap mmap)
{
Order order = orderService.selectOrderById(orderId);
order.setOrderStatus("3");
return toAjax(orderService.updateOrder(order));
}
@GetMapping("/receiveStatus/{orderId}")
@ResponseBody
public AjaxResult receiveStatus(@PathVariable("orderId") Long orderId, ModelMap mmap)
{
Order order = orderService.selectOrderById(orderId);
order.setOrderStatus("4");
return toAjax(orderService.updateOrder(order));
}
/**
* 修改保存订单管理
*/
@RequiresPermissions("system:order:edit")
@Log(title = "订单管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Order order)
{
mmap.put("user", userService.selectUserById(userId));
return prefix + "/resetPwd";
}
@RequiresPermissions("system:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwdSave(User user)
{
userService.checkUserAllowed(user);
if (userService.resetUserPwd(user) > 0)
{
if (ShiroUtils.getUserId() == user.getUserId())
{
setSysUser(userService.selectUserById(user.getUserId()));
}
return success();
}
return error();
}
@RequiresPermissions("system:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(userService.deleteUserByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
/**
* 校验用户名
*/
@PostMapping("/checkLoginNameUnique")
@ResponseBody
public String checkLoginNameUnique(User user)
{
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add";
}
/**
* 新增保存部门
*/
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated Dept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
return toAjax(deptService.insertDept(dept));
}
/**
* 修改
*/
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
Dept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
dept.setParentName("无");
}
mmap.put("dept", dept);
return prefix + "/edit";
}
/**
* 保存
*/
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated Dept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if(dept.getParentId().equals(dept.getDeptId()))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
{
return AjaxResult.error(e.getMessage());
}
}
/**
* 通用上传请求(多个)
*/
@PostMapping("/common/uploads")
@ResponseBody
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
{
try
{
// 上传文件路径
String filePath = System.getProperty("user.dir").replace('\\','/')+RuoYiConfig.getUploadPath();
List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>();
for (MultipartFile file : files)
{
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
urls.add(url);
fileNames.add(fileName);
newFileNames.add(FileUtils.getName(fileName));
originalFilenames.add(file.getOriginalFilename());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
mmap.put("dept", dept);
return prefix + "/edit";
}
/**
* 保存
*/
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated Dept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if(dept.getParentId().equals(dept.getDeptId()))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
return toAjax(deptService.updateDept(dept));
}
/**
* 删除
*/
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{deptId}")
@ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId)
{
if (deptService.selectDeptCount(deptId) > 0)
{
return AjaxResult.warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return AjaxResult.warn("部门存在用户,不允许删除");
}
return toAjax(deptService.deleteDeptById(deptId));
}
/**
* 校验部门名称
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
List<Dept> deptList = deptService.selectDeptList(dept);
return deptList;
}
/**
* 新增部门
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add";
}
/**
* 新增保存部门
*/
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated Dept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
return toAjax(deptService.insertDept(dept));
}
/**
* 修改
*/
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
Dept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
dept.setParentName("无");
}
mmap.put("dept", dept);
return prefix + "/edit";
}
/**
* 保存
*/
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dept:edit")
return getDataTable(list);
}
/**
* 导出商品管理列表
*/
@RequiresPermissions("system:product:export")
@Log(title = "商品管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Product product)
{
List<Product> list = productService.selectProductList(product);
ExcelUtil<Product> util = new ExcelUtil<Product>(Product.class);
return util.exportExcel(list, "product");
}
/**
* 新增商品管理
*/
@GetMapping("/add")
public String add( ModelMap mmap)
{
return prefix + "/add";
}
/**
* 新增商品管理
*/
@GetMapping("/petAdd")
public String petAdd( ModelMap mmap)
{
return "system/pet/add";
}
/**
* 新增保存商品管理
* @throws IOException
*/
@RequiresPermissions("system:product:add")
@Log(title = "商品管理", businessType = BusinessType.INSERT)
@PostMapping("/checkMenuNameUnique")
@ResponseBody
public String checkMenuNameUnique(Menu menu)
{
return menuService.checkMenuNameUnique(menu);
}
/**
* 加载角色菜单列表树
*/
@GetMapping("/roleMenuTreeData")
@ResponseBody
public List<Ztree> roleMenuTreeData(Role role)
{
List<Ztree> ztrees = menuService.roleMenuTreeData(role);
return ztrees;
}
/**
* 加载所有菜单列表树
*/
@GetMapping("/menuTreeData")
@ResponseBody
public List<Ztree> menuTreeData(Role role)
{
List<Ztree> ztrees = menuService.menuTreeData();
return ztrees;
}
/**
* 选择菜单树
*/
@GetMapping("/selectMenuTree/{menuId}")
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap)
{
mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/tree";
}
}