基于javaweb+mysql的springboot宠物领养寄养商城系统(java+springboot+html+bootstrap+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot宠物领养寄养商城系统(java+springboot+html+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项目:是;
技术栈
-
后端:SpringBoot+Mybatis
-
前端:HTML+CSS+Bootstrap+jQuery
使用说明
-
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
-
使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
- 将项目中application.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,登录地址:http://localhost:8089/login
管理员: admin/admin123
普通账户: liming/123456
*/
@GetMapping("/edit")
public String edit(ModelMap mmap)
{
User user = getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/edit";
}
/**
* 修改头像
*/
@GetMapping("/avatar")
public String avatar(ModelMap mmap)
{
User user = getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/avatar";
}
/**
* 修改用户
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/update")
@ResponseBody
public AjaxResult update(User user)
{
User currentUser = getSysUser();
currentUser.setUserName(user.getUserName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (userService.updateUserInfo(currentUser) > 0)
{
setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
return error();
}
/**
* 保存头像
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateAvatar")
@RequiresPermissions("system:menu:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated Menu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
return toAjax(menuService.insertMenu(menu));
}
/**
* 修改菜单
*/
@GetMapping("/edit/{menuId}")
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()
{
/**
* 角色分配数据权限
*/
@GetMapping("/authDataScope/{roleId}")
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/dataScope";
}
/**
* 保存角色分配数据权限
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/authDataScope")
@ResponseBody
public AjaxResult authDataScopeSave(Role role)
{
roleService.checkRoleAllowed(role);
if (roleService.authDataScope(role) > 0)
{
setSysUser(userService.selectUserById(getSysUser().getUserId()));
return success();
}
return error();
}
@RequiresPermissions("system:role:remove")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(roleService.deleteRoleByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
/**
* 校验角色名称
*/
@PostMapping("/checkRoleNameUnique")
@ResponseBody
public String checkRoleNameUnique(Role role)
{
return roleService.checkRoleNameUnique(role);
}
mmap.put("userName", user.getUserName());
}
Order queryOrder = new Order();
queryOrder.setOrderStatus("5");
List<Order> productOrder = orderService.selectOrderList(queryOrder);
mmap.put("productOrder", productOrder);
return prefix + "/buyerShow";
}
@GetMapping("/onlinemessage")
public String onlinemessage(ModelMap mmap) {
User user = ShiroUtils.getSysUser();
if (user != null) {
mmap.put("userName", user.getUserName());
}
return prefix + "/onlinemessage";
}
}
/**
* 参数配置 信息操作处理
*
*/
@Controller
@RequestMapping("/system/config")
public class ConfigController extends BaseController
{
private String prefix = "system/config";
@Autowired
private IConfigService configService;
@RequiresPermissions("system:config:view")
@GetMapping()
public String config()
{
return prefix + "/config";
}
/**
* 查询参数配置列表
*/
@RequiresPermissions("system:config:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(Config config)
{
startPage();
/**
* 修改保存订单管理
*/
@RequiresPermissions("system:order:edit")
@Log(title = "订单管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Order order)
{
return toAjax(orderService.updateOrder(order));
}
/**
* 删除订单管理
*/
@RequiresPermissions("system:order:remove")
@Log(title = "订单管理", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(orderService.deleteOrderByIds(ids));
}
}
if (userService.updateUserInfo(currentUser) > 0)
{
setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
return error();
}
/**
* 保存头像
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateAvatar")
@ResponseBody
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
{
User currentUser = getSysUser();
try
{
if (!file.isEmpty())
{
String filePath = System.getProperty("user.dir").replace('\\','/')+RuoYiConfig.getUploadPath();
String avatar = FileUploadUtils.upload(filePath, file);
currentUser.setAvatar(avatar);
if (userService.updateUserInfo(currentUser) > 0)
{
setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
}
return error();
}
catch (Exception e)
{
log.error("修改头像失败!", e);
return error(e.getMessage());
}
}
}
}
/**
* 修改保存参数配置
*/
@RequiresPermissions("system:config:edit")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated Config config)
{
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
return toAjax(configService.updateConfig(config));
}
/**
* 删除参数配置
*/
@RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(configService.deleteConfigByIds(ids));
}
/**
* 校验参数键名
*/
@PostMapping("/checkConfigKeyUnique")
@ResponseBody
public String checkConfigKeyUnique(Config config)
{
return configService.checkConfigKeyUnique(config);
}
}
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)
{
return userService.checkLoginNameUnique(user.getLoginName());
}
/**
* 校验手机号码
*/
@PostMapping("/checkPhoneUnique")
@ResponseBody
public String checkPhoneUnique(User user)
{
@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";
}
}
* 校验菜单名称
*/
@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";
}
}
@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("message", message);
return prefix + "/edit";
}
/**
* 修改保存留言管理
*/
@RequiresPermissions("system:message:edit")
@Log(title = "留言管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Message message)
{
return toAjax(messageService.updateMessage(message));
}
/**
* 删除留言管理
*/
@RequiresPermissions("system:message:remove")
@Log(title = "留言管理", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(messageService.deleteMessageByIds(ids));
}
}
/**
* 登录验证
*
*/
@Controller
@RequestMapping("/front")
public class FrontController extends BaseController {
private String prefix = "front";
@Autowired
private ITypeService typeService;
@Autowired
private IProductService productService;
@Autowired
private IOrderService orderService;
}
catch (Exception e)
{
log.error("修改头像失败!", e);
return error(e.getMessage());
}
}
}
/**
* 部门信息
*
*/
@Controller
@RequestMapping("/system/dept")
public class DeptController extends BaseController
{
private String prefix = "system/dept";
@Autowired
private IDeptService deptService;
@RequiresPermissions("system:dept:view")
@GetMapping()
public String dept()
{
return prefix + "/dept";
}
String localPath = System.getProperty("user.dir").replace('\\','/')+RuoYiConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"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");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
{
ip = request.getRemoteAddr();
}
return prefix + "/add";
}
/**
* 新增保存角色
*/
@RequiresPermissions("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated Role role)
{
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
return toAjax(roleService.insertRole(role));
}
/**
* 修改角色
*/
@GetMapping("/edit/{roleId}")
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/edit";
}
/**
* 修改保存角色
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated Role role)
{