概述
源码获取:俺的博客首页 "资源" 里下载!
项目介绍
本项目分为前后台,前台为普通用户登录,后台为管理员登录;
管理员角色包含以下功能:
管理员登录,管理员信息管理,用户信息管理,新闻公告管理,套餐类型信息管理,城市信息管理,摄影基地信息管理,套餐信息管理,订单信息管理,查看评价信息等功能。
用户角色包含以下功能:
按分类查看,用户登录,查看商品详情,加入购物车,提交订单,查看订单,修改个人信息,查看网站公告,查看摄影基地等功能。
环境需要
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+CSS+JavaScript+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
景点管理控制层:
@Controller
@Scope("prototype")
public class SpotsController {
private static final Logger logger = LoggerFactory.getLogger(SpotsController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "spotsService")
private ISpotsService spotsService;
/**
* 添加拍摄景点
*
* @param spots
* @param HttpServletRequest
* @return
*/
@RequestMapping(value = "addSpots", method = RequestMethod.POST)
@ResponseBody
public ReturnResult addSpots(TSpots spots, HttpServletRequest request) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, String> map = OperationFileUtil.multiFileUpload(request,
request.getServletContext().getRealPath("/") + "uploads\spots\");
String filePath = "";
for (Map.Entry<String, String> entry : map.entrySet()) {
filePath = entry.getValue();
}
filePath = filePath.replace(request.getServletContext().getRealPath("/"), "/");
spots.setPath(filePath);
spots.setCreatetime(new Date());
spotsService.insert(spots);
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("新增spots失败" + e);
}
return returnResult;
}
/**
* 修改spots
* @param spots
* @return
*/
@RequestMapping(value = "updateSpots", method = RequestMethod.POST)
@ResponseBody
public ReturnResult updateSpots(TSpots spots) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
spotsService.updateBySQL("UPDATE t_spots SET name='" + spots.getName() + "',content='"+spots.getContent()+"', status="+spots.getStatus()+" WHERE id=" + spots.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("修改spots失败" + e);
}
return returnResult;
}
/**
* 分页获取spots
* @return
*/
@RequestMapping(value = "getSpotsListByPage", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getSpotsListByPage(PageVO page) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT DISTINCT * FROM t_spots WHERE 1=1");
List<Map<String, Object>> results = spotsService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total = spotsService.selectCount(new TSpots());
int rows = page.getRows();
rows = rows == 0 ? 10 : rows;
resultMap.put("total", (total % rows != 0 ? (total / rows + 1) : (total / rows)));
resultMap.put("page", page.getPage());
resultMap.put("records", total);
resultMap.put("rows", results);
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(resultMap);
}
}catch (Exception e) {
logger.error("分页获取spots失败" + e);
}
return returnResult;
}
/**
* 根据获取id spots
* @param id
* @return
*/
@RequestMapping(value = "getSpotsById", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getSpotsById(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(spotsService.selectByPrimaryKey(id));
}catch (Exception e) {
logger.error("根据获取spots失败" + e);
}
return returnResult;
}
/**
* 获取所有启用的spots
* @return
*/
@RequestMapping(value = "getAllSpots", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAllSpots() {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(spotsService.getAllSpots());
} catch (Exception e) {
logger.error("获取所有启用spots失败" + e);
}
return returnResult;
}
/**
* 获取所有5条启用的spots
* @return
*/
@RequestMapping(value = "getFiveSpots", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getFiveSpots() {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(spotsService.selectBySQL("select * from t_spots ORDER BY id DESC limit 0,5"));
} catch (Exception e) {
logger.error("获取所有5条启用的spots失败" + e);
}
return returnResult;
}
}
用户管理控制层:
@Controller
@RequestMapping("/user")
@Scope("prototype")
public class UserController {
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "userService")
private IUserService userService;
/**
* 登录
* @param user
* @param session
* @return
*/
@RequestMapping(value = "login")
@ResponseBody
public ReturnResult login(TUser user, HttpSession session) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
user = userService.login(user);
if (user != null) {
user.setPassword(null);
session.setAttribute("user", user);
returnResult.setStatus(ReturnCodeType.SUCCESS);
}
} catch (Exception e) {
logger.error("登录失败" + e);
}
return returnResult;
}
/**
* 从session中获取用户信息
* @param session
* @return
*/
@RequestMapping("getUserInfo")
@ResponseBody
public ReturnResult getUserInfo(HttpSession session) {
returnResult.setStatus(ReturnCodeType.FAILURE);
TUser user = (TUser) session.getAttribute("user");
if (user != null) {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(user);
} else {
logger.info("获取用户信息失败:用户未登录");
}
return returnResult;
}
/**
* 注册用户
* @param user
* @return
*/
@RequestMapping(value = "register")
@ResponseBody
public ReturnResult register(TUser user) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
if (userService.checkUserByName(user.getName())) {
if (userService.register(user) >= 0) {
returnResult.setStatus(ReturnCodeType.SUCCESS);
}
}
} catch (Exception e) {
logger.error("注册失败" + e);
}
return returnResult;
}
/**
* 检测用户名是否存在
* @param name
* @return
*/
@RequestMapping(value = "checkUserName")
@ResponseBody
public ReturnResult checkUserName(String name) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
if (userService.checkUserByName(name)) {
returnResult.setStatus(ReturnCodeType.SUCCESS);
}
} catch (Exception e) {
logger.error("检测用户名是否存在失败:" + e);
}
return returnResult;
}
/**
* 管理员查看所有的用户信息
* @param session
* @return
*/
@RequestMapping("getAllUserInfo")
@ResponseBody
public ReturnResult getAllUserInfo(HttpSession session,PageVO page,String name) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
if (session.getAttribute("admin") != null) {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT DISTINCT * FROM t_user WHERE 1=1");
if(StringUtils.isNotBlank(name)){
sql.append(" AND name="+name);
}
List<Map<String, Object>> results = userService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total = userService.selectCount(new TUser());
int rows = page.getRows();
rows = rows == 0 ? 10 : rows;
resultMap.put("total", (total % rows != 0 ? (total / rows + 1) : (total / rows)));
resultMap.put("page", page.getPage());
resultMap.put("records", total);
resultMap.put("rows", results);
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(resultMap);
}
} else {
logger.info("获取所有的用户信息失败:管理员未登录");
}
} catch (Exception e) {
logger.error("获取所有的用户信息失败:" + e);
}
return returnResult;
}
/**
* 退出
* @param session
* @return
*/
@RequestMapping("logout")
@ResponseBody
public ReturnResult logout(HttpSession session) {
session.invalidate();
return returnResult.setStatus(ReturnCodeType.SUCCESS);
}
/**
* 修改密码
* @param oldPassword
* @param password
* @param session
* @return
*/
@RequestMapping("updatePassword")
@ResponseBody
public ReturnResult updatePassword(TUser user) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
if (userService.updatePassword(user) > 0) {
returnResult.setStatus(ReturnCodeType.SUCCESS);
}
} catch (Exception e) {
logger.error("修改密码失败:" + e);
}
return returnResult;
}
}
后台管理控制层:
@Controller
@RequestMapping("/admin")
@Scope("prototype")
public class AdminController {
private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "adminService")
private IAdminService adminService;
/**
* 管理员登录
* @param admin
* @param session
* @return
*/
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
public ReturnResult login(TAdmin admin, HttpSession session) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
admin = adminService.login(admin);
if (admin != null) {
admin.setPassword(null);
session.setAttribute("admin", admin);
returnResult.setStatus(ReturnCodeType.SUCCESS);
}
} catch (Exception e) {
logger.error("登录失败:" + e);
}
return returnResult;
}
/**
* 从session获取管理员信息
* @param session
* @return
*/
@RequestMapping(value="getAdminInfo", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAdminInfo(HttpSession session) {
returnResult.setStatus(ReturnCodeType.FAILURE);
TAdmin admin = (TAdmin) session.getAttribute("admin");
if (admin != null) {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(admin);
} else {
logger.info("获取管理员信息失败:管理员未登录");
}
return returnResult;
}
/**
* 退出
* @param session
* @return
*/
@RequestMapping(value="logout", method = RequestMethod.POST)
@ResponseBody
public ReturnResult logout(HttpSession session) {
session.invalidate();
return returnResult.setStatus(ReturnCodeType.SUCCESS);
}
}
源码获取:俺的博客首页 "资源" 里下载!
最后
以上就是悲凉手套为你收集整理的Java项目:儿童摄影预约系统(java+SSM+JSP+JS+jquery+Mysql)源码获取:俺的博客首页 "资源" 里下载!源码获取:俺的博客首页 "资源" 里下载!的全部内容,希望文章能够帮你解决Java项目:儿童摄影预约系统(java+SSM+JSP+JS+jquery+Mysql)源码获取:俺的博客首页 "资源" 里下载!源码获取:俺的博客首页 "资源" 里下载!所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复