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

import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.jpsoft.shinestar.modules.base.dao.ParkingWayDAO;
import com.jpsoft.shinestar.modules.base.entity.ParkingWay;
import com.jpsoft.shinestar.modules.base.service.ParkingWayService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="parkingWayService")
public class ParkingWayServiceImpl implements ParkingWayService {
	@Resource(name="parkingWayDAO")
	private ParkingWayDAO parkingWayDAO;

	@Override
	public ParkingWay get(String id) {
		// TODO Auto-generated method stub
		return parkingWayDAO.get(id);
	}

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

		return parkingWayDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

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

        return page;
	}

	@Override
	public ParkingWay findByCompanyId(String companyId) {
		return parkingWayDAO.findByCompanyId(companyId);
	}
}