package cc.gzvtc.photographer.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cc.gzvtc.common.util.OperationFileUtil;
import cc.gzvtc.model.TPhotographer;
import cc.gzvtc.model.TPhotographerLabel;
import cc.gzvtc.model.TPhotographerLevel;
import cc.gzvtc.model.TPhotographerSpots;
import cc.gzvtc.photographer.service.IPhotographerLabelService;
import cc.gzvtc.photographer.service.IPhotographerLevelService;
import cc.gzvtc.photographer.service.IPhotographerService;
import cc.gzvtc.photographer.service.IPhotographerSpotsService;
import cc.gzvtc.vo.PageVO;
import cc.gzvtc.vo.ReturnCodeType;
import cc.gzvtc.vo.ReturnResult;
/**
*
* @author hzc 2017年2月12日
*
*/
@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);
try {
Map<String, String> map = OperationFileUtil.multiFileUpload(request,
request.getServletContext().getRealPath("/") + "uploads/photographer/");
String filePath = "";
for (Map.Entry<String, String> entry : map.entrySet()) {
filePath = entry.getValue();
}
filePath = filePath.replace(request.getServletContext().getRealPath("/"), "/");
photographer.setHead(filePath);
photographer.setCreatetime(new Date());
photographerService.insert(photographer);
int id = photographer.getId();
TPhotographerLabel label = new TPhotographerLabel(labelId, id, new Date(), "0");
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 {
photographerService.updateBySQL("UPDATE t_photographer SET name='" + photographer.getName() + "',summary='"
+ photographer.getSummary() + "',status=" + photographer.getStatus() + " WHERE id="
+ photographer.getId());
photographerLabelService.updateBySQL("UPDATE t_photographer_label SET labelId=" + labelId
+ " WHERE photographerId=" + photographer.getId());
photographerLevelService.updateBySQL("UPDATE t_photographer_level SET levelId=" + levelId
+ " 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 {
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);
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);
沐知全栈开发
- 粉丝: 5818
- 资源: 5227
最新资源
- VCU整车控制器主控芯片MPC5744,原理图+源代码
- 基于非线性干扰观测器的直升机滑模反演控制,期刊simulink模型复现
- 51单片机串口通信程序源码,注释详细,包含接收和传输代码,以及文档说明
- FX3U和三菱伺服控制的框架标准程序,适合新手学习定位用 用 标签分层,说明了定位控制中的公共参数设定、回原点、JOG手动、绝对定位、相对定位、控制等部分,有伺服驱动器的针脚接线 ‘包括有: 1、
- 电动汽车有序充电参与电网负荷削峰填谷
- 热电联产系统智能经济调度:一种深度强化学习方法 关键词:热电联产,经济调度,深度强化学习,近端优化 一种热电组合(CHP)系统经济调度的深度强化学习(DRL)方法,该方法具有对不同操作场景的适应性,显
- 魔术轮胎,dugoff轮胎建模 软件使用:Matlab Simulink 适用场景:采用模块化建模方法,搭建非线性魔术轮胎PAC2002,dugoff模型 非线性轮胎模型输入: 轮胎侧偏角,轮胎滑
- 啊阿斯顿撒法公分的身高是是
- 基于时域信号 逆变器 阻抗模型 特征值识别 稳定性分析 关键词 系统识别、导纳模型、阻抗模型、基于逆变器的资源、稳定性分析 测试环境:MATLAB 由于越来越多的基于逆变器的资源(IBR)的集成,电
- 有源电力滤波器matlab仿真, 并联型apf仿真fft分析 谐波电流检测ipiq法 跟踪电流控制(传统滞环控制 空间电压矢量滞环控制) 总谐波畸变率降至3%以下
- 编程领域中正则表达式的全面介绍与典型应用场景解析
- 使用STM32DSP库制作的数字滤波器, 滤波器系数通过MATLAB生成 配合STM32串口输出,在Excel中绘图,上面只是演示了低通滤波器 源码,包括滤波器系数生成教程
- 基于VHDL的数字密码锁设计,使用FPGA作为控制器,包括相应的功能仿真和相关设计资料
- 深入解析 Vue3 框架:新特性、改进与应用案例的技术指南
- 胶钉机程序 用国产三菱3U和威纶触摸屏编写 此程序已经实际设备上批量应用,程序成熟可靠,借鉴价值高,程序有注释
- 在IEEE-14总线系统中执行连续功率流 测试环境:MATLAB 读取IEEE14和 IEEE30系统数据 连续潮流又称为延拓潮流,是电力系统电压稳定性分析的有力工具 PV曲线由于反映了系统随着负
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈