Helius
2021-01-25 89e17a219d8a6d208e4cb32a43e90abb89b3c93b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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, "发布状态");
    }
     
}