gan/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppUserMapper.xml

346 lines
18 KiB
XML

<?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.ruoyi.app.mapper.AppUserMapper">
<resultMap type="AppUser" id="AppUserResult">
<result property="id" column="id" />
<result property="username" column="username" />
<result property="password" column="password" />
<result property="nickname" column="nickname" />
<result property="email" column="email" />
<result property="phone" column="phone" />
<result property="address" column="address" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="avatarUrl" column="avatar_url" />
<result property="education" column="education" />
<result property="school" column="school" />
<result property="major" column="major" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="experience" column="experience" />
<result property="companyName" column="company_name" />
<result property="industry" column="industry" />
<result property="jobTime" column="job_time" />
<result property="jobName" column="job_name" />
<result property="jobType" column="job_type" />
<result property="skillId" column="skill_id" />
<result property="jobContent" column="job_content" />
<result property="type" column="type" />
<result property="sex" column="sex" />
<result property="birthday" column="birthday" />
<result property="shareResource" column="share_resource" />
<result property="isTech" column="is_tech" />
<result property="idea" column="idea" />
<result property="isPartner" column="is_partner" />
<result property="hobby" column="hobby" />
<result property="city" column="city" />
<result property="other" column="other" />
<result property="isMember" column="is_member" />
<result property="orderId" column="order_id" />
<result property="orderStartTime" column="order_start_time" />
<result property="orderEndTime" column="order_end_time" />
</resultMap>
<sql id="appUserColumns">
a.id as "id",
a.username as "username",
a.password as "password",
a.nickname as "nickname",
a.email as "email",
a.phone as "phone",
a.address as "address",
a.create_time as "createTime",
a.update_time as "updateTime",
a.avatar_url as "avatarUrl",
a.education as "education",
a.school as "school",
a.major as "major",
a.start_time as "startTime",
a.end_time as "endTime",
a.experience as "experience",
a.company_name as "companyName",
a.industry as "industry",
a.job_time as "jobTime",
a.job_name as "jobName",
a.job_type as "jobType",
a.skill_id as "skillId",
a.job_content as "jobContent",
a.type as "type",
a.sex as "sex",
a.birthday as "birthday",
a.share_resource as "shareResource",
a.is_tech as "isTech",
a.idea as "idea",
a.is_partner as "isPartner",
a.hobby as "hobby",
a.other as "other",
a.is_member as "isMember",
a.order_id as "orderId",
a.order_start_time as "orderStartTime",
a.order_end_time as "orderEndTime"
</sql>
<sql id="selectAppUserVo">
select id, username, password, nickname, email, phone, address, create_time, update_time, avatar_url, education, school, major, start_time, end_time, experience, company_name, industry, job_time, job_name, job_type, skill_id, job_content, type,is_member,
order_id, order_start_time, order_end_time from app_user
</sql>
<select id="selectAppUserList" parameterType="AppUser" resultMap="AppUserResult">
<include refid="selectAppUserVo"/>
<where>
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="nickname != null and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
<if test="email != null and email != ''"> and email = #{email}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="avatarUrl != null and avatarUrl != ''"> and avatar_url = #{avatarUrl}</if>
<if test="education != null and education != ''"> and education = #{education}</if>
<if test="school != null and school != ''"> and school = #{school}</if>
<if test="major != null and major != ''"> and major = #{major}</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="experience != null and experience != ''"> and experience = #{experience}</if>
<if test="companyName != null and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
<if test="industry != null and industry != ''"> and industry = #{industry}</if>
<if test="jobTime != null "> and job_time = #{jobTime}</if>
<if test="jobName != null and jobName != ''"> and job_name like concat('%', #{jobName}, '%')</if>
<if test="jobType != null and jobType != ''"> and job_type = #{jobType}</if>
<if test="skillId != null and skillId != ''"> and skill_id = #{skillId}</if>
<if test="jobContent != null and jobContent != ''"> and job_content = #{jobContent}</if>
<if test="type != null "> and type = #{type}</if>
<if test="sex != null "> and sex = #{sex}</if>
<if test="birthday != null "> and birthday = #{birthday}</if>
<if test="shareResource != null and shareResource != ''"> and share_resource = #{shareResource}</if>
<if test="isTech != null "> and is_tech = #{isTech}</if>
<if test="idea != null and idea != ''"> and idea = #{idea}</if>
<if test="isPartner != null "> and is_partner = #{isPartner}</if>
<if test="hobby != null and hobby != ''"> and hobby = #{hobby}</if>
<if test="city != null and city != ''"> and city = #{city}</if>
<if test="other != null and other != ''"> and other = #{other}</if>
<if test="isMember != null "> and is_member = #{isMember}</if>
<if test="orderId != null "> and order_id = #{orderId}</if>
<if test="orderStartTime != null "> and order_start_time = #{orderStartTime}</if>
<if test="orderEndTime != null "> and order_end_time = #{orderEndTime}</if>
</where>
</select>
<select id="selectAppUserById" parameterType="Long" resultType="com.ruoyi.app.domain.vo.AppUserVo">
select
<include refid="appUserColumns"/>,
s.name as "schoolName",
t.name as "cityName",
a.id as "userId",
count(DISTINCT(r.id)) as "friendNum",
count(DISTINCT(l.id)) as "likeNum",
count(DISTINCT(f.id)) as "attentionNum",
count(DISTINCT(fa.id)) as "fansNum"
from app_user a
left join app_school s on s.id = a.school
left join app_user_fans f on f.user_id = a.id
left join app_user_fans fa on fa.friend_id = a.id
left join app_user_friend r on r.user_id = a.id
left join app_dynamic_like l on l.dynamic_user_id = a.id
left join app_town t on t.id = a.address
where a.id = #{id}
group by a.id
</select>
<select id="listUser" parameterType="AppUser" resultType="com.ruoyi.app.domain.vo.AppUserInfoVo">
select
<include refid="appUserColumns"/>
from app_user a
<where>
<if test="ids != null and ids.size()"> a.id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectList" parameterType="AppUser" resultType="com.ruoyi.app.domain.vo.AppUserDataVo">
select
<include refid="appUserColumns"/>,
s.name as "schoolName",
count(f.user_id) as "fansNum"
from app_user a
left join app_school s on s.id = a.school
left join app_user_fans f on f.user_id = a.id
<where>
<if test="isMember != null "> and a.is_member = #{isMember}</if>
<if test="appId != null "> and a.id != #{appId}</if>
<if test="school != null and school != ''"> and a.school = #{school}</if>
<if test="companyName != null and companyName != ''"> and a.company_name like concat('%', #{companyName}, '%')</if>
<if test="ids != null and ids.size()"> and a.id not in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="friendIds != null and friendIds.size() > 0"> and a.id in
<foreach collection="friendIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
group by a.id
</select>
<select id="listByOrderTime" resultType="java.lang.Long">
select
a.id
from app_user a
<where>
a.is_member = 0
and a.order_end_time &gt; now()
</where>
</select>
<update id="updateAppUserById" parameterType="java.lang.Long">
update app_user set is_member = 1,update_time = now()
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<insert id="insertAppUser" parameterType="AppUser" useGeneratedKeys="true" keyProperty="id">
insert into app_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="username != null">username,</if>
<if test="password != null">password,</if>
<if test="nickname != null">nickname,</if>
<if test="email != null">email,</if>
<if test="phone != null">phone,</if>
<if test="address != null">address,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="avatarUrl != null">avatar_url,</if>
<if test="education != null">education,</if>
<if test="school != null">school,</if>
<if test="major != null">major,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="experience != null">experience,</if>
<if test="companyName != null">company_name,</if>
<if test="industry != null">industry,</if>
<if test="jobTime != null">job_time,</if>
<if test="jobName != null">job_name,</if>
<if test="jobType != null">job_type,</if>
<if test="skillId != null">skill_id,</if>
<if test="jobContent != null">job_content,</if>
<if test="type != null">type,</if>
<if test="sex != null">sex,</if>
<if test="birthday != null">birthday,</if>
<if test="shareResource != null">share_resource,</if>
<if test="isTech != null">is_tech,</if>
<if test="idea != null">idea,</if>
<if test="isPartner != null">is_partner,</if>
<if test="hobby != null">hobby,</if>
<if test="city != null">city,</if>
<if test="other != null">other,</if>
<if test="isMember != null">is_member,</if>
<if test="orderId != null">order_id,</if>
<if test="orderStartTime != null">order_start_time,</if>
<if test="orderEndTime != null">order_end_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="nickname != null">#{nickname},</if>
<if test="email != null">#{email},</if>
<if test="phone != null">#{phone},</if>
<if test="address != null">#{address},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="avatarUrl != null">#{avatarUrl},</if>
<if test="education != null">#{education},</if>
<if test="school != null">#{school},</if>
<if test="major != null">#{major},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="experience != null">#{experience},</if>
<if test="companyName != null">#{companyName},</if>
<if test="industry != null">#{industry},</if>
<if test="jobTime != null">#{jobTime},</if>
<if test="jobName != null">#{jobName},</if>
<if test="jobType != null">#{jobType},</if>
<if test="skillId != null">#{skillId},</if>
<if test="jobContent != null">#{jobContent},</if>
<if test="type != null">#{type},</if>
<if test="sex != null">#{sex},</if>
<if test="birthday != null">#{birthday},</if>
<if test="shareResource != null">#{shareResource},</if>
<if test="isTech != null">#{isTech},</if>
<if test="idea != null">#{idea},</if>
<if test="isPartner != null">#{isPartner},</if>
<if test="hobby != null">#{hobby},</if>
<if test="city != null">#{city},</if>
<if test="other != null">#{other},</if>
<if test="isMember != null">#{isMember},</if>
<if test="orderId != null">#{orderId},</if>
<if test="orderStartTime != null">#{orderStartTime},</if>
<if test="orderEndTime != null">#{orderEndTime},</if>
</trim>
</insert>
<update id="updateAppUser" parameterType="AppUser">
update app_user
<trim prefix="SET" suffixOverrides=",">
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="nickname != null">nickname = #{nickname},</if>
<if test="email != null">email = #{email},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="address != null">address = #{address},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="avatarUrl != null">avatar_url = #{avatarUrl},</if>
<if test="education != null">education = #{education},</if>
<if test="school != null">school = #{school},</if>
<if test="major != null">major = #{major},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="experience != null">experience = #{experience},</if>
<if test="companyName != null">company_name = #{companyName},</if>
<if test="industry != null">industry = #{industry},</if>
<if test="jobTime != null">job_time = #{jobTime},</if>
<if test="jobName != null">job_name = #{jobName},</if>
<if test="jobType != null">job_type = #{jobType},</if>
<if test="skillId != null">skill_id = #{skillId},</if>
<if test="jobContent != null">job_content = #{jobContent},</if>
<if test="type != null">type = #{type},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="birthday != null">birthday = #{birthday},</if>
<if test="shareResource != null">share_resource = #{shareResource},</if>
<if test="isTech != null">is_tech = #{isTech},</if>
<if test="idea != null">idea = #{idea},</if>
<if test="isPartner != null">is_partner = #{isPartner},</if>
<if test="hobby != null">hobby = #{hobby},</if>
<if test="city != null">city = #{city},</if>
<if test="other != null">other = #{other},</if>
<if test="isMember != null">is_member = #{isMember},</if>
<if test="orderId != null">order_id = #{orderId},</if>
<if test="orderStartTime != null">order_start_time = #{orderStartTime},</if>
<if test="orderEndTime != null">order_end_time = #{orderEndTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAppUserById" parameterType="Long">
delete from app_user where id = #{id}
</delete>
<delete id="deleteAppUserByIds" parameterType="String">
delete from app_user where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectAppUserByPhone" resultType="com.ruoyi.app.domain.AppUser">
<include refid="selectAppUserVo"/> where phone = #{phoneNumber}
</select>
</mapper>