spring-cloud/service/seata-account/src/main/resources/mapper/AccountTblMapper.xml

73 lines
2.9 KiB
XML
Raw Normal View History

2025-02-11 19:38:18 +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">
<mapper namespace="com.atguigu.account.mapper.AccountTblMapper">
<resultMap id="BaseResultMap" type="com.atguigu.account.bean.AccountTbl">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="money" column="money" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,user_id,money
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from account_tbl
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from account_tbl
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.atguigu.account.bean.AccountTbl" useGeneratedKeys="true">
insert into account_tbl
( id,user_id,money
)
values (#{id,jdbcType=INTEGER},#{userId,jdbcType=VARCHAR},#{money,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.atguigu.account.bean.AccountTbl" useGeneratedKeys="true">
insert into account_tbl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="userId != null">user_id,</if>
<if test="money != null">money,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="userId != null">#{userId,jdbcType=VARCHAR},</if>
<if test="money != null">#{money,jdbcType=INTEGER},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.atguigu.account.bean.AccountTbl">
update account_tbl
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="money != null">
money = #{money,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.atguigu.account.bean.AccountTbl">
update account_tbl
set
user_id = #{userId,jdbcType=VARCHAR},
money = #{money,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="debit">
update account_tbl
set money = money - #{money,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=VARCHAR}
</update>
</mapper>