package com.njzscloud.supervisory.dict.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.dict.mapper.SysDictItemMapper;
import com.njzscloud.supervisory.dict.pojo.SysDictItemEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 字典条目表
 */
@Slf4j
@Service
public class SysDictItemService extends ServiceImpl<SysDictItemMapper, SysDictItemEntity> implements IService<SysDictItemEntity> {

    /**
     * 新增
     *
     * @param sysDictItemEntity 数据
     */

    public void add(SysDictItemEntity sysDictItemEntity) {
        this.save(sysDictItemEntity);
    }

    /**
     * 修改
     *
     * @param sysDictItemEntity 数据
     */

    public void modify(SysDictItemEntity sysDictItemEntity) {
        this.updateById(sysDictItemEntity);
    }

    /**
     * 删除
     *
     * @param ids Ids
     */

    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     *
     * @param id Id
     * @return SysDictItemEntity 结果
     */

    public SysDictItemEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     *
     * @param sysDictItemEntity 筛选条件
     * @param pageParam         分页参数
     * @return PageResult&lt;SysDictItemEntity&gt; 分页结果
     */

    public PageResult<SysDictItemEntity> paging(PageParam pageParam, SysDictItemEntity sysDictItemEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<SysDictItemEntity>query(sysDictItemEntity)));
    }

}
