基于javaweb+mysql的springboot婚纱影楼摄影预约网站设计和实现(javaweb+ssm+springboot)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot婚纱影楼摄影预约网站设计和实现(javaweb+ssm+springboot)
主要功能设计: 运行环境: java jdk 1.8 环境:IDEA tomcat环境: Tomcat 7.x、8
主要功能说明: 管理员角色包含以下功能:管理员登录,订单管理,摄影师管理,级别管理,标签管理,摄影地点管理,客片管理,轮播图管理,资讯管理等功能。
客户角色包含以下功能:客户首页,客片欣赏,预约摄影师,会员登录,填写预约摄影师信息,查看活动,订单查看等功能。
技术框架: HTML+CSS+JavaScript+jsp+mysql+Spring+SpringMVC+mybatis+Spring boot 数据库: Mysql数据库
}
List<Map<String, Object>> results = labelService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total =Integer.valueOf(labelService.selectBySQL(countSql.toString()).get(0).get("total").toString());
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("分页获取label失败" + e);
}
return returnResult;
}
/**
* 获取所有启用的label
* @param label
* @return
*/
@RequestMapping(value = "getAllLabel", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAllLabel(){
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(labelService.getAllLabel());
} catch (Exception e) {
logger.error("获取所有启用的label" + e);
}
return returnResult;
}
}
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT * FROM t_label WHERE 1=1");
StringBuffer countSql = new StringBuffer("SELECT COUNT(*) AS total FROM t_label WHERE 1=1");
if(StringUtils.isNotBlank(Status)){
sql.append(" AND status="+Status);
countSql.append(" AND status="+Status);
}
List<Map<String, Object>> results = labelService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total =Integer.valueOf(labelService.selectBySQL(countSql.toString()).get(0).get("total").toString());
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("分页获取label失败" + e);
}
return returnResult;
}
/**
* 获取所有启用的label
* @param label
* @return
*/
@RequestMapping(value = "getAllLabel", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAllLabel(){
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(labelService.getAllLabel());
} catch (Exception e) {
logger.error("获取所有启用的label" + e);
}
return returnResult;
}
}
/**
*
*
*/
@Controller
@Scope("prototype")
public class LevelController {
private static final Logger logger = LoggerFactory.getLogger(LevelController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "levelService")
private ILevelService levelService;
/**
* 添加级别
*
* @param level
* @return
*/
@RequestMapping(value = "addLevel", method = RequestMethod.POST)
@ResponseBody
public ReturnResult addLevel(TLevel level) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
level.setCreatetime(new Date());
level.setStatus("0");
levelService.insert(level);
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("新增level失败" + e);
}
}
List<Map<String, Object>> results = levelService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total = Integer.valueOf(levelService.selectBySQL(countSql.toString()).get(0).get("total").toString());
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("分页获取level失败" + e);
}
return returnResult;
}
/**
* 获取所有启用的level
* @param level
* @return
*/
@RequestMapping(value = "getAllLevel", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAllLevel(){
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(levelService.getAllLevel());
} catch (Exception e) {
logger.error("获取所有启用的level" + e);
}
return returnResult;
}
}
sql.append(" AND b.labelId=" + labelId);
sql.append(" AND f.id=" + labelId);
}
if (StringUtils.isNotBlank(levelId)) {
sql.append(" AND c.levelId=" + levelId);
sql.append(" AND g.id=" + levelId);
}
if (StringUtils.isNotBlank(spotsId)) {
sql.append(" AND d.spotsId=" + spotsId);
sql.append(" AND h.id=" + spotsId);
}
if (StringUtils.isNotBlank(status)) {
sql.append(" AND a.status=" + status);
}
if (StringUtils.isNotBlank(name)) {
sql.append(" AND a.name=" + name);
}
List<Map<String, Object>> results = photographerService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total = photographerService.selectCount(new TPhotographer());
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("分页获取photographer失败" + e);
}
return returnResult;
}
/**
* 分页获取启用的photographer
*
* @return
*/
@RequestMapping(value = "getPhotographerListByPageStatus", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getPhotographerListByPageStatus(PageVO page, String labelId, String levelId, String spotsId,
String start, String end) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer(
"SELECT a.*,f.`name` AS label,g.`name` AS level,h.`name` AS spots FROM t_photographer a,t_photographer_label b,t_photographer_level c ,t_photographer_spots d,t_label f,t_level g,t_spots h WHERE a.id=b.photographerId AND a.id = c.photographer AND a.id = d.photographerId AND f.id=b.labelId AND g.id=c.levelId AND h.id= d.spotsId AND a.status=0");
StringBuffer countSql = new StringBuffer("SELECT COUNT(*) AS total FROM t_photographer a,t_photographer_label b,t_photographer_level c ,t_photographer_spots d,t_label f,t_level g,t_spots h WHERE a.id=b.photographerId AND a.id = c.photographer AND a.id = d.photographerId AND f.id=b.labelId AND g.id=c.levelId AND h.id= d.spotsId AND a.status=0");
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
/**
* 根据id获取label
* @param label
* @return
*/
@RequestMapping(value = "getLabelById", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getLabelById(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(labelService.selectByPrimaryKey(id));
} catch (Exception e) {
logger.error("根据id获取label失败" + e);
}
return returnResult;
}
/**
* 分页获取label
* @return
*/
@RequestMapping(value = "getLabelListByPage", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getLabelListByPage(PageVO page,String Status) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT * FROM t_label WHERE 1=1");
StringBuffer countSql = new StringBuffer("SELECT COUNT(*) AS total FROM t_label WHERE 1=1");
if(StringUtils.isNotBlank(Status)){
sql.append(" AND status="+Status);
countSql.append(" AND status="+Status);
}
List<Map<String, Object>> results = labelService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total =Integer.valueOf(labelService.selectBySQL(countSql.toString()).get(0).get("total").toString());
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);
}
}
/**
* 多文件上传辅助
*
* @param request
* 当前上传的请求
* @param basePath
* 保存文件的路径
* @param exclude
* 排除文件名字符串,以逗号分隔的,默认无可传null
* @return
* @throws IOException
*/
private static Map<String, String> multifileUploadAssist(HttpServletRequest request, String basePath, String exclude) throws IOException {
exclude = exclude == null ? "" : exclude;
Map<String, String> filePaths = new HashMap<String, String>();
File file = null;
// 创建一个通用的多部分解析器
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
// 判断 request 是否有文件上传,即多部分请求
if (multipartResolver.isMultipart(request)) {
// 转换成多部分request
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
// get the parameter names of the MULTIPART files contained in this request
Iterator<String> iter = multiRequest.getFileNames();
while (iter.hasNext()) {
// 取得上传文件
List<MultipartFile> multipartFiles = multiRequest.getFiles(iter.next());
for (MultipartFile multipartFile : multipartFiles) {
String fileName = multipartFile.getOriginalFilename();
if (StringUtils.isNotEmpty(fileName) && (!exclude.contains(fileName))) {
file = new File(basePath + changeFilename2UUID(fileName));
filePaths.put(fileName, file.getPath());
multipartFile.transferTo(file);
}
}
}
}
return filePaths;
}
/**
* 将文件名转变为UUID命名的 ,保留文件后缀
*
* @param filename
* @return
*/
public static String changeFilename2UUID(String filename) {
String uuid = UUID.randomUUID().toString();
return uuid + "." + FilenameUtils.getExtension(filename);
}
/**
*
*
*/
@Controller
@Scope("prototype")
public class BannerController {
private static final Logger logger = LoggerFactory.getLogger(BannerController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "bannerService")
private IBannerService bannerService;
/**
* 添加banner图
*
* @param banner
* @param HttpServletRequest
logger.error("获取所有启用的Photographer失败" + e);
}
return returnResult;
}
}
/**
*
*
*/
@Controller
@Scope("prototype")
public class WorksController {
private static final Logger logger = LoggerFactory.getLogger(WorksController.class);
private ReturnResult returnResult = new ReturnResult();
+ " WHERE photographer=" + photographer.getId());
photographerSpotsService.updateBySQL("UPDATE t_photographer_spots SET spotsId=" + spotsId
+ " WHERE photographerId=" + photographer.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("修改photographer失败" + e);
e.printStackTrace();
}
return returnResult;
}
/**
* 根据id获取Photographer
* admin
*
* @param Photographer
* @return
*/
@RequestMapping(value = "getPhotographerById", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getPhotographerById(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS)
.setData(photographerService.selectBySQL(
"SELECT a.*,b.labelId,c.levelId,d.spotsId FROM t_photographer a,t_photographer_label b,t_photographer_level c,t_photographer_spots d WHERE a.id ="
+ id + " AND b.photographerId=" + id + " AND c.photographer=" + id
+ " AND d.photographerId=" + id + "")
.get(0));
} catch (Exception e) {
logger.error("根据id获取Photographer失败" + e);
}
return returnResult;
}
/**
* 根据id获取Photographer
* user
*
* @param Photographer
* @return
*/
@RequestMapping(value = "getPhotographer")
@ResponseBody
public ReturnResult getPhotographer(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
photographerLabelService.insert(label);
TPhotographerLevel level = new TPhotographerLevel(levelId, id, new Date(), "0");
photographerLevelService.insert(level);
TPhotographerSpots spots = new TPhotographerSpots(spotsId, id, new Date(), "0");
photographerSpotsService.insert(spots);
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("新增photographer失败" + e);
}
return returnResult;
}
/**
* 修改photographer状态
*
* @param photographer
* @return
*/
@RequestMapping(value = "updatePhotographerStatus", method = RequestMethod.GET)
@ResponseBody
public ReturnResult updatePhotographerStatus(TPhotographer photographer) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
photographerService.updateBySQL("UPDATE t_photographer SET status=" + photographer.getStatus()
+ " WHERE id=" + photographer.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("更新photographer状态失败" + e);
}
return returnResult;
}
/**
* 修改photographer的name和summary
*
* @param photographer
* @return
*/
@RequestMapping(value = "updatePhotographer", method = RequestMethod.POST)
@ResponseBody
public ReturnResult updatePhotographer(TPhotographer photographer, Integer labelId, Integer levelId,
Integer spotsId) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
public ReturnResult getWorksListByPage(PageVO page,String photographerId,String spotsId,String status) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT a.*,b.`name` AS photographer,c.`name` AS spots FROM t_works a,t_photographer b,t_spots c WHERE a.photographerId=b.id AND a.spotsId=c.id");
StringBuffer countSql = new StringBuffer("SELECT COUNT(*) AS total FROM t_works a,t_photographer b,t_spots c WHERE a.photographerId=b.id AND a.spotsId=c.id");
if(StringUtils.isNotBlank(photographerId)){
sql.append(" AND b.id="+photographerId);
countSql.append(" AND b.id="+photographerId);
}
if(StringUtils.isNotBlank(spotsId)){
sql.append(" AND c.id="+spotsId);
countSql.append(" AND c.id="+spotsId);
}
if(StringUtils.isNotBlank(status)){
sql.append(" AND a.status="+status);
countSql.append(" AND a.status="+status);
}
List<Map<String, Object>> results = worksService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total = Integer.valueOf(worksService.selectBySQL(countSql.toString()).get(0).get("total").toString());
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("分页获取works失败" + e);
}
return returnResult;
}
/**
* 分页获取启用的works
* @return
*/
@RequestMapping(value = "getWorksListByPageStatus", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getWorksListByPageStatus(String sord,String spotsId) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
String sql = "SELECT * FROM t_works WHERE status=0";
if(StringUtils.isNotBlank(sord)){
sql="SELECT * FROM t_works WHERE status=0 ORDER BY id DESC";
}
@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;
}
}
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("分页获取works失败" + e);
}
return returnResult;
}
/**
* 分页获取启用的works
* @return
*/
@RequestMapping(value = "getWorksListByPageStatus", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getWorksListByPageStatus(String sord,String spotsId) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
String sql = "SELECT * FROM t_works WHERE status=0";
if(StringUtils.isNotBlank(sord)){
sql="SELECT * FROM t_works WHERE status=0 ORDER BY id DESC";
}
if(StringUtils.isNotBlank(spotsId)){
sql = "SELECT * FROM t_works WHERE status=0 AND spotsId="+spotsId;
}
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(worksService.selectBySQL(sql));
}catch (Exception e) {
logger.error("分页获取启用的works失败" + 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);
resultMap.put("page", page.getPage());
resultMap.put("records", total);
resultMap.put("rows", results);
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(resultMap);
}
}catch (Exception e) {
logger.error("分页获取level失败" + e);
}
return returnResult;
}
/**
* 获取所有启用的level
* @param level
* @return
*/
@RequestMapping(value = "getAllLevel", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAllLevel(){
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(levelService.getAllLevel());
} catch (Exception e) {
logger.error("获取所有启用的level" + e);
}
return returnResult;
}
}
* @return
*/
@RequestMapping(value = "updateLabel", method = RequestMethod.POST)
@ResponseBody
public ReturnResult updateLabel(TLabel label) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
labelService.updateBySQL("UPDATE t_label SET name='" + label.getName() + "', status="+label.getStatus()+" WHERE id=" + label.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("修改label失败" + e);
}
return returnResult;
}
/**
* 根据id获取label
* @param label
* @return
*/
@RequestMapping(value = "getLabelById", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getLabelById(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(labelService.selectByPrimaryKey(id));
} catch (Exception e) {
logger.error("根据id获取label失败" + e);
}
return returnResult;
}
/**
* 分页获取label
* @return
*/
@RequestMapping(value = "getLabelListByPage", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getLabelListByPage(PageVO page,String Status) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {