package net.mingsoft.cms.action.web;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.biz.impl.CategoryBizImpl;
import net.mingsoft.cms.entity.CategoryEntity;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.Element;

import javax.sql.DataSource;
import javax.swing.text.Document;
import java.util.ArrayList;
import java.util.List;
@Service
public class SqlSession {
    private SqlSessionFactory sessionFactory;
      String  abc;

    @Autowired
    private DataSource dataSource;
    @Autowired
    private ICategoryBiz categoryBiz;


    public SqlSessionFactory testBoradReturnType() throws Exception {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.message = dataSource.getConnection().toString();
        resultEntity.status = dataSource.getLoginTimeout();
        return sessionFactory;
    }


    public void init() {
        List<String> list = new ArrayList<>();
        list.stream().map(clazz -> "t" + (this.getClass().getSimpleName()));
    }

    public void pushDownStream(ResultEntity businessStatusBack) {
        String store = businessStatusBack.getMessage();
        int s = 0;
        if ("1".equals(store)) {
            s = 1;
        } else if ("2".equals(store)) {
            s = 2;
        }else {
            s=3;
        }
    }

    public void listEmpty(CategoryEntity category) {
            BasicUtil.startPage();
            category.setSqlWhere("");
            String  str = categoryBiz.setTopId(category);
            if("".equals(str)){
                System.out.println("empty set");
            }
    }

    public  void  errorTest(){
        CategoryBizImpl str= new CategoryBizImpl();
        String  temp=  str.listObjs().toString().replaceAll("(.*/proxy/download_file/)(.*)", "cid:$2");

       /* String  temp=  str.listObjs().toString().replaceAll("(.*///proxy/download_file/)(.*)", "cid:$2");  */
        List<Integer> miniUserIdList = new ArrayList<>();
        miniUserIdList.forEach(item -> str.listObjs().toString());
        miniUserIdList.forEach(item -> miniUserIdList.add(item));
      }




}
