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.JtBusinessProjectMapper;
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;
	@Resource
	private JtBusinessProjectMapper jtBusinessProjectMapper;
	@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);
	}

	@Override
	public Map<String,Object> getApplicationData(Integer size1,Integer size2,Integer size3,Integer size4,Integer size5 ,Integer size6 ,Integer size7 ,Integer size8) {
		Map<String, Object> map=new HashMap<>();
		map.put("military", jtBusinessProjectMapper.getProjectByTag("军工市场采购",size1));
		map.put("government", jtBusinessProjectMapper.getProjectByTag("政府市场采购", size2));
		map.put("international", jtBusinessProjectMapper.getProjectByTag("国际市场开发", size3));
		map.put("taxReduction", jtBusinessProjectMapper.getProjectByTag("减税免税", size4));
		map.put("financingLease", jtBusinessProjectMapper.getProjectByTag("融资租售", size5));
		map.put("defenseWeapon", jtBusinessProjectMapper.getProjectByTag("攻防利器", size6));
		map.put("ownUse", jtBusinessProjectMapper.getProjectByTag("他山己用", size7));
		map.put("brandBuilding", jtBusinessProjectMapper.getProjectByTag("品牌建设",size8));
		return map;
	}
}
