package com.ruoyi.system.mapper;

import com.ruoyi.system.domain.AccessCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AccessCountMapper {

    @Select("SELECT * FROM access_count WHERE year = #{year}")
    AccessCount selectByYear(Integer year);

    @Update("UPDATE access_count SET count = count + 1 WHERE year = #{year}")
    int incrementCount(Integer year);

    @Update("INSERT INTO access_count (year, count) VALUES (#{year}, 1) ON DUPLICATE KEY UPDATE count = count + 1")
    int insertOrUpdateAccessCount(Integer year);
}
