package com.goafanti.business.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.goafanti.business.bo.JtTagBo;
import com.goafanti.business.service.JtTagService;
import com.goafanti.common.dao.JtTagMapper;
import com.goafanti.common.model.JtTag;
import com.goafanti.common.utils.StringUtils;
import com.goafanti.core.mybatis.BaseMybatisDao;
import com.goafanti.core.mybatis.page.Pagination;
@Service
public class JtTagServiceImpl   extends BaseMybatisDao<JtTagMapper> implements JtTagService {
	@Resource
	private JtTagMapper	jtTagMapper;
	@Override
	public int addTag(JtTag a) {
		a.setId(UUID.randomUUID().toString());
		a.setCreateTime(new Date());
		return jtTagMapper.insert(a);
	}
	@Override
	public int deleteJtTag(String id) {
		return jtTagMapper.deleteByPrimaryKey(id);
	}
	@Override
	public int updateJtTag(JtTag a) {
		return jtTagMapper.updateByPrimaryKeySelective(a);
	}
	@Override
	public JtTag detailJtTag(JtTag a) {
		return jtTagMapper.selectByPrimaryKey(a.getId());
	}
	@SuppressWarnings("unchecked")
	@Override
	public Pagination<JtTagBo> selectListJtTag(JtTag a, Integer pageNo, Integer pageSize) {
		Map<String, Object> params = new HashMap<>();
		if(pageNo==null ||pageNo<1)pageNo=1;
		if(pageSize==null ||pageSize<1)pageSize=10;
		if(null!=null&&StringUtils.isNotBlank(a.getName()))params.put("name", a.getName());
		return (Pagination<JtTagBo>)findPage("selectJtTagList", "selectJtTagCount", params, pageNo, pageSize);
	}

}
