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.SysNotifyCategory;
import cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyCategoryExample;
import cn.superdesk.uniorder.dao.mapper.sys.notify.SysNotifyCategoryMapper;
import cn.superdesk.uniorder.service.sys.notify.SysNotifyCategoryService;
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 SysNotifyCategoryServiceImpl implements SysNotifyCategoryService {

    @Autowired
    private SysNotifyCategoryMapper sysNotifyCategoryMapper;


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


    @Override
    public int insertSelective(SysNotifyCategory entity) {
        return sysNotifyCategoryMapper.insertSelective(entity);
    }

    @Override
    public int updateByPrimaryKeySelective(SysNotifyCategory entity) {
        return sysNotifyCategoryMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public void deleteObj(Long id) {
    }

    @Override
    public SysNotifyCategory findById(Long id) {
        return sysNotifyCategoryMapper.selectByPrimaryKey(id);
    }

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

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

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


    public void addSysNotifyCategory(SysNotifyCategory entity) {
        sysNotifyCategoryMapper.insertSelective(entity);
    }

    public void updateSysNotifyCategory(SysNotifyCategory entity) {
        SysNotifyCategory originEntity = sysNotifyCategoryMapper.selectByPrimaryKey(entity.getId());
//		AssertUtil.notNull(originEntity);
        AnBeanUtils.copy(entity, originEntity);
        sysNotifyCategoryMapper.updateByPrimaryKeySelective(originEntity);
    }

    public void deleteSysNotifyCategory(Long id) {
        sysNotifyCategoryMapper.deleteByPrimaryKey(id);
    }

    public SysNotifyCategory findSysNotifyCategoryById(Long id) {
        SysNotifyCategory entity = sysNotifyCategoryMapper.selectByPrimaryKey(id);
//		AssertUtil.notNull(entity);
        return entity;
    }

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

        // 样例 保留
//		SysNotifyCategory sysNotifyCategoryConditions = AnBeanUtils.mapToBean(conditions,SysNotifyCategory.class);

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

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

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

    }

}