Refactor user account management by replacing User entity with UserAccount, updating UserController and UserService for CRUD operations, and modifying MyBatis mappers accordingly.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,39 +0,0 @@
|
||||
<?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.gameplatform.server.mapper.UserMapper">
|
||||
|
||||
<resultMap id="UserResultMap" type="com.gameplatform.server.model.User">
|
||||
<id property="id" column="id" />
|
||||
<result property="username" column="username" />
|
||||
<result property="email" column="email" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, username, email, created_at
|
||||
</sql>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="UserResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM users
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="UserResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM users
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.User" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO users (username, email, created_at)
|
||||
VALUES (#{username}, #{email}, NOW())
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="long">
|
||||
DELETE FROM users WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -28,4 +28,61 @@
|
||||
WHERE username = #{username}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="UserAccountMap">
|
||||
SELECT id, user_type, username, display_name, password_hash, role, status, points_balance, created_at, updated_at
|
||||
FROM user_account
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.account.UserAccount" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO user_account (user_type, username, display_name, password_hash, role, status, points_balance)
|
||||
VALUES (#{userType}, #{username}, #{displayName}, #{passwordHash}, #{role}, #{status}, #{pointsBalance})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.gameplatform.server.model.entity.account.UserAccount">
|
||||
UPDATE user_account
|
||||
<set>
|
||||
<if test="displayName != null">display_name = #{displayName},</if>
|
||||
<if test="role != null">role = #{role},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="setStatus">
|
||||
UPDATE user_account SET status = #{status} WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updatePassword">
|
||||
UPDATE user_account SET password_hash = #{passwordHash} WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1) FROM user_account
|
||||
<where>
|
||||
<if test="userType != null and userType != ''">AND user_type = #{userType}</if>
|
||||
<if test="status != null and status != ''">AND status = #{status}</if>
|
||||
<if test="role != null and role != ''">AND role = #{role}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (username LIKE CONCAT('%', #{keyword}, '%') OR display_name LIKE CONCAT('%', #{keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="listByFilter" resultMap="UserAccountMap">
|
||||
SELECT id, user_type, username, display_name, password_hash, role, status, points_balance, created_at, updated_at
|
||||
FROM user_account
|
||||
<where>
|
||||
<if test="userType != null and userType != ''">AND user_type = #{userType}</if>
|
||||
<if test="status != null and status != ''">AND status = #{status}</if>
|
||||
<if test="role != null and role != ''">AND role = #{role}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (username LIKE CONCAT('%', #{keyword}, '%') OR display_name LIKE CONCAT('%', #{keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY id DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user