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

import java.math.BigDecimal;
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.CanteenInfoDAO;
import com.jpsoft.shinestar.modules.base.entity.CanteenInfo;
import com.jpsoft.shinestar.modules.base.service.CanteenInfoService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="canteenInfoService")
public class CanteenInfoServiceImpl implements CanteenInfoService {
	@Resource(name="canteenInfoDAO")
	private CanteenInfoDAO canteenInfoDAO;

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

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


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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = canteenInfoDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<CanteenInfo> list() {
		// TODO Auto-generated method stub
		return canteenInfoDAO.list();
	}
		
	@Override
	public Page<CanteenInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
        Page<CanteenInfo> page = PageHelper.startPage(1,10).doSelectPage(()->{
            canteenInfoDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}