package cn.com.countrygarden.bi.main.service.wcx.impl;

import cn.com.countrygarden.bi.main.constant.wcx.WcxConstant;
import cn.com.countrygarden.bi.main.dao.wcx.WcxRoleMapper;
import cn.com.countrygarden.bi.main.dao.wcx.WcxThumbMapper;
import cn.com.countrygarden.bi.main.dao.wcx.WcxUserMapper;
import cn.com.countrygarden.bi.main.model.wcx.WcxRole;
import cn.com.countrygarden.bi.main.model.wcx.WcxThumb;
import cn.com.countrygarden.bi.main.model.wcx.WcxUser;
import cn.com.countrygarden.bi.main.service.wcx.WcxThumbService;
import cn.com.countrygarden.bi.main.util.wcx.CommonUtil;
import cn.com.countrygarden.bi.main.util.wcx.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 *  点赞服务类
 *  
 *  @author ferren
 */
@Service
public class WcxThumbServiceImpl implements WcxThumbService {
    @Autowired
    private WcxThumbMapper wcxThumbMapper;
    @Autowired
    private WcxRoleMapper wcxRoleMapper;
    @Autowired
    private WcxUserMapper wcxUserMapper;

    @Override
    public WcxThumb selectOne(WcxThumb wcxThumb) {

        return null;
    }

    @Override
    public boolean isThumb(String userId, String innovationId) {
        WcxThumb conditionWcxThumb = new WcxThumb();
        conditionWcxThumb.setInnovationId(innovationId);
        conditionWcxThumb.setUserId(userId);
        WcxThumb hadThumb = wcxThumbMapper.selectOne(conditionWcxThumb);
        if (hadThumb != null) {
            return true;
        }
        return false;
    }

    @Override
    public Long getThumbNumber(String innovationId) {
        return wcxThumbMapper.selectThumbNumberByInnovationId(innovationId);
    }

    @Override
    public int getLeadThumbNumber(String innovationId) {
        return wcxThumbMapper.getLeadThumbNumberByInnId(innovationId);
    }

    @Override
    public Integer findThumbedNumByInnoId(String innoId, Date startDate, Date endDate) {
        Integer thumbedNumByInnoId = wcxThumbMapper.findThumbedNumByInnoId(innoId, startDate, endDate);
        return thumbedNumByInnoId;
    }


    private WcxThumb wcxThumbConstructor(String thumbId, Integer thumbNumber,
                                         String userId, String innovationId,
                                         String status, Date createDate){
        WcxThumb wcxThumb = new WcxThumb();
        wcxThumb.setThumbId(thumbId);
        wcxThumb.setThumbNumber(thumbNumber);
        wcxThumb.setUserId(userId);
        wcxThumb.setInnovationId(innovationId);
        wcxThumb.setStatus(status);
        wcxThumb.setCreateDate(createDate);
        return wcxThumb;
    }
}
