package cn.superdesk.uniorder.service.sys.logger.impl;


import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.sys.logger.SysMonitorFunctionLog;
import cn.superdesk.uniorder.dao.entity.sys.logger.SysMonitorFunctionLogExample;
import cn.superdesk.uniorder.dao.mapper.sys.logger.SysMonitorFunctionLogMapper;
import cn.superdesk.uniorder.service.sys.logger.SysMonitorFunctionLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: 监控日志
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-07-05 16:35:25
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-07-05 16:35:25
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Service
public class SysMonitorFunctionLogServiceImpl implements SysMonitorFunctionLogService {

    @Autowired
    private SysMonitorFunctionLogMapper sysMonitorFunctionLogMapper;


    /****************************************** extends BaseService 部分 start ******************************************/


    @Override
    public int insertSelective(SysMonitorFunctionLog entity) {
        return sysMonitorFunctionLogMapper.insertSelective(entity);
    }

    @Override
    public int updateByPrimaryKeySelective(SysMonitorFunctionLog entity) {
        return sysMonitorFunctionLogMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public void deleteObj(Long id) {
    }

    @Override
    public SysMonitorFunctionLog findById(Long id) {
        return sysMonitorFunctionLogMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<SysMonitorFunctionLog> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {
        return null;
    }

    @Override
    public List<SysMonitorFunctionLog> findAll(Map<String, Object> queryMap) {
        return null;
    }

    /****************************************** extends BaseService 部分   end ******************************************/


    public void addSysMonitorFunctionLog(SysMonitorFunctionLog entity) {
        sysMonitorFunctionLogMapper.insertSelective(entity);
    }

    public void updateSysMonitorFunctionLog(SysMonitorFunctionLog entity) {
        SysMonitorFunctionLog originEntity = sysMonitorFunctionLogMapper.selectByPrimaryKey(entity.getId());
//		AssertUtil.notNull(originEntity);
        AnBeanUtils.copy(entity, originEntity);
        sysMonitorFunctionLogMapper.updateByPrimaryKey(originEntity);
    }

    public void deleteSysMonitorFunctionLog(Long id) {
        sysMonitorFunctionLogMapper.deleteByPrimaryKey(id);
    }

    public SysMonitorFunctionLog findSysMonitorFunctionLogById(Long id) {
        SysMonitorFunctionLog entity = sysMonitorFunctionLogMapper.selectByPrimaryKey(id);
//		AssertUtil.notNull(entity);
        return entity;
    }

    public R<List<SysMonitorFunctionLog>> pageQuery(Map<String, Object> conditions, int pageNun, int pageSize) {

        // 样例 保留
//		SysMonitorFunctionLog sysMonitorFunctionLogConditions = BeanUtils.mapToBean(conditions,SysMonitorFunctionLog.class);

        SysMonitorFunctionLogExample          example  = new SysMonitorFunctionLogExample();
        SysMonitorFunctionLogExample.Criteria criteria = example.createCriteria();

        PageHelper.startPage(pageNun, pageSize);
        List<SysMonitorFunctionLog>     resultList = sysMonitorFunctionLogMapper.selectByExample(example);
        PageInfo<SysMonitorFunctionLog> page       = new PageInfo<SysMonitorFunctionLog>(resultList);
        PageHelper.clearPage();

        return new R<List<SysMonitorFunctionLog>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), resultList);

    }

}