基于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数据库
/**
*
*
*/
@Controller
@Scope("prototype")
public class ScheduleController {
private static final Logger logger = LoggerFactory.getLogger(ScheduleController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "scheduleService")
private IScheduleService scheduleService;
/**
* 添加预约
*
* @param schedule
* @param session
* @return
*/
@RequestMapping(value = "addSchedule", method = RequestMethod.POST)
@ResponseBody
public ReturnResult addSchedule(TSchedule schedule, HttpSession session,String startdate,String enddate) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
schedule.setStart(DateFormater.stringToDate(startdate));
schedule.setEnd(DateFormater.stringToDate(enddate));
schedule.setCreatetime(new Date());
TUser user = (TUser)session.getAttribute("user");
schedule.setUserid(user.getId());
if(scheduleService.insert(schedule)>0){
returnResult.setStatus(ReturnCodeType.SUCCESS);
}
} catch (Exception e) {
logger.error("新增schedule失败" + 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;
}
}
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;
}
/**
/**
* 根据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 {
returnResult.setStatus(ReturnCodeType.SUCCESS)
.setData(photographerService.selectBySQL(
"SELECT a.name,a.head,a.summary,d.`name` AS level,e.`name` AS spots FROM t_photographer a,t_photographer_level b,t_photographer_spots c,t_level d,t_spots e WHERE a.id=" + id + " AND b.photographer=" + id + " AND c.photographerId=" + id + " AND d.id=b.levelId AND e.id = c.spotsId AND a.`status`=0")
.get(0));
} catch (Exception e) {
logger.error("根据id获取Photographer失败" + e);
}
return returnResult;
}
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(infoService.selectByPrimaryKey(id));
}catch (Exception e) {
logger.error("根据获取info失败" + e);
}
return returnResult;
}
/**
* 获取所有启用的info
* @return
*/
@RequestMapping(value = "getAllInfo", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getAllInfo() {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(infoService.getAllInfo());
}catch (Exception e) {
logger.error("根据获取启用info失败" + e);
}
return returnResult;
}
/**
* 获取所有最新6条启用的info
* @return
*/
@RequestMapping(value = "getSixInfo", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getSixInfo() {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(infoService.selectBySQL("select * from t_infomation WHERE `status` = 0 ORDER BY id DESC limit 0,6"));
}catch (Exception e) {
logger.error("获取所有最新6条启用的info失败" + e);
}
return returnResult;
}
/**
* 富文本上头本地图片
*
* @param request
* @return
* @throws IOException
* @throws IllegalStateException
*/
@ResponseBody
@RequestMapping(value = "info/upload")
public Map<String, Object> upload(HttpServletRequest request) throws IllegalStateException, IOException {
Map<String, String> map = OperationFileUtil.multiFileUpload(request,
request.getServletContext().getRealPath("/") + "uploads/info/");
String filePath = "";
try {
commentService.deleteByPrimaryKey(id);
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("删除comment失败" + e);
}
return returnResult;
}
/**
* 根据摄影师id查询评论
*
* @param comment
* @param HttpServletRequest
* @return
*/
@RequestMapping(value = "getCommentByPid", method = RequestMethod.GET)
@ResponseBody
public ReturnResult getCommentByPid(Integer pid) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(commentService.selectBySQL("SELECT a.`comment`,a.createTime,b.`name` FROM t_comment a,t_user b where a.userId=b.id AND a.photographerId="+pid));
} catch (Exception e) {
logger.error("根据摄影师id查询评论" + e);
}
return returnResult;
}
/**
* 分页获取comment
* @return
*/
@RequestMapping(value = "getCommentListByPage", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getCommentListByPage(PageVO page) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT DISTINCT * FROM t_comment WHERE 1=1");
List<Map<String, Object>> results = commentService.selectPageBySQL(sql.toString(), page.getPage() - 1,
page.getRows());
if (!results.isEmpty() && results != null) {
int total = commentService.selectCount(new TComment());
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());
+ " 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 {
returnResult.setStatus(ReturnCodeType.SUCCESS)
.setData(photographerService.selectBySQL(
"SELECT a.name,a.head,a.summary,d.`name` AS level,e.`name` AS spots FROM t_photographer a,t_photographer_level b,t_photographer_spots c,t_level d,t_spots e WHERE a.id=" + id + " AND b.photographer=" + id + " AND c.photographerId=" + id + " AND d.id=b.levelId AND e.id = c.spotsId AND a.`status`=0")
.get(0));
} catch (Exception e) {
logger.error("根据id获取Photographer失败" + e);
}
return returnResult;
}
/**
* 分页获取photographer
*
* @return
*/
@RequestMapping(value = "getPhotographerListByPage", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getPhotographerListByPage(PageVO page, String labelId, String levelId, String spotsId,
String beforeTime, String afterTime, String status, String name) {
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");
if (StringUtils.isNotBlank(labelId)) {
sql.append(" AND b.labelId=" + labelId);
StringBuffer sql = new StringBuffer("SELECT * FROM t_level WHERE 1=1");
StringBuffer countSql = new StringBuffer("SELECT COUNT(*) AS total FROM t_level WHERE 1=1");
if(StringUtils.isNotBlank(Status)){
sql.append(" AND status="+Status);
countSql.append(" AND status="+Status);
}
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;
}
}
try {
String filePath = request.getServletContext().getRealPath("/");
TBanner banner = bannerService.selectByPrimaryKey(id);
filePath +=banner.getPath();
OperationFileUtil.deleteFile(filePath);
bannerService.deleteByPrimaryKey(id);
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("删除banner失败" + e);
}
return returnResult;
}
/**
* 修改banner的title
* @param banner
* @return
*/
@RequestMapping(value = "updateBanner", method = RequestMethod.POST)
@ResponseBody
public ReturnResult updateBanner(TBanner banner) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
bannerService.updateBySQL("UPDATE t_banner SET title='" + banner.getTitle() + "' WHERE id=" + banner.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("修改banner失败" + e);
}
return returnResult;
}
/**
* 根据id获取banner
* @param banner
* @return
*/
@RequestMapping(value = "getBannerById", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getBannerById(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(bannerService.selectByPrimaryKey(id));
} catch (Exception e) {
logger.error("根据id获取banner失败" + e);
}
return returnResult;
}
@ResponseBody
public ReturnResult updateLevel(TLevel level) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
levelService.updateBySQL("UPDATE t_level SET name='" + level.getName() + "', status="+level.getStatus()+" WHERE id=" + level.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("修改level失败" + e);
}
return returnResult;
}
/**
* 根据id获取level
* @param level
* @return
*/
@RequestMapping(value = "getLevelById", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getLevelById(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(levelService.selectByPrimaryKey(id));
} catch (Exception e) {
logger.error("根据id获取level失败" + e);
}
return returnResult;
}
/**
* 分页获取level
* @return
*/
@RequestMapping(value = "getLevelListByPage", method = RequestMethod.POST)
@ResponseBody
public ReturnResult getLevelListByPage(PageVO page,String Status) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, Object> resultMap = new HashMap<String, Object>();
StringBuffer sql = new StringBuffer("SELECT * FROM t_level WHERE 1=1");
StringBuffer countSql = new StringBuffer("SELECT COUNT(*) AS total FROM t_level WHERE 1=1");
if(StringUtils.isNotBlank(Status)){
sql.append(" AND status="+Status);
countSql.append(" AND status="+Status);
}
List<Map<String, Object>> results = levelService.selectPageBySQL(sql.toString(), page.getPage() - 1,
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);
}
}
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";
}
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) {
@ResponseBody
public ReturnResult getSchedule(HttpSession session) {
returnResult.setStatus(ReturnCodeType.FAILURE);
TUser user = (TUser) session.getAttribute("user");
return returnResult.setStatus(ReturnCodeType.SUCCESS).setData(scheduleService.selectBySQL("SELECT DATE_FORMAT(a.`start`,'%Y-%m-%d') AS start,DATE_FORMAT(a.`end`,'%Y-%m-%d') AS end,b.name,a.`status`,a.id,a.photographerId FROM t_schedule a,t_photographer b WHERE a.photographerId = b.id AND a.userId="+user.getId()));
}
/**
*删除
* @param schedule
* @return
*/
@RequestMapping(value = "deleteSchedule", method = RequestMethod.GET)
@ResponseBody
public ReturnResult deleteSchedule(HttpSession session,Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
session.getAttribute("user");
return returnResult.setStatus(ReturnCodeType.SUCCESS).setData(scheduleService.deleteByPrimaryKey(id));
} catch (Exception e) {
e.printStackTrace();
}
return returnResult;
}
}
/**
attachment.setStatus("0");
attachment.setCreatetime(new Date());
attachmentService.insert(attachment);
}
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("新增works失败" + e);
e.printStackTrace();
}
return returnResult;
}
/**
* 修改works状态
* @param works
* @return
*/
@RequestMapping(value = "updateWorksStatus", method = RequestMethod.GET)
@ResponseBody
public ReturnResult updateWorksStatus(TWorks works) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
worksService.updateBySQL("UPDATE t_works SET status=" + works.getStatus() + " WHERE id=" + works.getId());
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("更新works状态失败" + e);
}
return returnResult;
}
/**
* 修改works封面
* @param works
* @return
*/
@RequestMapping(value = "updateWorksPath", method = RequestMethod.POST)
@ResponseBody
public ReturnResult updateWorksPath(TWorks works,HttpServletRequest request) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, String> map = OperationFileUtil.multiFileUpload(request,
request.getServletContext().getRealPath("/") + "uploads/images/");
String filePath = "";
for (Map.Entry<String, String> entry : map.entrySet()) {
filePath = entry.getValue();
}
filePath = filePath.replace(request.getServletContext().getRealPath("/"), "/").replace("\\", "/");
worksService.updateBySQL("UPDATE t_works SET path='" + filePath + "' WHERE id=" + works.getId());
/**
*
*
*/
@Controller
@Scope("prototype")
public class ScheduleController {
private static final Logger logger = LoggerFactory.getLogger(ScheduleController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "scheduleService")
private IScheduleService scheduleService;
/**
* 添加预约
*
* @param schedule
* @param session
* @return
*/
@RequestMapping(value = "addSchedule", method = RequestMethod.POST)
@ResponseBody
public ReturnResult addSchedule(TSchedule schedule, HttpSession session,String startdate,String enddate) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
schedule.setStart(DateFormater.stringToDate(startdate));
schedule.setEnd(DateFormater.stringToDate(enddate));
schedule.setCreatetime(new Date());
TUser user = (TUser)session.getAttribute("user");
/**
*
*
*/
@Controller
@Scope("prototype")
public class InfoController {
private static final Logger logger = LoggerFactory.getLogger(InfoController.class);
private ReturnResult returnResult = new ReturnResult();
@Resource(name = "infoService")
private IInfoService infoService;
/**
* 添加咨询
*
* @param info
* @param HttpServletRequest
* @return
*/
@RequestMapping(value = "addInfo", method = RequestMethod.POST)
@ResponseBody
public ReturnResult addInfo(TInfomation info, HttpServletRequest request) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
Map<String, String> map = OperationFileUtil.multiFileUpload(request,
request.getServletContext().getRealPath("/") + "uploads/info/");
String filePath = "";
for (Map.Entry<String, String> entry : map.entrySet()) {
filePath = entry.getValue();
}
filePath = filePath.replace(request.getServletContext().getRealPath("/"), "/");
info.setPath(filePath);
info.setCreatetime(new Date());
infoService.insert(info);
returnResult.setStatus(ReturnCodeType.SUCCESS);
} catch (Exception e) {
logger.error("新增info失败" + e);
}
return returnResult;
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(worksService.getWorks(id));
} catch (Exception e) {
logger.error("根据id获取Works失败" + e);
}
return returnResult;
}
/**
* 根据photographerid获取Works
* @param Works
* @return
*/
@RequestMapping(value = "getWorksByPhotographerId", method = RequestMethod.GET)
@ResponseBody
public ReturnResult getWorksByPhotographerId(Integer id) {
returnResult.setStatus(ReturnCodeType.FAILURE);
try {
returnResult.setStatus(ReturnCodeType.SUCCESS).setData(worksService.getWorksByPhotographerId(id));
} catch (Exception e) {
logger.error("根据photographerid获取Works失败" + e);
}
return returnResult;
}
/**
* 分页获取works
* @return
*/
@RequestMapping(value = "getWorksListByPage", method = RequestMethod.POST)
@ResponseBody
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) {