game-api/ff-admin/src/main/resources/mapper/common/TenantGameQuotaMapper.xml

97 lines
4.6 KiB
XML
Raw Normal View History

2025-02-12 13:42:52 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2025-02-12 13:42:52 +08:00
<mapper namespace="com.ff.common.mapper.TenantGameQuotaMapper">
2025-02-12 13:42:52 +08:00
<resultMap type="TenantGameQuota" id="TenantGameQuotaResult">
<result property="id" column="id" />
<result property="tenantKey" column="tenant_key" />
<result property="balance" column="balance" />
<result property="quotaType" column="quota_type" />
2025-02-12 13:42:52 +08:00
<result property="version" column="version" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTenantGameQuotaVo">
select id, tenant_key, balance, quota_type, version, create_by, create_time, update_by, update_time from ff_tenant_game_quota
2025-02-12 13:42:52 +08:00
</sql>
<select id="selectTenantGameQuotaByTenantKey" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
where tenant_key = #{tenantKey} and quota_type = #{quotaType}
</select>
2025-02-12 13:42:52 +08:00
<select id="selectTenantGameQuotaList" parameterType="TenantGameQuota" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
<where>
2025-02-12 13:42:52 +08:00
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="balance != null "> and balance = #{balance}</if>
<if test="quotaType != null "> and quota_type = #{quotaType}</if>
2025-02-12 13:42:52 +08:00
<if test="version != null "> and version = #{version}</if>
</where>
</select>
2025-02-12 13:42:52 +08:00
<select id="selectTenantGameQuotaById" parameterType="Long" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
where id = #{id}
</select>
<update id="changeBalance" parameterType="TenantGameQuota">
update ff_tenant_game_quota set balance = #{balance},version =version+1
where tenant_key = #{tenantKey} and quota_type = #{quotaType} and version = #{version}
</update>
2025-02-12 13:42:52 +08:00
<insert id="insertTenantGameQuota" parameterType="TenantGameQuota" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_game_quota
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="balance != null">balance,</if>
<if test="quotaType != null">quota_type,</if>
2025-02-12 13:42:52 +08:00
<if test="version != null">version,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
2025-02-12 13:42:52 +08:00
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="balance != null">#{balance},</if>
<if test="quotaType != null">#{quotaType},</if>
2025-02-12 13:42:52 +08:00
<if test="version != null">#{version},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
2025-02-12 13:42:52 +08:00
</insert>
<update id="updateTenantGameQuota" parameterType="TenantGameQuota">
update ff_tenant_game_quota
<trim prefix="SET" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="balance != null">balance = #{balance},</if>
<if test="quotaType != null">quota_type = #{quotaType},</if>
2025-02-12 13:42:52 +08:00
<if test="version != null">version = #{version},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTenantGameQuotaById" parameterType="Long">
delete from ff_tenant_game_quota where id = #{id}
</delete>
<delete id="deleteTenantGameQuotaByIds" parameterType="String">
delete from ff_tenant_game_quota where id in
2025-02-12 13:42:52 +08:00
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>