package org.dromara.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.dromara.system.domain.SysVersion;
import org.dromara.system.domain.bo.SysVersionBo;
import org.dromara.system.domain.dto.VersionDTO;
import org.dromara.system.domain.vo.SysVersionVo;

@Mapper
public interface SysVerisonMapper extends BaseMapper<SysVersion> {

    IPage<SysVersionVo> getList(@Param("page") Page<SysVersion> page, @Param("query") SysVersionBo query);


    @Update("UPDATE sys_version SET status = 0 WHERE platform_type = #{platformType} AND status = 1")
    void disableOtherVersions(String platformType);

    @Update("UPDATE sys_version SET status = 0 " +
        "WHERE platform_type = #{platformType} " +
        "AND status = 1 " +
        "AND id != #{currentId}")  // 排除当前正在修改的版本
    void disableOtherVersion(@Param("platformType") String platformType,
                              @Param("currentId") Long currentId);
}
