2026-10-14 22:12:06 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
<mapper namespace="com.hongzhen.hera.data.UserAccountMapper">
|
|
|
|
|
|
|
|
|
|
<sql id="BaseColumnList">
|
|
|
|
|
id, username, nickname, password_hash, mobile, email, nfc_uid, wechat_openid, wechat_unionid,
|
|
|
|
|
status, register_country_code, register_region_code, register_city, register_timezone,
|
|
|
|
|
created_at, updated_at
|
|
|
|
|
</sql>
|
|
|
|
|
|
2026-10-15 21:28:05 +08:00
|
|
|
<select id="findByOpenId" resultType="com.hongzhen.hera.data.UserAccount">
|
|
|
|
|
SELECT <include refid="BaseColumnList"/> FROM user_account WHERE wechat_openid = #{openId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="findByMobile" resultType="com.hongzhen.hera.data.UserAccount">
|
|
|
|
|
SELECT <include refid="BaseColumnList"/> FROM user_account WHERE mobile = #{mobile}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="findByIdForUpdate" resultType="com.hongzhen.hera.data.UserAccount">
|
|
|
|
|
SELECT <include refid="BaseColumnList"/> FROM user_account WHERE id = #{id} FOR UPDATE
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="bindWechat">
|
|
|
|
|
UPDATE user_account SET wechat_openid = #{wechatOpenid},
|
|
|
|
|
wechat_unionid = COALESCE(#{wechatUnionid}, wechat_unionid), mobile = #{mobile}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateNickname">
|
|
|
|
|
UPDATE user_account SET nickname = #{nickname} WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-10-14 22:12:06 +08:00
|
|
|
<select id="findById" resultType="com.hongzhen.hera.data.UserAccount">
|
|
|
|
|
SELECT <include refid="BaseColumnList"/> FROM user_account WHERE id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="findAll" resultType="com.hongzhen.hera.data.UserAccount">
|
|
|
|
|
SELECT <include refid="BaseColumnList"/>
|
|
|
|
|
FROM user_account
|
|
|
|
|
ORDER BY id DESC
|
|
|
|
|
LIMIT #{offset}, #{limit}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
INSERT INTO user_account (
|
|
|
|
|
username, nickname, password_hash, mobile, email, nfc_uid, wechat_openid, wechat_unionid,
|
|
|
|
|
status, register_country_code, register_region_code, register_city, register_timezone
|
|
|
|
|
) VALUES (
|
|
|
|
|
#{username}, #{nickname}, #{passwordHash}, #{mobile}, #{email}, #{nfcUid}, #{wechatOpenid},
|
|
|
|
|
#{wechatUnionid}, COALESCE(#{status}, 1), #{registerCountryCode}, #{registerRegionCode},
|
|
|
|
|
#{registerCity}, #{registerTimezone}
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="update">
|
|
|
|
|
UPDATE user_account
|
|
|
|
|
SET username = #{username},
|
|
|
|
|
nickname = #{nickname},
|
|
|
|
|
password_hash = COALESCE(#{passwordHash}, password_hash),
|
|
|
|
|
mobile = #{mobile},
|
|
|
|
|
email = #{email},
|
|
|
|
|
nfc_uid = #{nfcUid},
|
|
|
|
|
wechat_openid = #{wechatOpenid},
|
|
|
|
|
wechat_unionid = #{wechatUnionid},
|
|
|
|
|
status = COALESCE(#{status}, status),
|
|
|
|
|
register_country_code = #{registerCountryCode},
|
|
|
|
|
register_region_code = #{registerRegionCode},
|
|
|
|
|
register_city = #{registerCity},
|
|
|
|
|
register_timezone = #{registerTimezone}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteById">DELETE FROM user_account WHERE id = #{id}</delete>
|
|
|
|
|
</mapper>
|