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.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.setShopId(users.getShopId());
|
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());
|
|
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) {
|
|
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);
|
}
|
|
}
|