package cn.tworice.client.service;

import cn.tworice.mybatis.query.LambdaQueryWrapperX;
import cn.tworice.common.util.excel.InductsListenerService;
import cn.tworice.client.dao.-tworice_name-Dao;
import cn.tworice.common.entity.code.*;
import cn.tworice.mybatis.vo.PageParam;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Arrays;
import java.util.Map;
import javax.annotation.Resource;


@Service
public class -tworice_name-Service implements InductsListenerService<-tworice_name-> {
    @Resource
    private -tworice_name-Dao dao;

    public Map<String,Object> getPage(PageParam pageParam,-tworice_name- entity) {
          return dao.selectPage(pageParam, new LambdaQueryWrapperX<-tworice_name->()
                          .eqIfPresent(-tworice_name-::getId, entity.getId())
                          .eqIfPresent(-tworice_name-::getCreator, entity.getCreator())
                          -tworice_query-
                          .orderByDesc(-tworice_name-::getCreateTime)
                  );
    }

    public int set(-tworice_name- entity) {
        if(entity.getId()==null){
            return dao.insert(entity);
        }else{
            return dao.updateById(entity);
        }
    }

    public int del(Integer[] ids) {
        return dao.deleteBatchIds(Arrays.asList(ids));
    }

    @Override
    public boolean saveBatch(List<-tworice_name-> list) {
        return dao.insertBatch(list,list.size());
    }

    public -tworice_name- info(int id) {
        return dao.selectById(id);
    }
}