package com.njzscloud.dispose.cst.station.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.dispose.cst.station.mapper.StationMemberMapper;
import com.njzscloud.dispose.cst.station.pojo.entity.StationMemberEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 站点成员
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class StationMemberService extends ServiceImpl<StationMemberMapper, StationMemberEntity> implements IService<StationMemberEntity> {

    /**
     * 新增
     */
    public void add(StationMemberEntity stationMemberEntity) {
        this.save(stationMemberEntity);
    }

    /**
     * 修改
     */
    public void modify(StationMemberEntity stationMemberEntity) {
        this.updateById(stationMemberEntity);
    }

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

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

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