package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;

import cn.estsh.i3plus.core.api.iservice.busi.ISysConfigService;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.SysConfig;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @Description : 系统参数服务测试
 * @Reference :
 * @Author : yunhao
 * @Date : 2018-10-30 10:49
 * @Modify :
 **/
public class TestSysConfigService extends TestBase {

    @Autowired
    private ISysConfigService sysConfigService;

    /**
     * 测试 查询所有系统参数
     */
    @Test
    @Transactional
    public void testListSysConfig() {
        List list = sysConfigService.ListSysConfig();
        System.out.println(JSON.toJSONString(list));
    }

    /**
     * 测试 根据id查询系统参数
     */
    @Test
    @Transactional
    public void testGetSysConfigById() {
        SysConfig sysConfig = sysConfigService.getSysConfigById(1057110061127700480L);
        System.out.println(JSON.toJSONString(sysConfig));
    }

    /**
     * 测试 添加系统参数
     */
    @Test
    @Transactional
    @Rollback(false)
    public void testInsertSysConfig() {
        SysConfig sysConfig = new SysConfig();
        sysConfig.setName("系统名称");
        sysConfig.setConfigCode("sys_name");
        sysConfig.setConfigType(1);
        sysConfig.setConfigValue("IMPP");
        sysConfig.setConfigDescription("系统名称");

        sysConfigService.insertSysConfig(sysConfig);
        System.out.println(JSON.toJSONString(sysConfig));

    }

    /**
     * 测试 修改系统参数
     */
    @Test
    @Transactional
    public void testUpdateSysConfig(){
        SysConfig sysConfig = sysConfigService.getSysConfigById(1057110613261684736L);
        sysConfig.setConfigDescription("测试修改");

        sysConfigService.updateSysConfig(sysConfig);
    }

    /**
     * 测试 根据id删除系统参数
     */
    @Test
    @Transactional
    public void testDeleteSysConfigById(){
        sysConfigService.deleteSysConfigById(1057111616417566720L);
    }

    /**
     * 测试 复制查询
     */
    @Test
    @Transactional
    public void testQuerySysConfigByPager(){
        SysConfig sysConfig = new SysConfig();

        Pager pager = new Pager();
        pager.setPageSize(10);
        pager.setCurrentPage(1);

        ListPager list = sysConfigService.querySysConfigByPager(sysConfig,pager);
        System.out.println(list);
    }
}
