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.PersonPopedomIconDAO;
import com.jpsoft.shinestar.modules.base.entity.PersonPopedomIcon;
import com.jpsoft.shinestar.modules.base.service.PersonPopedomIconService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="personPopedomIconService")
public class PersonPopedomIconServiceImpl implements PersonPopedomIconService {
	@Resource(name="personPopedomIconDAO")
	private PersonPopedomIconDAO personPopedomIconDAO;

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

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

		return personPopedomIconDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

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

		return page;
	}

	@Override
	public List<PersonPopedomIcon> findByPersonPopedomId(String personPopedomId) {
		return personPopedomIconDAO.findByPersonPopedomId(personPopedomId);
	}

	@Override
	public int deleteByPersonPopedomId(String personPopedomId) {
		return personPopedomIconDAO.deleteByPersonPopedomId(personPopedomId);
	}

	@Override
	public PersonPopedomIcon findByPersonIdAndIconName(Long personId, String iconName) {
		return personPopedomIconDAO.findByPersonIdAndIconName(personId,iconName);
	}
}