package com.ketayao.security.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.PropertyFilter;
import org.apache.log4j.Logger;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ketayao.security.MyLoggerFactory;
import com.ketayao.security.SecurityConstants;
import com.ketayao.security.entity.main.AdvertiseInfo;
import com.ketayao.security.entity.main.AdvertiseType;
import com.ketayao.security.entity.main.DoorOpennum;
import com.ketayao.security.entity.main.TenOpennum;
import com.ketayao.security.entity.main.TenementInfo;
import com.ketayao.security.entity.main.User;
import com.ketayao.security.exception.ExistedException;
import com.ketayao.security.service.AdvertiseService;
import com.ketayao.security.service.CommonlyUsedAreaService;
import com.ketayao.util.dwz.AjaxObject;
import com.ketayao.util.dwz.Page;
/**
* @author xinzi
* @date 2013-06-04
*/
@Controller
@RequestMapping("management/security/advertise")
public class AdvertiseController {
private static Logger logger = MyLoggerFactory.getLogger(AdvertiseController.class);
@Autowired
AdvertiseService advertiseService;
@Autowired
CommonlyUsedAreaService commonlyUsedAreaService;
@PersistenceContext
private EntityManager em;
private static final String CREATE = "management/advertise/create";
private static final String UPDATE = "management/advertise/update";
private static final String AUDIT = "management/advertise/audit";
private static final String LIST = "management/advertise/list";
private static final String AUDITLIST = "management/advertise/auditlist";
/**
* 查看广告投放申请列表
* @param page
* @param map
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:view")
@RequestMapping(value="/list", method={RequestMethod.GET, RequestMethod.POST})
public String list(Page page, Map<String, Object> map,HttpServletRequest request) {
Map<String, Object> reqMap = new HashMap<String, Object>();
String advState = request.getParameter("advState");
String advType = request.getParameter("advType");
String advTitle = request.getParameter("advTitle");
String efectiveTimeSta = request.getParameter("efectiveTimeSta");
String efectiveTimeEnd = request.getParameter("efectiveTimeEnd");
reqMap.put("advState", advState);
reqMap.put("advType", advType);
reqMap.put("advTitle", advTitle);
reqMap.put("efectiveTimeSta", efectiveTimeSta);
reqMap.put("efectiveTimeEnd", efectiveTimeEnd);
List<AdvertiseInfo> advertiseInfoList = advertiseService.find(page, reqMap);
map.put("page", page);
map.put("advertiseInfoList", advertiseInfoList);
map.put("advState", advState);
map.put("advType", advType);
map.put("advTitle", advTitle);
map.put("efectiveTimeSta", efectiveTimeSta);
map.put("efectiveTimeEnd", efectiveTimeEnd);
return LIST;
}
/**
* 进入添加广告信息页面
*/
@RequiresPermissions("AdvertiseManage:save")
@RequestMapping(value="/create", method=RequestMethod.GET)
public String preCreate(Map<String, Object> map) {
List<AdvertiseType> typeList = advertiseService.getTypeList();
map.put("typeList",typeList);
return CREATE;
}
/**
* 保存页面填写的广告信息
* 有三种广告类型 1、文字 2、图片 JPEG、PNG、GIF、BMP3、视频AVI、MP4、WMV、MPG
*/
@RequiresPermissions("AdvertiseManage:save")
@RequestMapping(value="/create", method=RequestMethod.POST)
public @ResponseBody String create(HttpServletRequest request,Map<String, Object> map) {
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
Map<String,String> paramMap = new HashMap<String, String>();
String advTitle = request.getParameter("advTitle");
String advType = request.getParameter("advType");
String advFileType = request.getParameter("advFileType");
String advContent = request.getParameter("advContent");
String gradeIds = request.getParameter("gradeIds");
String gradeNames = request.getParameter("gradeNames");
String useDev = request.getParameter("useDev");
String efectiveTimeSta = request.getParameter("efectiveTimeSta");
String efectiveTimeEnd = request.getParameter("efectiveTimeEnd");
paramMap.put("advTitle", advTitle);
paramMap.put("advType", advType);
paramMap.put("advFileType", advFileType);
paramMap.put("advContent", advContent);
paramMap.put("gradeIds", gradeIds);
paramMap.put("gradeNames", gradeNames);
paramMap.put("useDev", useDev);
paramMap.put("efectiveTimeSta", efectiveTimeSta);
paramMap.put("efectiveTimeEnd", efectiveTimeEnd);
paramMap.put("author", optUser.getUsername());
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,Object> rltMap = advertiseService.saveAdvertiseInfo(paramMap,request);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setNavTabId("moduleListNav_107");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告信息删除
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:delete")
@RequestMapping(value="/deleteBatch", method=RequestMethod.POST)
public @ResponseBody String deleteBatch(HttpServletRequest request,Map<String, Object> map) {
AjaxObject ajaxObject = new AjaxObject();
String ids = request.getParameter("ids");
try {
Map<String,Object> rltMap = advertiseService.deleteBatch(ids);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setCallbackType("");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
logger.error("系统出错:",e.getCause());
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告信息删除
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:delete")
@RequestMapping(value="/delete/{id}", method=RequestMethod.POST)
public @ResponseBody String delete(@PathVariable Long id,HttpServletRequest request) {
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,Object> rltMap = advertiseService.deleteEntity(id);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
logger.error("系统出错:",e.getCause());
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 修改图片广告信息
* 有三种广告类型 1、文字 2、图片 3、视频
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/update/{id}", method=RequestMethod.GET)
public String preUpdate(@PathVariable Long id, Map<String, Object> map) {
List<AdvertiseType> typeList = advertiseService.getTypeList();
map.put("typeList",typeList);
Map<String, Object> backMap = advertiseService.getEntity(id);
map.put("advertiseMap", backMap);
AdvertiseInfo advertiseInfo = (AdvertiseInfo) backMap.get("advertiseInfo");
int length = 1;
if(advertiseInfo!=null){
length= advertiseInfo.getRelativeFiles().size()+1;
}
map.put("length",length);
return UPDATE;
}
/**
* 修改广告信息
* @param request
* @return json.toString()
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/update", method=RequestMethod.POST)
public @ResponseBody String update(HttpServletRequest request) {
AjaxObject ajaxObject = new AjaxObject();
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
Map<String,String> paramsMap = new HashMap<String,String>();
String id = request.getParameter("id");
paramsMap.put("id", id);
paramsMap.put("author", optUser.getUsername());
try {
Map<String,Object> rltMap = advertiseService.updateEntity(paramsMap,request);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setNavTabId("moduleListNav_107");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告审核和分发列表
* @param page
* @param map
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:view")
@RequestMapping(value="/auditlist", method={RequestMethod.GET, RequestMethod.POST})
public String auditlist(Page page, Map<String, Object> map,HttpServletRequest request) {
Map<String, Object> reqMap = new HashMap<String, Object>();
String advState = request.getParameter("advState");
String advType = request.getParameter("advType");
String advTitle = request.getParameter("advTitle");
String efectiveTimeSta = request.getParameter("efectiveTimeSta");
String efectiveTimeEnd = request.getParameter("efectiveTimeEnd");
reqMap.put("advState", advState);
reqMap.put("advType", advType);
reqMap.put("advTitle", advTitle);
reqMap.put("efectiveTimeSta", efectiveTimeSta);
reqMap.put("efectiveTimeEnd", efectiveTimeEnd);
List<AdvertiseInfo> advertiseInfoList = advertiseService.find(page, reqMap);
map.put("page", page);
map.put("advertiseInfoList", advertiseInfoList);
map.put("advState", advState);
map.put("advType", advType);
map.put("advTitle", advTitle);
map.put("efectiveTimeSta", efectiveTimeSta);
map.put("efectiveTimeEnd", efectiveTimeEnd);
return AUDITLIST;
}
/**
* 修改图片广告信息
* 有三种广告类型 1、文字 2、图片 3、视频
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/audit/{id}", method=RequestMethod.GET)
public String preAudit(@PathVariable Long id, Map<String, Object> map) {
List<AdvertiseType> typeList = advertiseService.getTypeList();
map.put("typeList",typeList);
map.put("advertiseMap", advertiseService.getEntity(id));
return AUDIT;
}
/**
* 审核广告信息
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/audit", method=RequestMethod.POST)
public @ResponseBody String Audit(HttpServletRequest request) {
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,String> paramsMap = new HashMap<String,String>();
String id = request.getParameter("id");
String advState = request.getParameter("advState");
String adminNote = request.getParameter("adminNote");
paramsMap.put("id", id);
paramsMap.put("advState", advState);
paramsMap.put("adminNote", adminNote);
paramsMap.put("auditor", optUser.getUsername());
Map<String,Object> rltMap = advertiseService.auditEntity(paramsMap);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setCallbackType("");
ajaxObject.setNavTabId("moduleListNav_108");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 审核广告信息
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/batchAudit", method=RequestMethod.POST)
public @ResponseBody String batchAudit(HttpServletRequest request) {
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,String> paramsMap = new HashMap<String,String>();
String ids = request.getParameter("ids");
String advState = request.getParameter("advState");
String adminNote = request.getParameter("adminNote");
paramsMap.put("ids", ids);
paramsMap.put("advState", advState);
paramsMap.put("adminNote", adminNote);
paramsMap.put("auditor", optUser.getUsername());
Map<String,Object> rltMap = advertiseService.batchAudit(paramsMap);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setCallbackType("");
ajaxObject.setNavTabId("moduleListNav_108");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告信息删除
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:delete")
@RequestMapping(value="/delImg", method=RequestMethod.POST)
public @ResponseBody String delImg(HttpServletRequest request) {
String id = request.getParameter("id");
Map<String,Object> rltMap = advertiseService.deleteFileinfo(id);
return JSONObject.fromObject(rltMap).toString();
}
/**
* 获取广告信息附件
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:view")
@RequestMapping(value="/getFiles", method=RequestMethod.POST)
public @ResponseBody String getFiles(HttpServletRequest request) {
String advId = request.getParameter("advId");
String advFileType = request.getParameter("advFileType");
Map<String,String> paramsMap = new HashMap<String,String>();
paramsMap.put("advId", advId);
paramsMap.put("advFileType",advFileType);
Map<String,Object> rltMap = advertiseService.getFiles(paramsMap);
JsonConfig config = new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
if (arg1.equals("advertiseInfo")) {
return true;
} else {
return false;
}
}
});
// 将数据转换成Json数据
JSONObject jsonObject = JSONObject.fromObject(rltMap, config);
return jsonObject.toString();
}
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.PropertyFilter;
import org.apache.log4j.Logger;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ketayao.security.MyLoggerFactory;
import com.ketayao.security.SecurityConstants;
import com.ketayao.security.entity.main.AdvertiseInfo;
import com.ketayao.security.entity.main.AdvertiseType;
import com.ketayao.security.entity.main.DoorOpennum;
import com.ketayao.security.entity.main.TenOpennum;
import com.ketayao.security.entity.main.TenementInfo;
import com.ketayao.security.entity.main.User;
import com.ketayao.security.exception.ExistedException;
import com.ketayao.security.service.AdvertiseService;
import com.ketayao.security.service.CommonlyUsedAreaService;
import com.ketayao.util.dwz.AjaxObject;
import com.ketayao.util.dwz.Page;
/**
* @author xinzi
* @date 2013-06-04
*/
@Controller
@RequestMapping("management/security/advertise")
public class AdvertiseController {
private static Logger logger = MyLoggerFactory.getLogger(AdvertiseController.class);
@Autowired
AdvertiseService advertiseService;
@Autowired
CommonlyUsedAreaService commonlyUsedAreaService;
@PersistenceContext
private EntityManager em;
private static final String CREATE = "management/advertise/create";
private static final String UPDATE = "management/advertise/update";
private static final String AUDIT = "management/advertise/audit";
private static final String LIST = "management/advertise/list";
private static final String AUDITLIST = "management/advertise/auditlist";
/**
* 查看广告投放申请列表
* @param page
* @param map
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:view")
@RequestMapping(value="/list", method={RequestMethod.GET, RequestMethod.POST})
public String list(Page page, Map<String, Object> map,HttpServletRequest request) {
Map<String, Object> reqMap = new HashMap<String, Object>();
String advState = request.getParameter("advState");
String advType = request.getParameter("advType");
String advTitle = request.getParameter("advTitle");
String efectiveTimeSta = request.getParameter("efectiveTimeSta");
String efectiveTimeEnd = request.getParameter("efectiveTimeEnd");
reqMap.put("advState", advState);
reqMap.put("advType", advType);
reqMap.put("advTitle", advTitle);
reqMap.put("efectiveTimeSta", efectiveTimeSta);
reqMap.put("efectiveTimeEnd", efectiveTimeEnd);
List<AdvertiseInfo> advertiseInfoList = advertiseService.find(page, reqMap);
map.put("page", page);
map.put("advertiseInfoList", advertiseInfoList);
map.put("advState", advState);
map.put("advType", advType);
map.put("advTitle", advTitle);
map.put("efectiveTimeSta", efectiveTimeSta);
map.put("efectiveTimeEnd", efectiveTimeEnd);
return LIST;
}
/**
* 进入添加广告信息页面
*/
@RequiresPermissions("AdvertiseManage:save")
@RequestMapping(value="/create", method=RequestMethod.GET)
public String preCreate(Map<String, Object> map) {
List<AdvertiseType> typeList = advertiseService.getTypeList();
map.put("typeList",typeList);
return CREATE;
}
/**
* 保存页面填写的广告信息
* 有三种广告类型 1、文字 2、图片 JPEG、PNG、GIF、BMP3、视频AVI、MP4、WMV、MPG
*/
@RequiresPermissions("AdvertiseManage:save")
@RequestMapping(value="/create", method=RequestMethod.POST)
public @ResponseBody String create(HttpServletRequest request,Map<String, Object> map) {
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
Map<String,String> paramMap = new HashMap<String, String>();
String advTitle = request.getParameter("advTitle");
String advType = request.getParameter("advType");
String advFileType = request.getParameter("advFileType");
String advContent = request.getParameter("advContent");
String gradeIds = request.getParameter("gradeIds");
String gradeNames = request.getParameter("gradeNames");
String useDev = request.getParameter("useDev");
String efectiveTimeSta = request.getParameter("efectiveTimeSta");
String efectiveTimeEnd = request.getParameter("efectiveTimeEnd");
paramMap.put("advTitle", advTitle);
paramMap.put("advType", advType);
paramMap.put("advFileType", advFileType);
paramMap.put("advContent", advContent);
paramMap.put("gradeIds", gradeIds);
paramMap.put("gradeNames", gradeNames);
paramMap.put("useDev", useDev);
paramMap.put("efectiveTimeSta", efectiveTimeSta);
paramMap.put("efectiveTimeEnd", efectiveTimeEnd);
paramMap.put("author", optUser.getUsername());
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,Object> rltMap = advertiseService.saveAdvertiseInfo(paramMap,request);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setNavTabId("moduleListNav_107");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告信息删除
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:delete")
@RequestMapping(value="/deleteBatch", method=RequestMethod.POST)
public @ResponseBody String deleteBatch(HttpServletRequest request,Map<String, Object> map) {
AjaxObject ajaxObject = new AjaxObject();
String ids = request.getParameter("ids");
try {
Map<String,Object> rltMap = advertiseService.deleteBatch(ids);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setCallbackType("");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
logger.error("系统出错:",e.getCause());
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告信息删除
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:delete")
@RequestMapping(value="/delete/{id}", method=RequestMethod.POST)
public @ResponseBody String delete(@PathVariable Long id,HttpServletRequest request) {
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,Object> rltMap = advertiseService.deleteEntity(id);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
logger.error("系统出错:",e.getCause());
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 修改图片广告信息
* 有三种广告类型 1、文字 2、图片 3、视频
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/update/{id}", method=RequestMethod.GET)
public String preUpdate(@PathVariable Long id, Map<String, Object> map) {
List<AdvertiseType> typeList = advertiseService.getTypeList();
map.put("typeList",typeList);
Map<String, Object> backMap = advertiseService.getEntity(id);
map.put("advertiseMap", backMap);
AdvertiseInfo advertiseInfo = (AdvertiseInfo) backMap.get("advertiseInfo");
int length = 1;
if(advertiseInfo!=null){
length= advertiseInfo.getRelativeFiles().size()+1;
}
map.put("length",length);
return UPDATE;
}
/**
* 修改广告信息
* @param request
* @return json.toString()
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/update", method=RequestMethod.POST)
public @ResponseBody String update(HttpServletRequest request) {
AjaxObject ajaxObject = new AjaxObject();
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
Map<String,String> paramsMap = new HashMap<String,String>();
String id = request.getParameter("id");
paramsMap.put("id", id);
paramsMap.put("author", optUser.getUsername());
try {
Map<String,Object> rltMap = advertiseService.updateEntity(paramsMap,request);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setNavTabId("moduleListNav_107");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告审核和分发列表
* @param page
* @param map
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:view")
@RequestMapping(value="/auditlist", method={RequestMethod.GET, RequestMethod.POST})
public String auditlist(Page page, Map<String, Object> map,HttpServletRequest request) {
Map<String, Object> reqMap = new HashMap<String, Object>();
String advState = request.getParameter("advState");
String advType = request.getParameter("advType");
String advTitle = request.getParameter("advTitle");
String efectiveTimeSta = request.getParameter("efectiveTimeSta");
String efectiveTimeEnd = request.getParameter("efectiveTimeEnd");
reqMap.put("advState", advState);
reqMap.put("advType", advType);
reqMap.put("advTitle", advTitle);
reqMap.put("efectiveTimeSta", efectiveTimeSta);
reqMap.put("efectiveTimeEnd", efectiveTimeEnd);
List<AdvertiseInfo> advertiseInfoList = advertiseService.find(page, reqMap);
map.put("page", page);
map.put("advertiseInfoList", advertiseInfoList);
map.put("advState", advState);
map.put("advType", advType);
map.put("advTitle", advTitle);
map.put("efectiveTimeSta", efectiveTimeSta);
map.put("efectiveTimeEnd", efectiveTimeEnd);
return AUDITLIST;
}
/**
* 修改图片广告信息
* 有三种广告类型 1、文字 2、图片 3、视频
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/audit/{id}", method=RequestMethod.GET)
public String preAudit(@PathVariable Long id, Map<String, Object> map) {
List<AdvertiseType> typeList = advertiseService.getTypeList();
map.put("typeList",typeList);
map.put("advertiseMap", advertiseService.getEntity(id));
return AUDIT;
}
/**
* 审核广告信息
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/audit", method=RequestMethod.POST)
public @ResponseBody String Audit(HttpServletRequest request) {
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,String> paramsMap = new HashMap<String,String>();
String id = request.getParameter("id");
String advState = request.getParameter("advState");
String adminNote = request.getParameter("adminNote");
paramsMap.put("id", id);
paramsMap.put("advState", advState);
paramsMap.put("adminNote", adminNote);
paramsMap.put("auditor", optUser.getUsername());
Map<String,Object> rltMap = advertiseService.auditEntity(paramsMap);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setCallbackType("");
ajaxObject.setNavTabId("moduleListNav_108");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 审核广告信息
*/
@RequiresPermissions("AdvertiseManage:edit")
@RequestMapping(value="/batchAudit", method=RequestMethod.POST)
public @ResponseBody String batchAudit(HttpServletRequest request) {
User optUser = (User) request.getSession().getAttribute(SecurityConstants.LOGIN_USER);
AjaxObject ajaxObject = new AjaxObject();
try {
Map<String,String> paramsMap = new HashMap<String,String>();
String ids = request.getParameter("ids");
String advState = request.getParameter("advState");
String adminNote = request.getParameter("adminNote");
paramsMap.put("ids", ids);
paramsMap.put("advState", advState);
paramsMap.put("adminNote", adminNote);
paramsMap.put("auditor", optUser.getUsername());
Map<String,Object> rltMap = advertiseService.batchAudit(paramsMap);
if(Boolean.valueOf(String.valueOf(rltMap.get("rlt")))){
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_SUCCESS);
ajaxObject.setCallbackType("");
ajaxObject.setNavTabId("moduleListNav_108");
}else{
ajaxObject.setMessage(String.valueOf(rltMap.get("msg")));
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
}
} catch (Exception e) {
e.printStackTrace();
ajaxObject = new AjaxObject(e.getMessage());
ajaxObject.setCallbackType("");
ajaxObject.setStatusCode(AjaxObject.STATUS_CODE_FAILURE);
return ajaxObject.toString();
}
return ajaxObject.toString();
}
/**
* 广告信息删除
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:delete")
@RequestMapping(value="/delImg", method=RequestMethod.POST)
public @ResponseBody String delImg(HttpServletRequest request) {
String id = request.getParameter("id");
Map<String,Object> rltMap = advertiseService.deleteFileinfo(id);
return JSONObject.fromObject(rltMap).toString();
}
/**
* 获取广告信息附件
* @param id
* @param request
* @return ajaxObject.toString()
*/
@RequiresPermissions("AdvertiseManage:view")
@RequestMapping(value="/getFiles", method=RequestMethod.POST)
public @ResponseBody String getFiles(HttpServletRequest request) {
String advId = request.getParameter("advId");
String advFileType = request.getParameter("advFileType");
Map<String,String> paramsMap = new HashMap<String,String>();
paramsMap.put("advId", advId);
paramsMap.put("advFileType",advFileType);
Map<String,Object> rltMap = advertiseService.getFiles(paramsMap);
JsonConfig config = new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
if (arg1.equals("advertiseInfo")) {
return true;
} else {
return false;
}
}
});
// 将数据转换成Json数据
JSONObject jsonObject = JSONObject.fromObject(rltMap, config);
return jsonObject.toString();
}
}