package com.fkzy.warn.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fkzy.warn.service.TestService;
import com.fkzy.warn.common.request.RequestParameter;
import com.fkzy.warn.mapper.TestMapper;
import com.fkzy.warn.model.Test;
import org.springframework.stereotype.Service;

/**
 * @author zhangjing
 * @date 2023/10/16 18:17
 * @description
 */
@Service
public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements
    TestService {

    @Override
    public boolean saveModel(Test entity) {
        boolean result = this.save(entity);
        return result;
    }

    @Override
    public boolean updateModel(Test entity) {
        boolean result = this.updateById(entity);
        return result;
    }

    @Override
    public boolean deleteModel(Test entity) {
        boolean result = this.removeById(entity);
        
        return result;
    }

    @Override
    public Page<Test> queryPage(RequestParameter parameter) {
        Test entity = parameter.getParameter().toJavaObject(Test.class);
        Page<Test> page = new Page<Test>(parameter.getCurrent(), parameter.getSize());
        page.setSearchCount(true);
        page.setOptimizeCountSql(true);
        QueryWrapper<Test> eWrapper = new QueryWrapper<Test>(entity);
        Page<Test> result = this.page(page, eWrapper);
        return result;
    }
}
