935090232@qq.com
2021-03-19 81a3369395a7cccceb7cd36f5238cc6fe2aa88e5
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package com.matrix.system.hive.action;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import javax.annotation.Resource;
 
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.StringUtils;
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.ArticleType;
import com.matrix.system.hive.plugin.message.StringUtil;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import com.matrix.system.hive.service.ArticleTypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
 
 
 
/**
 * @author jiangyouyao
 * @date 2016-07-15 11:19
 * 文章类型Controller
 */
@Controller
@RequestMapping(value = "admin/articleType")
public class ArticleTypeController extends BaseController{
 
 
 
 
    @Resource
    private ArticleTypeService currentService;
    
    /**
     * 商城文章列表显示
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody
    AjaxResult showList(ArticleType articleType, PaginationVO pageVo) {
 
        return showList(currentService, articleType, pageVo);
    }
        
    /**
     * 内部培训列表显示
     */
    @RequestMapping(value = "/all")
    public @ResponseBody AjaxResult all(ArticleType articleType) {
 
        articleType.setType(Dictionary.ARTICEL_TYPE_NAME_SCWZ);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,    currentService.findByModel(articleType), 0);
    }
    
    /**
     * 项目列表显示
     */
    @RequestMapping(value = "/projAll")
    public @ResponseBody AjaxResult projAll(ArticleType articleType) {
 
        articleType.setType(Dictionary.ARTICEL_TYPE_NAME_WXXMWZ);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,    currentService.findByModel(articleType), 0);
    }
    
    
    /**
     * 内部培训列表显示
     */
    @RequestMapping(value = "/queryAll")
    public @ResponseBody AjaxResult queryAll(ArticleType articleType) {
        SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        articleType.setType(Dictionary.ARTICEL_TYPE_NAME_MDXY);
        articleType.setCompanyId(users.getCompanyId());
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,    currentService.findByModel(articleType), 0);
    }
    
/*    *//**
     * 美度学院列表显示(培训资料)
     *//*
    @RequestMapping(value = "/pxzl")
    public @ResponseBody AjaxResult pxzl(ArticleType articleType) {
        articleType.setType(Dictionary.ARTICEL_TYPE_NAME_MDXY);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,    currentService.findByModel(articleType), 0);
    }*/
    
    /**
     * 新增或者修改页面
     */       
       @RequestMapping(value = "/addOrModify")
    public @ResponseBody AjaxResult addOrModify(ArticleType articleType) {
        SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        articleType.setShopId(users.getShopId());
           articleType.setType(Dictionary.ARTICEL_TYPE_NAME_SCWZ);
        if (articleType.getId() != null) {
 
            return modify(currentService, articleType, "文章类型");
        } else {
 
            return add(currentService, articleType, "文章类型");
        }
    }
       
       /**
     * 新增美度学院类型
     */       
       @RequestMapping(value = "/addModify")
    public @ResponseBody AjaxResult addModify(ArticleType articleType) {
           articleType.setType(Dictionary.ARTICEL_TYPE_NAME_MDXY);
        SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        articleType.setShopId(users.getShopId());
        articleType.setCompanyId(users.getCompanyId());
        Long parentId = articleType.getParentId();
        List<Long> ids = new ArrayList<>();
        while (parentId != 0) {
            ArticleType type = currentService.findById(parentId);
            ids.add(type.getId());
            parentId = type.getParentId();
        }
 
        articleType.setParentIds(CollectionUtils.isNotEmpty(ids) ? StringUtils.collToStr(ids, ",") : null);
        if (articleType.getId() != null) {
            // 自己不能是自己的父节点
            if (articleType.getParentId() != null && articleType.getParentId().equals(articleType.getId())) {
                throw new GlobleException("父级不能是自己");
            }
            return modify(currentService, articleType, "文章类型");
        } else {
 
            return add(currentService, articleType, "文章类型");
        }
    }
    
       
    /**
     * 新增项目类型
     */       
       @RequestMapping(value = "/addOrProjModify")
    public @ResponseBody AjaxResult addOrProjModify(ArticleType articleType) {
           articleType.setType(Dictionary.ARTICEL_TYPE_NAME_WXXMWZ);
        SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        articleType.setShopId(users.getShopId());
        if (articleType.getId() != null) {
 
            return modify(currentService, articleType, "项目");
        } else {
 
            return add(currentService, articleType, "项目");
        }
    }
       
  
       
       /**
     * 进入修改界面
     */   
       @RequestMapping(value = "/editForm")
    public String editForm(Long id) {
        ArticleType articleType;
        if (id != null) {
            articleType = currentService.findById(id);
            WebUtil.getRequest().setAttribute("obj", articleType);
        }
        return "admin/hive/shopping/articleTypeManage-form";
    }    
       
     /**
     * 项目管理进入修改界面
     */   
       @RequestMapping(value = "/updateProjForm")
    public String updateProjForm(Long id) {
        ArticleType articleType;
        if (id != null) {
            articleType = currentService.findById(id);
            WebUtil.getRequest().setAttribute("obj", articleType);
        }
        return "admin/hive/shopping/projArticleType-form";
    }    
     /**
     * 进入美度学院修改页面
     */   
       @RequestMapping(value = "/updateForm")
    public String updateForm(Long id) {
        ArticleType articleType;
        if (id != null) {
            articleType = currentService.findById(id);
            WebUtil.getRequest().setAttribute("obj", articleType);
        }
        return "admin/hive/operate/trainingMaterialsType-form";
    }    
       
       
       /**
     * 删除
     */  
     @RequestMapping(value = "/del")
    public @ResponseBody AjaxResult del(String keys) {
 
        return remove(currentService, keys);
    }
     
     @RequestMapping(value = "/findById")
    public @ResponseBody AjaxResult findById(Long id) {
 
        ArticleType articleType = super.findById(currentService, id);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, Arrays.asList(articleType), 0);
    }
     
}