package com.jpsoft.shinestar.modules.base.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jpsoft.shinestar.modules.base.dao.SchoolServeDAO;
import com.jpsoft.shinestar.modules.base.entity.SchoolServe;
import com.jpsoft.shinestar.modules.base.service.SchoolServeService;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 墨鱼_mo
 * @date 2020-7-27 14:21
 */
@Transactional
@Component(value="schoolServeService")
public class SchoolServeServiceImpl implements SchoolServeService {

    @Resource
    private SchoolServeDAO schoolServeDAO;

    @Override
    public SchoolServe get(String id) {
        return schoolServeDAO.get(id);
    }

    @Override
    public int insert(SchoolServe model) {
        // TODO Auto-generated method stub
        //model.setId(UUID.randomUUID().toString());

        return schoolServeDAO.insert(model);
    }



    @Override
    public int update(SchoolServe model) {
        // TODO Auto-generated method stub
        return schoolServeDAO.update(model);
    }

    @Override
    public int delete(String id) {
        // TODO Auto-generated method stub
        return schoolServeDAO.delete(id);
    }

    @Override
    public boolean exist(String id) {
        // TODO Auto-generated method stub
        int count = schoolServeDAO.exist(id);

        return count > 0 ? true : false;
    }

    @Override
    public List<SchoolServe> list() {
        // TODO Auto-generated method stub
        return schoolServeDAO.list();
    }


    @Override
    public Page<SchoolServe> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
        Page<SchoolServe> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            schoolServeDAO.search(searchParams,sortList);
        });

        return page;
    }

    @Override
    public List<SchoolServe> findByCompanyId(String companyId) {
        return schoolServeDAO.findByCompanyId(companyId);
    }

    @Override
    public List<SchoolServe> searchParams(Map<String, Object> searchParams) {
        return schoolServeDAO.searchParams(searchParams);
    }
}
