基于javaweb+mysql的springboot婚纱影楼摄影预约网站设计和实现(javaweb+ssm+springboot)

基于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数据库

		}
		return returnResult;
	}
	/**
	 * 根据摄影师id获取schedule
	 * @param schedule
	 * @return
	 */
	@RequestMapping(value = "getScheduleByPhotographerId", method = RequestMethod.GET)
	@ResponseBody
	public ScheduleVO getScheduleByPhotographerId(Integer photoer_id,String year,String month) {
		
		return scheduleService.getScheduleByPhotographerId( photoer_id, year, month);
	}
	
	/**
	 * 分页获取schedule
	 * @return
	 */
	@RequestMapping(value = "getScheduleListByPage", method = RequestMethod.POST)
	@ResponseBody
	public ReturnResult getScheduleListByPage(PageVO page,String photographerId,String start,String end) {
		returnResult.setStatus(ReturnCodeType.FAILURE);
		try {
			Map<String, Object> resultMap = new HashMap<String, Object>();
			StringBuffer sql = new StringBuffer("SELECT a.createTime,a.`status`,a.id,a.`start`,a.`end`,b.`name`,b.tel,c.`name` AS photographer FROM t_schedule a, t_user b ,t_photographer c WHERE a.userId = b.id AND a.photographerId =c.id");
			if(StringUtils.isNotBlank(photographerId)){
				sql.append(" AND a.photographerId="+photographerId);
			}
			if(StringUtils.isNotBlank(start)&&StringUtils.isNotBlank(end)){
				sql.append(" AND a.`start` BETWEEN '"+start+"' AND '"+end+"' OR a.`end` BETWEEN '"+start+"' AND '"+end+"'");
			}
			sql.append(" GROUP BY a.id ORDER BY a.createTime DESC");
			List<Map<String, Object>> results = scheduleService.selectPageBySQL(sql.toString(), page.getPage() - 1,
					page.getRows());
			if (!results.isEmpty() && results != null) {
				int total = scheduleService.selectCount(new TSchedule());
				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("分页获取schedule失败" + e);

/**
 */
@Controller
@Scope("prototype")
public class PhotographerController {

    private static final Logger logger = LoggerFactory.getLogger(PhotographerController.class);
    private ReturnResult returnResult = new ReturnResult();

    @Resource(name = "photographerService")
    private IPhotographerService photographerService;
    @Resource(name = "photographerLabelService")
    IPhotographerLabelService photographerLabelService;
    @Resource(name = "photographerLevelService")
    IPhotographerLevelService photographerLevelService;
    @Resource(name = "photographerSpotsService")
    IPhotographerSpotsService photographerSpotsService;

    /**
     * 添加摄影师
     *
     * @param photographer
     * @param HttpServletRequest
     * @return
     */
    @RequestMapping(value = "addPhotographer", method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult addPhotographer(TPhotographer photographer, HttpServletRequest request, Integer labelId,
                                        Integer levelId, Integer spotsId) {
        returnResult.setStatus(ReturnCodeType.FAILURE);

/**
 * 
 *
 */
@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);
		}
		return returnResult;

	}

	/**
			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);
				}
			}
	/**
	 * 根据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);
			}
		}catch (Exception e) {
			logger.error("分页获取label失败" + e);
		}
		return returnResult;
	}
	/**
	 * 获取所有启用的label
			levelService.insert(level);
			returnResult.setStatus(ReturnCodeType.SUCCESS);
		} catch (Exception e) {
			logger.error("新增level失败" + e);
		}
		return returnResult;

	}

	/**
	 * 修改level状态
	 * @param level
	 * @return
	 */
	@RequestMapping(value = "updatelevelStatus", method = RequestMethod.POST)
	@ResponseBody
	public ReturnResult updatelevelStatus(TLevel level) {
		returnResult.setStatus(ReturnCodeType.FAILURE);
		try {
			levelService.updateBySQL("UPDATE t_level SET status=" + level.getStatus() + " WHERE id=" + level.getId());
			
			returnResult.setStatus(ReturnCodeType.SUCCESS);
		} catch (Exception e) {
			logger.error("更新level状态失败" + e);
		}
		return returnResult;
	}
	
	
	/**
	 * 修改level的name
	 * @param level
	 * @return
	 */
	@RequestMapping(value = "updateLevel", method = RequestMethod.POST)
	@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;
	}
	/**
	 * @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,
					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) {

/**
 * 
 *
 */
@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
	 * @return
	 */
	@RequestMapping(value = "addBanner", method = RequestMethod.POST)
	@ResponseBody
	public ReturnResult addBanner(TBanner banner, HttpServletRequest request) {
		returnResult.setStatus(ReturnCodeType.FAILURE);
		try {

			Map<String, String> map = OperationFileUtil.multiFileUpload(request,
					request.getServletContext().getRealPath("/") + "uploads/banner/");
			String filePath = "";
			for (Map.Entry<String, String> entry : map.entrySet()) {
				filePath = entry.getValue();
			}
			filePath = filePath.replace(request.getServletContext().getRealPath("/"), "/");
			banner.setPath(filePath);
			banner.setCreatetime(new Date());
			bannerService.insert(banner);
			returnResult.setStatus(ReturnCodeType.SUCCESS);
		} catch (Exception e) {
			logger.error("新增banner失败" + e);
		}
		return returnResult;

	}

	/**
	 * @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;
	}
	
	/**
	 * 获取所有的banner
	 * @return
	 */
	@RequestMapping(value = "getAllBanner")
	@ResponseBody
	public ReturnResult getAllBanner(PageVO page) {
		returnResult.setStatus(ReturnCodeType.FAILURE);
		try {
			Map<String, Object> resultMap = new HashMap<String, Object>();
			StringBuffer sql = new StringBuffer("SELECT DISTINCT * FROM t_banner WHERE 1=1");
		
			
			List<Map<String, Object>> results = bannerService.selectPageBySQL(sql.toString(), page.getPage() - 1,
					page.getRows());
			if (!results.isEmpty() && results != null) {
				int total = bannerService.selectCount(new TBanner());
				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("分页获取banner失败" + e);
		}
	}
	
	/**
	 * 修改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;
	}
	
	/**
	 * 获取所有的banner
	 * @return
	 */
	@RequestMapping(value = "getAllBanner")
	@ResponseBody
	public ReturnResult getAllBanner(PageVO page) {
		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)){
				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);
	/**
	 * 修改info的title和content
	 * @param info
	 * @return
	 */
	@RequestMapping(value = "updateInfo", method = RequestMethod.POST)
	@ResponseBody
	public ReturnResult updateInfo(TInfomation info) {
		returnResult.setStatus(ReturnCodeType.FAILURE);
		try {
			infoService.updateBySQL("UPDATE t_infomation SET title='" + info.getTitle() + "', content='"+info.getContent()+"', status="+info.getStatus()+" WHERE id=" + info.getId());
			returnResult.setStatus(ReturnCodeType.SUCCESS);
		} catch (Exception e) {
			logger.error("修改info失败" + e);
		}
		return returnResult;
	}
	
	/**
	 * 分页获取info
	 * @return
	 */
	@RequestMapping(value = "getInfoListByPage", method = RequestMethod.POST)
	@ResponseBody
	public ReturnResult getInfoListByPage(PageVO page) {
		returnResult.setStatus(ReturnCodeType.FAILURE);
		try {
			Map<String, Object> resultMap = new HashMap<String, Object>();
			StringBuffer sql = new StringBuffer("SELECT DISTINCT * FROM t_infomation WHERE 1=1");
		
			
			List<Map<String, Object>> results = infoService.selectPageBySQL(sql.toString(), page.getPage() - 1,
					page.getRows());
			if (!results.isEmpty() && results != null) {
				int total = infoService.selectCount(new TInfomation());
				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);
        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)) {
                List<String> list = photographerService.selectByStartEnd(start, end);
                for (String id : list) {
                    sql.append(" AND a.id!=" + id);
                    countSql.append(" AND a.id!=" + id);
                }
            }
            if (StringUtils.isNotBlank(labelId)) {
                sql.append(" AND b.labelId=" + labelId);
                sql.append(" AND f.id=" + labelId);
                countSql.append(" AND b.labelId=" + labelId);
                countSql.append(" AND f.id=" + labelId);
            }
            if (StringUtils.isNotBlank(levelId)) {
                sql.append(" AND c.levelId=" + levelId);
                sql.append(" AND g.id=" + levelId);
                countSql.append(" AND c.levelId=" + levelId);
                countSql.append(" AND g.id=" + levelId);
            }
            if (StringUtils.isNotBlank(spotsId)) {
                sql.append(" AND d.spotsId=" + spotsId);
		}
		filePath = filePath.replace(request.getServletContext().getRealPath("/"), "/");
		filePath = filePath.replaceAll("\\\\", "/");
		Map<String, Object> result = new HashMap<String,Object>();
		result.put("data", filePath);
		result.put("status", 0);
		return result;
	}

}

/**
 * 
 *
 */
@Controller
@Scope("prototype")
public class SpotsController {

	private static final Logger logger = LoggerFactory.getLogger(SpotsController.class);
	private ReturnResult returnResult = new ReturnResult();

	@Resource(name = "spotsService")
 * @Description 操作文件工具类
 * @Version v1.0
 */
public final class OperationFileUtil {
    private static final String ENCODING = "utf-8";

    /**
     * 文件下载
     * 
     * @param filePath
     *            文件路径
     * @return
     * @throws UnsupportedEncodingException
     * @throws IOException
     */
    public static ResponseEntity<byte[]> download(String filePath) throws UnsupportedEncodingException, IOException {
        String fileName = FilenameUtils.getName(filePath);
        return downloadAssist(filePath, fileName);
    }

    /**
     * 文件下载
     * 
     * @param filePath
     *            文件路径
     * @param fileName
     *            文件名
     * @return
     * @throws UnsupportedEncodingException
     * @throws IOException
     */
    public static ResponseEntity<byte[]> download(String filePath, String fileName) throws UnsupportedEncodingException, IOException {
        return downloadAssist(filePath, fileName);
    }

    /**
     * 文件下载辅助
     * 
     * @param filePath
     *            文件路径
     * @param fileName
     *            文件名
     * @return
     * @throws UnsupportedEncodingException
	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";
			}
			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 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) {
				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);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值