package com.webchat.service.behavior;


import com.webchat.common.util.SpringContextUtil;
import com.webchat.repository.dao.IResourceBehaviorDAO;
import com.webchat.repository.entity.ResourceBehaviorEntity;

/**
 * 资源行为服务 - 写 (单向：没有取消行为，点击、浏览)
 */
public class ResourceOneWayBehaviorService extends AbstractResourceBehaviorService {

    @Override
    public boolean behaviorResource(String userId, Long resourceIndex, String resourceType, String behaviorType) {
        IResourceBehaviorDAO resourceBehaviorDAO = SpringContextUtil.getBean(IResourceBehaviorDAO.class);
        ResourceBehaviorEntity behaviorEntity = new ResourceBehaviorEntity();
        behaviorEntity.setUserId(userId);
        behaviorEntity.setResourceIndex(resourceIndex);
        behaviorEntity.setResourceType(resourceType);
        behaviorEntity.setBehaviorType(behaviorType);
        behaviorEntity.setStatus(Boolean.TRUE);
        resourceBehaviorDAO.save(behaviorEntity);
        // 刷新缓存
        return true;
    }
}
