package com.sqx.modules.errand.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.errand.dao.ErrandIllegalTypeDao;
import com.sqx.modules.errand.entity.ErrandIllegalType;
import com.sqx.modules.errand.service.ErrandIllegalTypeService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ErrandIllegalTypeServiceImpl extends ServiceImpl<ErrandIllegalTypeDao, ErrandIllegalType> implements ErrandIllegalTypeService {
    @Override
    public Result selectIllegalTypeList() {
        List<ErrandIllegalType> illegalTypes = baseMapper.selectList(null);
        return Result.success().put("data", illegalTypes);
    }

    @Override
    public Result selectIllegalTypePage(Integer page, Integer limit) {
        Page<ErrandIllegalType> pages=new Page<>(page,limit);
        PageUtils pageUtils = new PageUtils(baseMapper.selectPage(pages, null));
        return Result.success().put("data", pageUtils);
    }

    @Override
    public Result insertIllegalType(ErrandIllegalType errandIllegalType) {
        baseMapper.insert(errandIllegalType);
        return Result.success();
    }

    @Override
    public Result updateIllegalType(ErrandIllegalType errandIllegalType) {
        baseMapper.updateById(errandIllegalType);
        return Result.success();
    }

    @Override
    public Result deleteIllegalType(Long id) {
        baseMapper.deleteById(id);
        return Result.success();
    }
}
