package com.cretin.webdb.mapper

import com.baomidou.mybatisplus.core.mapper.BaseMapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select

/**
 * Copyright (C), 2015-2021, 电点科技有限公司
 * FileName: CustomUserService
 * Author: cretin
 * Date: 2021/3/17 6:23 下午
 * Description: 自定义的用户service
 */
interface CustomHomeService : BaseMapper<Any> {
    /**
     * 获取翻译的module
     */
    @Select("select ios_package,android_package from tb_str_translate_item where app_id = #{appId} group by ios_package,android_package")
    fun getTranslateModules(@Param("appId") appId: String): MutableList<MutableMap<String, Any?>>?

    /**
     * 获取已经有翻译的key
     */
//    @Select("select count(item_key),item_key from tb_v2_str_translate_item where item_channel in (#{channels}) and app_id = #{appId} group by item_key")
    @Select(
        "<script> select count(item_key) as cnum,item_key from tb_v2_str_translate_item where item_channel in " +
                "<foreach collection='channels' item='channel' open='(' separator=',' close=')'>" +
                "#{channel}" +
                "</foreach>" +
                " and app_id = #{appId} group by item_key" +
                "</script> "
    )
    fun getTranslatedKey(@Param("appId") appId:Int,@Param("channels") channels: MutableList<String>): MutableList<MutableMap<String, Any?>>?

    /**
     * 获取指定项目的所有key
     */
    @Select("select item_key from tb_v2_str_translate_item where app_id = #{appId} group by item_key")
    fun getAllKeys(@Param("appId") appId:Int): MutableList<MutableMap<String, Any?>>?

}