|
@@ -74,61 +74,100 @@
|
|
|
</if>
|
|
|
</sql>
|
|
|
|
|
|
- <sql id="selectPersonAndWorkResumeInfo">
|
|
|
- select p.id as id,
|
|
|
- p.name as name,
|
|
|
- p.profession as profession,
|
|
|
- p.account_id as account_id,
|
|
|
- p.person_type as person_type,
|
|
|
- p.username as username,
|
|
|
- w.is_leader as is_leader
|
|
|
- from person p,
|
|
|
- work_resume w
|
|
|
+ <sql id="personColumns">
|
|
|
+ p.id as id,
|
|
|
+ p.name as name,
|
|
|
+ p.profession as profession,
|
|
|
+ p.account_id as account_id,
|
|
|
+ p.person_type as person_type,
|
|
|
+ p.username as username,
|
|
|
+ p.name_pinyin as name_pinyin
|
|
|
</sql>
|
|
|
|
|
|
- <sql id="orderBy">
|
|
|
- order by
|
|
|
- <if test="depId != null and depId != ''">
|
|
|
- if(w.dep_id=#{depId} and w.is_leader="1", 0, 1),
|
|
|
- </if>
|
|
|
- p.name_pinyin
|
|
|
+ <sql id="selectPersonAndWorkResumeInfo">
|
|
|
+ select
|
|
|
+ <include refid="personColumns"/>
|
|
|
+ from person p,
|
|
|
+ work_resume w
|
|
|
</sql>
|
|
|
|
|
|
- <sql id="orderByNamePinyin">
|
|
|
- order by p.name_pinyin
|
|
|
+ <sql id="selectPersonAndWorkResumeInfoSingleDep">
|
|
|
+ select
|
|
|
+ <include refid="personColumns"/>,
|
|
|
+ if(w.dep_id = #{depId} and w.is_leader = '1', 0, 1) as is_leader
|
|
|
+ from person p,
|
|
|
+ work_resume w
|
|
|
</sql>
|
|
|
|
|
|
<sql id="queryPersonListByNameOrUserNameSql">
|
|
|
- <include refid="queryPersonInfo">
|
|
|
- <property name="queryExpression" value="queryPersonByNameOrUsernameExpression"/>
|
|
|
- <property name="orderBy" value="orderBy"/>
|
|
|
- </include>
|
|
|
+ <choose>
|
|
|
+ <when test="depId != null and depId != ''">
|
|
|
+ <include refid="queryPersonInfoSingleDep">
|
|
|
+ <property name="queryExpression" value="queryPersonByNameOrUsernameExpression"/>
|
|
|
+ </include>
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ <include refid="queryPersonInfo">
|
|
|
+ <property name="queryExpression" value="queryPersonByNameOrUsernameExpression"/>
|
|
|
+ </include>
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
</sql>
|
|
|
<sql id="queryPersonListSql">
|
|
|
- <include refid="queryPersonInfo">
|
|
|
- <property name="queryExpression" value="queryPersonWhereExpression"/>
|
|
|
- <property name="orderBy" value="orderBy"/>
|
|
|
- </include>
|
|
|
+ <choose>
|
|
|
+ <when test="depId != null and depId != ''">
|
|
|
+ <include refid="queryPersonInfoSingleDep">
|
|
|
+ <property name="queryExpression" value="queryPersonByNameOrUsernameExpression"/>
|
|
|
+ </include>
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ <include refid="queryPersonInfo">
|
|
|
+ <property name="queryExpression" value="queryPersonWhereExpression"/>
|
|
|
+ </include>
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
</sql>
|
|
|
<sql id="queryPersonListByDepIdsSql">
|
|
|
<include refid="queryPersonInfo">
|
|
|
<property name="queryExpression" value="queryPersonByDepIdsWhereExpression"/>
|
|
|
- <property name="orderBy" value="orderByNamePinyin"/>
|
|
|
</include>
|
|
|
</sql>
|
|
|
|
|
|
<sql id="queryPersonInfo">
|
|
|
- select max(pw.id) as id,
|
|
|
+ select * from (
|
|
|
+ select
|
|
|
+ <include refid="personWorkResumeColumns"/>
|
|
|
+ from (
|
|
|
+ <include refid="selectPersonAndWorkResumeInfo"/>
|
|
|
+ <include refid="${queryExpression}"/>
|
|
|
+ ) as pw group by pw.id
|
|
|
+ ) result order by
|
|
|
+ result.name_pinyin
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="personWorkResumeColumns">
|
|
|
+ max(pw.id) as id,
|
|
|
pw.name as name,
|
|
|
pw.profession as profession,
|
|
|
pw.account_id as account_id,
|
|
|
pw.person_type as person_type,
|
|
|
- pw.username as username from (
|
|
|
- <include refid="selectPersonAndWorkResumeInfo"/>
|
|
|
- <include refid="${queryExpression}"/>
|
|
|
- <include refid="${orderBy}"/>) as pw group by pw.id
|
|
|
+ pw.username as username,
|
|
|
+ pw.name_pinyin as name_pinyin
|
|
|
</sql>
|
|
|
|
|
|
+ <sql id="queryPersonInfoSingleDep">
|
|
|
+ select * from (
|
|
|
+ select
|
|
|
+ <include refid="personWorkResumeColumns"/>,
|
|
|
+ any_value(pw.is_leader) as is_leader
|
|
|
+ from (
|
|
|
+ <include refid="selectPersonAndWorkResumeInfoSingleDep"/>
|
|
|
+ <include refid="${queryExpression}"/>
|
|
|
+ ) as pw group by pw.id
|
|
|
+ ) result order by
|
|
|
+ result.is_leader,
|
|
|
+ result.name_pinyin
|
|
|
+ </sql>
|
|
|
|
|
|
<select id="queryPersonListByNameOrUserName"
|
|
|
parameterType="com.persagy.fm.person.model.dto.PageQueryPersonByNameOrUserNameDTO"
|