package com.platform.service;

import com.platform.dao.ApiSceneMapper;
import com.platform.entity.BrandVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;


@Service
public class ApiSceneService {
	@Autowired
	private ApiSceneMapper sceneMapper;
	
	
	public BrandVo queryObject(Integer id){
		return sceneMapper.queryObject(id);
	}

	public BrandVo queryByScene(String sceneNum){
		return sceneMapper.queryByScene(sceneNum);
	}
	
	public List<BrandVo> queryList(Map<String, Object> map){
		return sceneMapper.queryList(map);
	}
	
	
	public int queryTotal(Map<String, Object> map){
		return sceneMapper.queryTotal(map);
	}
	
	
	public void save(BrandVo brand){
		sceneMapper.save(brand);
	}
	
	
	public void update(BrandVo brand){
		sceneMapper.update(brand);
	}
	
	
	public void delete(Integer id){
		sceneMapper.delete(id);
	}
	
	
	public void deleteBatch(Integer[] ids){
		sceneMapper.deleteBatch(ids);
	}

	public Long increaseViewCount(String brandId) {
		if(ObjectUtils.isEmpty(brandId)){
			return 0L;
		}
		// 查找数据
		sceneMapper.increaseViewCount(brandId);
		BrandVo brandVo = sceneMapper.queryObject(brandId);
		if(!ObjectUtils.isEmpty(brandVo) && !ObjectUtils.isEmpty(brandVo.getPvTotalNum())){
			return brandVo.getPvTotalNum();
		}
		return 0L;
	}
}
