| package com.matrix.system.hive.action; | 
|   | 
| import java.util.Date; | 
|   | 
| import javax.annotation.Resource; | 
|   | 
| import com.matrix.core.constance.MatrixConstance; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.WebUtil; | 
| import com.matrix.system.common.bean.SysUsers; | 
| import com.matrix.system.constance.Dictionary; | 
| import com.matrix.system.hive.bean.Article; | 
| import com.matrix.system.common.bean.SystemDictionary; | 
| import com.matrix.system.hive.service.ArticleService; | 
| import com.matrix.system.common.service.SystemDictionaryService; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
|   | 
|   | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
|   | 
|   | 
| /** | 
|  * @author jiangyouyao | 
|  * @date 2016-07-15 11:19 | 
|  * 文章Controller | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/article") | 
| public class ArticleController extends BaseController{ | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     @Resource | 
|     private ArticleService currentService; | 
|     @Resource | 
|     private SystemDictionaryService sysDataDictionaryService; | 
|      | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(Article article, PaginationVO pageVo) { | 
|         article.setType(Dictionary.ARTICEL_TYPE_NAME_SCWZ); | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         article.setShopId(users.getShopId()); | 
|         return showList(currentService, article, pageVo); | 
|     } | 
|      | 
|     /** | 
|      * 美度学院文章集合 | 
|      */ | 
|     @RequestMapping(value = "/queryList") | 
|     public @ResponseBody AjaxResult queryList(Article article, PaginationVO pageVo) { | 
|         article.setType(Dictionary.ARTICEL_TYPE_NAME_MDXY); | 
|   | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         article.setShopId(users.getShopId()); | 
|         return showList(currentService, article, pageVo); | 
|         //return new AjaxResult(AjaxResult.STATUS_SUCCESS, currentService.findInPage(article, pageVo),currentService.findTotal(article)); | 
|     } | 
|      | 
|     /** | 
|      * 美度学院文章集合 | 
|      */ | 
|     @RequestMapping(value = "/queryAll") | 
|     public @ResponseBody AjaxResult queryAll(Article article, PaginationVO pageVo) { | 
|         article.setType(Dictionary.ARTICEL_TYPE_NAME_WXXMWZ); | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         article.setShopId(users.getShopId()); | 
|         return showList(currentService, article, pageVo); | 
|         //return new AjaxResult(AjaxResult.STATUS_SUCCESS, currentService.findInPage(article, pageVo),currentService.findTotal(article)); | 
|     } | 
|      | 
|      | 
|     /** | 
|      * 查询文章分类集合 | 
|      */ | 
|     @RequestMapping(value = "/queryClassify") | 
|     public @ResponseBody AjaxResult queryClassify() { | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         SystemDictionary sysDataDictionary=new SystemDictionary(); | 
|         sysDataDictionary.setType(Dictionary.ARTICLE_CLASSIFY); | 
|         sysDataDictionary.setShopId(users.getShopId()); | 
|         return new AjaxResult(AjaxResult.STATUS_SUCCESS, sysDataDictionaryService.findByModel(sysDataDictionary),0); | 
|     } | 
|      | 
|         | 
|     /** | 
|      * 新增或者修改页面 | 
|      */        | 
|        @RequestMapping(value = "/addOrModify") | 
|        @RemoveRequestToken | 
|     public @ResponseBody AjaxResult addOrModify(Article article) { | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         article.setShopId(users.getShopId()); | 
|         if (article.getId() != null) { | 
|             return modify(currentService, article, "文章"); | 
|         } else { | 
|             article.setCreatetiem(new Date()); | 
|             return add(currentService, article, "文章"); | 
|         } | 
|     } | 
|      | 
|        /** | 
|      * 进入修改界面 | 
|      */    | 
|        @RequestMapping(value = "/editForm") | 
|        @SaveRequestToken | 
|     public String editForm(Long id) { | 
|         Article article; | 
|         if (id != null) { | 
|             article = currentService.findById(id); | 
|             WebUtil.getRequest().setAttribute("obj", article); | 
|         } | 
|         return "admin/hive/operate/trainingMaterialsManage-form"; | 
|     } | 
|         | 
|        /** | 
|      * 进入修改界面 | 
|      */    | 
|        @RequestMapping(value = "/addForm") | 
|        @SaveRequestToken | 
|     public String addForm(Long id) { | 
|         Article article; | 
|         if (id != null) { | 
|             article = currentService.findById(id); | 
|             WebUtil.getRequest().setAttribute("obj", article); | 
|         } | 
|         return "admin/hive/operate/trainingMaterialsManage-form"; | 
|     } | 
|         | 
|        /** | 
|      * 项目进入修改界面 | 
|      */    | 
|        @RequestMapping(value = "/updateForm") | 
|        @SaveRequestToken | 
|     public String updateForm(Long id) { | 
|         Article article; | 
|         if (id != null) { | 
|             article = currentService.findById(id); | 
|             WebUtil.getRequest().setAttribute("obj", article); | 
|         } | 
|         return "admin/hive/shopping/projArticle-form"; | 
|     } | 
|         | 
|         | 
|        /** | 
|      * 删除 | 
|      */   | 
|      @RequestMapping(value = "/del") | 
|     public @ResponseBody AjaxResult del(String keys) { | 
|         return remove(currentService, keys); | 
|     } | 
|       | 
|      /** | 
|       * 改变发布状态:已发布 | 
|       * @param id | 
|       *  | 
|       */ | 
|      @RequestMapping(value = "/setArticleStaticY") | 
|      public @ResponseBody AjaxResult setArticleStaticY(Long id) {     | 
|          Article article = currentService.findById(id); | 
|          article.setIsPublish(Dictionary.FLAG_YES); | 
|         return modify(currentService, article, "发布状态"); | 
|     } | 
|           | 
|      /** | 
|       * 改变发布状态:未发布 | 
|       * @param id | 
|       *  | 
|       */ | 
|      @RequestMapping(value = "/setArticleStaticN") | 
|      public @ResponseBody AjaxResult setArticleStaticN(Long id) {     | 
|          Article article = currentService.findById(id); | 
|          article.setIsPublish(Dictionary.FLAG_NO); | 
|         return modify(currentService, article, "发布状态"); | 
|     } | 
|       | 
| } |