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

import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate;
import cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplateExample;
import cn.superdesk.uniorder.dao.mapper.sys.notify.SysNotifyTemplateMapper;
import cn.superdesk.uniorder.service.sys.notify.SysNotifyTemplateService;
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-03-01 17:37:17
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-03-01 17:37:17
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Service
public class SysNotifyTemplateServiceImpl implements SysNotifyTemplateService {

    @Autowired
    private SysNotifyTemplateMapper sysNotifyTemplateMapper;


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


    @Override
    public int insertSelective(SysNotifyTemplate entity) {
        return sysNotifyTemplateMapper.insertSelective(entity);
    }

    @Override
    public int updateByPrimaryKeySelective(SysNotifyTemplate entity) {
        return sysNotifyTemplateMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public void deleteObj(Long id) {
    }

    @Override
    public SysNotifyTemplate findById(Long id) {
        return sysNotifyTemplateMapper.selectByPrimaryKey(id);
    }

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

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

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


    public void addSysNotifyTemplate(SysNotifyTemplate entity) {
        sysNotifyTemplateMapper.insertSelective(entity);
    }

    public void updateSysNotifyTemplate(SysNotifyTemplate entity) {
        SysNotifyTemplate originEntity = sysNotifyTemplateMapper.selectByPrimaryKey(entity.getId());
//		AssertUtil.notNull(originEntity);
        AnBeanUtils.copy(entity, originEntity);
        sysNotifyTemplateMapper.updateByPrimaryKeySelective(originEntity);
    }

    public void deleteSysNotifyTemplate(Long id) {
        sysNotifyTemplateMapper.deleteByPrimaryKey(id);
    }

    public SysNotifyTemplate findSysNotifyTemplateById(Long id) {
        SysNotifyTemplate entity = sysNotifyTemplateMapper.selectByPrimaryKey(id);
//		AssertUtil.notNull(entity);
        return entity;
    }

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

        // 样例 保留
//		SysNotifyTemplate sysNotifyTemplateConditions = AnBeanUtils.mapToBean(conditions,SysNotifyTemplate.class);

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

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

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

    }

}