package com.njzscloud.supervisory.biz.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.biz.mapper.BizObjMapper;
import com.njzscloud.supervisory.biz.pojo.entity.BizObjEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 客户分类
 */
@Slf4j
@Service
public class BizObjService extends ServiceImpl<BizObjMapper, BizObjEntity> implements IService<BizObjEntity> {

    /**
     * 新增
     */
    public void add(BizObjEntity bizObjEntity) {
        this.save(bizObjEntity);
    }

    /**
     * 修改
     */
    public void modify(BizObjEntity bizObjEntity) {
        this.updateById(bizObjEntity);
    }

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

    /**
     * 详情
     */
    public BizObjEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     */
    public PageResult<BizObjEntity> paging(PageParam pageParam, BizObjEntity bizObjEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<BizObjEntity>query(bizObjEntity)));
    }

}
