jeestie系统的mybaties配置数据库xml数据库语句,为什么都加a?

Feng火 2015-06-08 11:12:03
jeestie系统的mybaties配置数据库xml数据库语句,为什么都加a? 求解答
代码如下:xml文件名,UserDao.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.thinkgem.jeesite.modules.sys.dao.UserDao">
<sql id="userColumns">
a.id,
a.company_id AS "company.id",
a.office_id AS "office.id",
a.login_name,
a.password,
a.no,
a.name,
a.email,
a.phone,
a.mobile,
a.user_type,
a.login_ip,
a.login_date,
a.remarks,
a.login_flag,
a.photo,
a.create_by AS "createBy.id",
a.create_date,
a.update_by AS "updateBy.id",
a.update_date,
a.del_flag,
c.name AS "company.name",
c.parent_id AS "company.parent.id",
c.parent_ids AS "company.parentIds",
ca.id AS "company.area.id",
ca.name AS "company.area.name",
ca.parent_id AS "company.area.parent.id",
ca.parent_ids AS "company.area.parentIds",
o.name AS "office.name",
o.parent_id AS "office.parent.id",
o.parent_ids AS "office.parentIds",
oa.id AS "office.area.id",
oa.name AS "office.area.name",
oa.parent_id AS "office.area.parent.id",
oa.parent_ids AS "office.area.parentIds",
cu.id AS "company.primaryPerson.id",
cu.name AS "company.primaryPerson.name",
cu2.id AS "company.deputyPerson.id",
cu2.name AS "company.deputyPerson.name",
ou.id AS "office.primaryPerson.id",
ou.name AS "office.primaryPerson.name",
ou2.id AS "office.deputyPerson.id",
ou2.name AS "office.deputyPerson.name"<!-- ,
r.id AS "roleList.id",
r.office_id AS "roleList.office.id",
r.name AS "roleList.name",
r.enname AS "roleList.enname",
r.role_type AS "roleList.roleType",
r.data_scope AS "roleList.dataScope" -->
</sql>

<sql id="userJoins">
JOIN sys_office c ON c.id = a.company_id
JOIN sys_area ca ON ca.id = c.area_id
JOIN sys_office o ON o.id = a.office_id
JOIN sys_area oa ON oa.id = o.area_id
LEFT JOIN sys_user cu ON cu.id = c.primary_person
LEFT JOIN sys_user cu2 ON cu2.id = c.deputy_person
LEFT JOIN sys_user ou ON ou.id = o.primary_person
LEFT JOIN sys_user ou2 ON ou2.id = o.deputy_person<!--
LEFT JOIN sys_user_role ur ON ur.user_id = a.id
LEFT JOIN sys_role r ON r.id = ur.role_id -->
</sql>

<!-- 根据编号获得用户 -->
<select id="get" resultType="User">
SELECT
<include refid="userColumns"/><!-- ,
ro.office_id AS "roleList.officeList.id" -->
FROM sys_user a
<include refid="userJoins"/><!--
LEFT JOIN sys_role_office ro ON ro.role_id = r.id -->
WHERE a.id = #{id}
</select>

<!-- 根据登录名查询用户 -->
<select id="getByLoginName" resultType="User" parameterType="User">
SELECT
<include refid="userColumns"/><!-- ,
ro.office_id AS "roleList.officeList.id" -->
FROM sys_user a
<include refid="userJoins"/><!--
LEFT JOIN sys_role_office ro ON ro.role_id = r.id -->
WHERE a.login_name = #{loginName} AND a.del_flag = #{DEL_FLAG_NORMAL}
</select>

<!-- 分页查询用户信息 -->
<select id="findList" resultType="User">
SELECT
<include refid="userColumns"/>
FROM sys_user a
<include refid="userJoins"/>
<if test="role != null and role.id != null and role.id != ''">
JOIN sys_user_role ur ON ur.user_id = a.id AND ur.role_id = #{role.id}
</if>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
<if test="company != null and company.id != null and company.id != ''">
AND (c.id = #{company.id} OR c.parent_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{company.id}||',%')</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{company.id}, ',%'))</if>
</if>
<if test="office != null and office.id != null and office.id != ''">
AND (o.id = #{office.id} OR o.parent_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{office.id}||',%')</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{office.id}, ',%'))</if>
</if>
<!-- 如果不是超级管理员,则不显示超级管理员用户 -->
<if test="!currentUser.admin">
AND a.id != '1'
</if>
<if test="loginName != null and loginName != ''">
AND a.login_name like
<if test="dbName == 'oracle'">'%'||#{loginName}||'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{loginName}, '%')</if>
</if>
<if test="name != null and name != ''">
AND a.name like
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{name}, '%')</if>
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY c.code, o.code, a.name
</otherwise>
</choose>
</select>

<!-- 根据OfficeId获取用户(树查询用户时用) -->
<select id="findUserByOfficeId" resultType="User" useCache="true">
SELECT
a.id, a.name, a.login_name
FROM sys_user a
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
AND a.office_id = #{office.id}
ORDER BY a.name
</select>

<!-- 查询全部用户 -->
<select id="findAllList" resultType="User">
SELECT
<include refid="userColumns"/>
FROM sys_user a
<include refid="userJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
ORDER BY c.code, o.code, a.name
</select>

</mapper>
...全文
290 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Feng火 2015-06-12
  • 打赏
  • 举报
回复
嗯说的对极了
香蕉猪 2015-06-08
  • 打赏
  • 举报
回复
[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/10.gif] <!-- 根据编号获得用户 --> <select id="get" resultType="User"> SELECT <include refid="userColumns"/><!-- , ro.office_id AS "roleList.officeList.id" --> FROM sys_user a <include refid="userJoins"/><!-- LEFT JOIN sys_role_office ro ON ro.role_id = r.id --> WHERE a.id = #{id} </select> a为sys_user 表的别名。

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧