package com.huiju.estateagents.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huiju.estateagents.entity.TaNews;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

/**
 * <p>
 * 资讯表  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-07-25
 */
@Mapper
public interface TaNewsMapper extends BaseMapper<TaNews> {

    /**
     * 某个字段值 +1
     * @param newsId
     * @param field
     * @param increment
     */
    @Update("UPDATE ta_news  SET ${field} = IFNULL(${field}, 0) + #{increment}  WHERE news_id = #{newsId}")
    void setFieldNum(@Param("newsId") String newsId, @Param("field") String field, @Param("increment") Integer increment);


    /**
     * 转化率 咨迅收藏 / 咨迅分享
     * @return
     */
    Map<String, Object> selectNewsStatistical(@Param("orgId") Integer orgId, @Param("saveOrShare") String saveOrShare);

}
