All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mingsoft.cms.biz.impl.ContentBizImpl Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2012-present 铭软科技(mingsoft.net)
 * 本软件及相关文档文件(以下简称“软件”)的版权归 铭软科技 所有
 * 遵循 铭软科技《服务协议》中的《保密条款》
 */






package net.mingsoft.cms.biz.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import freemarker.template.TemplateException;
import net.mingsoft.base.biz.impl.BaseBizImpl;
import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.biz.IContentBiz;
import net.mingsoft.cms.dao.ICategoryDao;
import net.mingsoft.cms.dao.IContentDao;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.mdiy.biz.ITagBiz;
import net.mingsoft.mdiy.entity.ModelEntity;
import net.mingsoft.mdiy.entity.TagEntity;
import net.mingsoft.mdiy.util.ParserUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 文章管理持久化层
 * @author 铭飞开发团队
 * 创建日期:2019-11-28 15:12:32
* 历史修订:
*/ @Service("cmscontentBizImpl") public class ContentBizImpl extends BaseBizImpl implements IContentBiz { /* * log4j日志记录 */ protected final Logger LOG = LoggerFactory.getLogger(this.getClass()); @Autowired private IContentDao contentDao; /** * 栏目管理业务层 */ @Autowired private ICategoryDao categoryDao; @Autowired private ITagBiz tagBiz; @Override protected IBaseDao getDao() { return contentDao; } @Override public List queryIdsByCategoryIdForParser(ContentBean contentBean) { return this.contentDao.queryIdsByCategoryIdForParser(contentBean); } @Override public List queryContent(ContentBean contentBean) { return this.contentDao.queryContent(contentBean); } @Override public int getSearchCount(ModelEntity contentModel, List diyList, Map whereMap, String categoryIds) { if (contentModel!=null) { return contentDao.getSearchCount(contentModel.getModelTableName(),diyList,whereMap, categoryIds); } return contentDao.getSearchCount(null,null,whereMap, categoryIds); } @Override public List queryIdsByCategoryIdForParserAndNotCover(ContentBean contentBean) { return this.contentDao.queryIdsByCategoryIdForParserAndNotCover(contentBean); } @Override public List list(Map map ) { //通过tagSqlBiz获取arclist对应的sql QueryWrapper tagWrapper = new QueryWrapper<>(); tagWrapper.eq("tag_name", "arclist"); TagEntity tagEntity = tagBiz.getOne(tagWrapper); String sqlFtl = tagEntity.getTagSql(); List contentEntities = null; //通过ParserUtil try { String sql = ParserUtil.rendering(map,sqlFtl); //执行原生的sql contentEntities = (List) tagBiz.excuteSql(sql); } catch (IOException e) { e.printStackTrace(); } catch (TemplateException e) { e.printStackTrace(); } return contentEntities; } @Override public Map get(Map map) { //通过tagSqlBiz获取data对应的sql LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TagEntity::getTagName, "data"); TagEntity tagEntity = tagBiz.getOne(wrapper); if (tagEntity == null) { return null; } String sqlFtl = tagEntity.getTagSql(); Map content = null; try { String sql = ParserUtil.rendering(map,sqlFtl); //执行原生的sql ListcontentEntities = (List) tagBiz.excuteSql(sql); if (CollUtil.isEmpty(contentEntities)) { return null; } // 默认取出第一个返回数据 content = contentEntities.get(0); } catch (Exception e) { e.printStackTrace(); } return content; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy