com.leazxl.cms.service.CmsCategoryService Maven / Gradle / Ivy
package com.leazxl.cms.service;
import com.leazxl.cms.dao.CmsCategoryDao;
import com.leazxl.cms.model.CmsArticle;
import com.leazxl.cms.model.CmsArticleData;
import com.leazxl.cms.model.CmsCategory;
import com.leazxl.core.idservice.IdService;
import com.leazxl.core.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
*
*/
@Service
public class CmsCategoryService {
@Autowired
private IdService idService;
@Autowired
private CmsCategoryDao categoryDao;
public List getCateList(String site, String parentId) {
List list = categoryDao.queryByParentId(site, parentId);
return list;
}
public void save(CmsCategory cmsCategory) {
if (cmsCategory.getId() == null || "".equals(cmsCategory.getId())) {
CmsCategory parecate = categoryDao.get(cmsCategory.getParentId());
cmsCategory.setId(idService.getId());
cmsCategory.setParentIds(parecate.getParentIds() + cmsCategory.getId()+",");
cmsCategory.setCreateBy(SecurityUtils.getUserId());
cmsCategory.setCreateDate(new Date());
cmsCategory.setUpdateBy(SecurityUtils.getUserId());
cmsCategory.setUpdateDate(new Date());
cmsCategory.setDelFlag("0");
categoryDao.save(cmsCategory);
} else {
cmsCategory.setUpdateBy(SecurityUtils.getUserId());
cmsCategory.setUpdateDate(new Date());
categoryDao.updateTemplateById(cmsCategory);
}
}
public void delete(String id) {
categoryDao.deleteById(id);
}
public CmsCategory get(String id) {
return categoryDao.get(id);
}
}