|
@@ -41,121 +41,115 @@ public class ActivityNewsController {
|
|
|
|
|
|
/**
|
|
|
* 活动资讯列表
|
|
|
- * @param typeId 类别id
|
|
|
- * @param tagId 标签
|
|
|
- * @param title 名称
|
|
|
- * @param pageNum 页码
|
|
|
+ *
|
|
|
+ * @param typeId 类别id
|
|
|
+ * @param tagId 标签
|
|
|
+ * @param title 名称
|
|
|
+ * @param pageNum 页码
|
|
|
* @param pageSize 条数
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("activityNewsList.html")
|
|
|
public ModelAndView activityNewsList(
|
|
|
- @RequestParam(defaultValue = "")Integer typeId,
|
|
|
- @RequestParam(defaultValue = "")Integer tagId,
|
|
|
- @RequestParam(defaultValue = "")String title,
|
|
|
- @RequestParam(defaultValue = "1")Integer pageNum,
|
|
|
- @RequestParam(defaultValue = "10")Integer pageSize){
|
|
|
+ @RequestParam(defaultValue = "") Integer typeId,
|
|
|
+ @RequestParam(defaultValue = "") Integer tagId,
|
|
|
+ @RequestParam(defaultValue = "") String title,
|
|
|
+ @RequestParam(defaultValue = "1") Integer pageNum,
|
|
|
+ @RequestParam(defaultValue = "10") Integer pageSize) {
|
|
|
|
|
|
- ModelAndView mav = new ModelAndView();
|
|
|
+ ModelAndView mav = new ModelAndView();
|
|
|
|
|
|
- List<ActivityNews> listActivityNewsInfo = iActivityNewsService.listActivityNewsInfo(typeId,tagId,title,pageNum,pageSize);//查询资讯信息
|
|
|
+ List<ActivityNews> listActivityNewsInfo = iActivityNewsService.listActivityNewsInfo(typeId, tagId, title, pageNum, pageSize);//查询资讯信息
|
|
|
|
|
|
List<ActivityType> listActivityTypeInfo = iActivityTypeService.listActivityTypeInfo();//查询类别信息
|
|
|
|
|
|
- List<ActivityTag> listActivityTagInfo = iActivityTagService.listActivityTagInfo();//查询标签信息
|
|
|
-
|
|
|
- long startTime = System.nanoTime();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for (ActivityType activityType : listActivityTypeInfo){
|
|
|
+ List<ActivityTag> listActivityTagInfo = iActivityTagService.listActivityTagInfo();//查询标签信息
|
|
|
|
|
|
- for (ActivityNews activityNews : listActivityNewsInfo){
|
|
|
|
|
|
- ActivityType activityType1 = iActivityTypeService.selectByKey(activityNews.getTypeid());//根据activityNews.getTypeid()查询ActivityType信息
|
|
|
- /*非空判断*/
|
|
|
- if (activityType1 != null){
|
|
|
- activityNews.setTypeName(activityType1.getTypename());//设置类型名
|
|
|
+ for (ActivityNews activityNews : listActivityNewsInfo) {
|
|
|
+ for (ActivityType activityType : listActivityTypeInfo) {
|
|
|
+ if(activityNews.getTypeid()==activityType.getId()){
|
|
|
+ activityNews.setTypeName(activityType.getTypename());//设置类型名
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
- for (ActivityTag activityTag : listActivityTagInfo){
|
|
|
-
|
|
|
- ActivityTag activityTag1 = iActivityTagService.selectByKey(activityNews.getTagid());//同上
|
|
|
- if (activityTag1 != null){
|
|
|
- activityNews.setTagName(activityTag1.getTagname());//设置标签名
|
|
|
- }
|
|
|
+ }
|
|
|
+ for (ActivityTag activityTag : listActivityTagInfo) {
|
|
|
+ if(activityNews.getTagid() == activityTag.getId()){
|
|
|
+ activityNews.setTagName(activityTag.getTagname());//设置标签名
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- long endTime = System.nanoTime();
|
|
|
- long time = endTime-startTime;
|
|
|
- System.out.print(time+"=======");
|
|
|
- mav.addObject("pageInfo",new PageInfo<ActivityNews>(listActivityNewsInfo));
|
|
|
- mav.addObject("typeInfo",listActivityTypeInfo);
|
|
|
- mav.addObject("tagInfo",listActivityTagInfo);
|
|
|
- mav.addObject("typeId",typeId);
|
|
|
- mav.addObject("tagId",tagId);
|
|
|
- mav.addObject("title",title);
|
|
|
- mav.addObject("pageNum",pageNum);
|
|
|
- mav.addObject("pageSize",pageSize);
|
|
|
+
|
|
|
+ mav.addObject("pageInfo", new PageInfo<ActivityNews>(listActivityNewsInfo));
|
|
|
+ mav.addObject("typeInfo", listActivityTypeInfo);
|
|
|
+ mav.addObject("tagInfo", listActivityTagInfo);
|
|
|
+ mav.addObject("typeId", typeId);
|
|
|
+ mav.addObject("tagId", tagId);
|
|
|
+ mav.addObject("title", title);
|
|
|
+ mav.addObject("pageNum", pageNum);
|
|
|
+ mav.addObject("pageSize", pageSize);
|
|
|
return mav;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加 跳转
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("activityNewsAdd.html")
|
|
|
- public ModelAndView activityNewsAdd(){
|
|
|
+ public ModelAndView activityNewsAdd() {
|
|
|
|
|
|
ModelAndView mav = new ModelAndView();
|
|
|
|
|
|
List<ActivityType> listActivityTypeInfo = iActivityTypeService.listActivityTypeInfo();//查询类型
|
|
|
|
|
|
- List<ActivityTag> listActivityTagInfo = iActivityTagService.listActivityTagInfo();//查询标签
|
|
|
+ List<ActivityTag> listActivityTagInfo = iActivityTagService.listActivityTagInfo();//查询标签
|
|
|
|
|
|
- mav.addObject("typeInfo",listActivityTypeInfo);
|
|
|
+ mav.addObject("typeInfo", listActivityTypeInfo);
|
|
|
|
|
|
- mav.addObject("tagInfo",listActivityTagInfo);
|
|
|
+ mav.addObject("tagInfo", listActivityTagInfo);
|
|
|
|
|
|
return mav;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加 实现
|
|
|
+ *
|
|
|
* @param activityNews
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("activityNewsAdds.html")
|
|
|
- public ModelAndView toAdds(ActivityNews activityNews, HttpServletRequest request){
|
|
|
+ public ModelAndView toAdds(ActivityNews activityNews, HttpServletRequest request) {
|
|
|
|
|
|
/* String rootPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
String contextPath = request.getSession().getServletContext().getContextPath();
|
|
|
BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "admin")
|
|
|
.invoke(ActionMap.UPLOAD_FILE);*/
|
|
|
- // activityNews.setActivityimage(state.getInfo("url"));
|
|
|
+ // activityNews.setActivityimage(state.getInfo("url"));
|
|
|
|
|
|
activityNews.setBrowsingvolume(0);
|
|
|
activityNews.setReleasetime(new Date());
|
|
|
|
|
|
String[] imgStr = activityNews.getActivityimage().split(",");
|
|
|
|
|
|
- if (imgStr.length >3){ //最多上传三张图片,判断一下
|
|
|
- return ViewUtil.returnview(0,"activityNewsList.html","活动资讯列表");
|
|
|
+ if (imgStr.length > 3) { //最多上传三张图片,判断一下
|
|
|
+ return ViewUtil.returnview(0, "activityNewsList.html", "活动资讯列表");
|
|
|
}
|
|
|
int row = iActivityNewsService.save(activityNews);
|
|
|
- return ViewUtil.returnview(row,"activityNewsList.html","活动资讯列表");
|
|
|
+ return ViewUtil.returnview(row, "activityNewsList.html", "活动资讯列表");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改 跳转
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("activityNewsUpdate.html")
|
|
|
- public ModelAndView activityNewsUpdate(Integer id){
|
|
|
+ public ModelAndView activityNewsUpdate(Integer id) {
|
|
|
|
|
|
ModelAndView mav = new ModelAndView();
|
|
|
|
|
@@ -165,78 +159,81 @@ public class ActivityNewsController {
|
|
|
|
|
|
String[] imgStr = activityNews.getActivityimage().split(",");//将查出的图片字符串路径,存到数组中
|
|
|
|
|
|
- for (String str : imgStr){ //将以","隔开的图片存放到list中,传给前台
|
|
|
+ for (String str : imgStr) { //将以","隔开的图片存放到list中,传给前台
|
|
|
list.add(str);
|
|
|
}
|
|
|
|
|
|
List<ActivityType> listActivityTypeInfo = iActivityTypeService.listActivityTypeInfo();//查询类型
|
|
|
|
|
|
- List<ActivityTag> listActivityTagInfo = iActivityTagService.listActivityTagInfo();//查询标签
|
|
|
+ List<ActivityTag> listActivityTagInfo = iActivityTagService.listActivityTagInfo();//查询标签
|
|
|
|
|
|
- mav.addObject("list",list);
|
|
|
- mav.addObject("activityNews",activityNews);
|
|
|
- mav.addObject("typeInfo",listActivityTypeInfo);
|
|
|
- mav.addObject("tagInfo",listActivityTagInfo);
|
|
|
+ mav.addObject("list", list);
|
|
|
+ mav.addObject("activityNews", activityNews);
|
|
|
+ mav.addObject("typeInfo", listActivityTypeInfo);
|
|
|
+ mav.addObject("tagInfo", listActivityTagInfo);
|
|
|
|
|
|
return mav;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改 实现
|
|
|
+ *
|
|
|
* @param activityNews
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("activityNewsUpdates.html")
|
|
|
- public ModelAndView toUpdates(ActivityNews activityNews){
|
|
|
+ public ModelAndView toUpdates(ActivityNews activityNews) {
|
|
|
|
|
|
- String [] imgStr = activityNews.getActivityimage().split(",");//将图片保存到数组中,用来判断图片个数
|
|
|
+ String[] imgStr = activityNews.getActivityimage().split(",");//将图片保存到数组中,用来判断图片个数
|
|
|
|
|
|
- if (imgStr.length > 3){ //图片个数大于3,返回操作失败
|
|
|
+ if (imgStr.length > 3) { //图片个数大于3,返回操作失败
|
|
|
|
|
|
- return ViewUtil.returnview(0,"activityNewsList.html","活动资讯列表");
|
|
|
+ return ViewUtil.returnview(0, "activityNewsList.html", "活动资讯列表");
|
|
|
}
|
|
|
|
|
|
int row = iActivityNewsService.updateNotNull(activityNews);//修改
|
|
|
|
|
|
- return ViewUtil.returnview(row,"activityNewsList.html","活动资讯列表");
|
|
|
+ return ViewUtil.returnview(row, "activityNewsList.html", "活动资讯列表");
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("activityNewsDel.html")
|
|
|
- public AjaxMessage<Object> providerDel(String id){
|
|
|
+ public AjaxMessage<Object> providerDel(String id) {
|
|
|
|
|
|
AjaxMessage<Object> am = new AjaxMessage();
|
|
|
- String [] idlist = id.split(",");
|
|
|
+ String[] idlist = id.split(",");
|
|
|
|
|
|
int row = 0;
|
|
|
|
|
|
- for (String string : idlist){
|
|
|
+ for (String string : idlist) {
|
|
|
row += iActivityNewsService.delete(Integer.valueOf(string));
|
|
|
}
|
|
|
- if (row > 0 ){
|
|
|
+ if (row > 0) {
|
|
|
am.setIs(true);
|
|
|
am.setMsg("删除成功 ");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
am.setIs(false);
|
|
|
am.setMsg("删除失败");
|
|
|
}
|
|
|
|
|
|
- return am;
|
|
|
+ return am;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 上传图片到本地服务器
|
|
|
+ *
|
|
|
* @param photo
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/uploadImg",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
|
|
|
- public ApiMessage<Object> uploadImg(@RequestParam MultipartFile[] photo){
|
|
|
+ @RequestMapping(value = "/uploadImg", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
|
|
|
+ public ApiMessage<Object> uploadImg(@RequestParam MultipartFile[] photo) {
|
|
|
|
|
|
String folder = "upload/activity";//创建文件夹存放上传图片
|
|
|
try {
|