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,52 @@
|
||||
<?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.user.UserMapper">
|
||||
|
||||
<sql id="BaseColumnList">
|
||||
id, open_id, union_id, phone, avatar_url, nickname, gender, birthday, birth_hour,
|
||||
province, city, district, points, pinned_daily_card_id, profile_edit_count, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
<select id="findById" resultType="com.hongzhen.hera.user.User">
|
||||
SELECT <include refid="BaseColumnList"/>
|
||||
FROM hera_user
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByOpenId" resultType="com.hongzhen.hera.user.User">
|
||||
SELECT <include refid="BaseColumnList"/>
|
||||
FROM hera_user
|
||||
WHERE open_id = #{openId}
|
||||
</select>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO hera_user (
|
||||
open_id, union_id, phone, avatar_url, nickname, gender, birthday, birth_hour,
|
||||
province, city, district, points, pinned_daily_card_id, profile_edit_count, created_at, updated_at
|
||||
) VALUES (
|
||||
#{openId}, #{unionId}, #{phone}, #{avatarUrl}, #{nickname}, #{gender}, #{birthday}, #{birthHour},
|
||||
#{province}, #{city}, #{district}, #{points}, #{pinnedDailyCardId}, #{profileEditCount},
|
||||
#{createdAt}, #{updatedAt}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE hera_user
|
||||
SET union_id = #{unionId},
|
||||
phone = #{phone},
|
||||
avatar_url = #{avatarUrl},
|
||||
nickname = #{nickname},
|
||||
gender = #{gender},
|
||||
birthday = #{birthday},
|
||||
birth_hour = #{birthHour},
|
||||
province = #{province},
|
||||
city = #{city},
|
||||
district = #{district},
|
||||
points = #{points},
|
||||
pinned_daily_card_id = #{pinnedDailyCardId},
|
||||
profile_edit_count = #{profileEditCount},
|
||||
updated_at = #{updatedAt}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user