feat: add MyBatis CRUD and database integration
This commit is contained in:
1 parent
4222b7124c
commit
8a97a0b054
67 files changed
+2597
-102
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?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>
|
||||
|
||||
<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>
|
||||
Reference in new issue
Block a user