Commit 04e80373 by Suvalue

数据库切换到mysql后的优化

parent c4e21bbb
<?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.bsoft.admin.mapper.DicOrgMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.DicOrg">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="ORG_CODE" jdbcType="VARCHAR" property="orgCode" />
<result column="ORG_NAME" jdbcType="VARCHAR" property="orgName" />
<result column="ORG_NO" jdbcType="VARCHAR" property="orgNo" />
<result column="ORG_SHORT_NAME" jdbcType="VARCHAR" property="orgShortName" />
<result column="ORG_GROUP" jdbcType="VARCHAR" property="orgGroup" />
<result column="ORG_TYPE" jdbcType="VARCHAR" property="orgType" />
<result column="ORG_ADDRESS" jdbcType="VARCHAR" property="orgAddress" />
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
</resultMap>
<resultMap id="DicOrgResultMap" extends="BaseResultMap" type="com.bsoft.admin.model.respmodel.DicOrgList" />
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from dic_org
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.DicOrg">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into dic_org (CREATE_DATE, CREATE_USERID, `STATE`,
ORG_CODE, ORG_NAME, ORG_NO,
ORG_SHORT_NAME, ORG_GROUP, ORG_TYPE,
ORG_ADDRESS, PARENT_ID)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{orgCode,jdbcType=VARCHAR}, #{orgName,jdbcType=VARCHAR}, #{orgNo,jdbcType=VARCHAR},
#{orgShortName,jdbcType=VARCHAR}, #{orgGroup,jdbcType=VARCHAR}, #{orgType,jdbcType=VARCHAR},
#{orgAddress,jdbcType=VARCHAR}, #{parentId,jdbcType=DECIMAL})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.DicOrg">
update dic_org
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
ORG_CODE = #{orgCode,jdbcType=VARCHAR},
ORG_NAME = #{orgName,jdbcType=VARCHAR},
ORG_NO = #{orgNo,jdbcType=VARCHAR},
ORG_SHORT_NAME = #{orgShortName,jdbcType=VARCHAR},
ORG_GROUP = #{orgGroup,jdbcType=VARCHAR},
ORG_TYPE = #{orgType,jdbcType=VARCHAR},
ORG_ADDRESS = #{orgAddress,jdbcType=VARCHAR},
PARENT_ID = #{parentId,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, ORG_CODE, ORG_NAME, ORG_NO, ORG_SHORT_NAME,
ORG_GROUP, ORG_TYPE, ORG_ADDRESS, PARENT_ID
from dic_org
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectParentAll" resultMap="DicOrgResultMap">
select ID, CREATE_DATE, CREATE_USERID, "STATE", ORG_CODE, ORG_NAME, ORG_NO, ORG_SHORT_NAME,
ORG_GROUP, ORG_TYPE, ORG_ADDRESS, PARENT_ID
from DIC_ORG
where "STATE"=1
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, ORG_CODE, ORG_NAME, ORG_NO, ORG_SHORT_NAME,
ORG_GROUP, ORG_TYPE, ORG_ADDRESS, PARENT_ID
from dic_org
</select>
<select id="selectByUser" resultMap="BaseResultMap">
SELECT o.*
FROM SYS_USER_ORG_RS uor,DIC_ORG o
where uor.ORG_ID=o.ID and uor.USER_ID= #{userId,jdbcType=DECIMAL}
and o.`STATE`=1 and uor."STATE"=1
</select>
<select id="selectByName" resultMap="BaseResultMap">
select * from DIC_ORG where ORG_NAME=#{orgName,jdbcType=VARCHAR} and `STATE`=1
</select>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysMenuMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysMenu">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATA" jdbcType="TIMESTAMP" property="createData" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="MENU_NAME" jdbcType="VARCHAR" property="menuName" />
<result column="MENU_URL" jdbcType="VARCHAR" property="menuUrl" />
<result column="MENU_IMAGE" jdbcType="VARCHAR" property="menuImage" />
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
<result column="PAGE_CODE" jdbcType="VARCHAR" property="pageCode" />
<result column="SORT" jdbcType="DECIMAL" property="sort" />
</resultMap>
<resultMap id="sysMenuResultMap" type="com.bsoft.admin.model.respmodel.SysMenuList" extends="BaseResultMap"/>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_menu
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysMenu">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_menu (CREATE_DATA, CREATE_USERID, `STATE`,
MENU_NAME, MENU_URL, MENU_IMAGE,
PARENT_ID, PAGE_CODE, SORT
)
values (#{createData,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{menuName,jdbcType=VARCHAR}, #{menuUrl,jdbcType=VARCHAR}, #{menuImage,jdbcType=VARCHAR},
#{parentId,jdbcType=DECIMAL}, #{pageCode,jdbcType=VARCHAR}, #{sort,jdbcType=DECIMAL}
)
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysMenu">
update sys_menu
set CREATE_DATA = #{createData,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
MENU_NAME = #{menuName,jdbcType=VARCHAR},
MENU_URL = #{menuUrl,jdbcType=VARCHAR},
MENU_IMAGE = #{menuImage,jdbcType=VARCHAR},
PARENT_ID = #{parentId,jdbcType=DECIMAL},
PAGE_CODE = #{pageCode,jdbcType=VARCHAR},
SORT = #{sort,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATA, CREATE_USERID, `STATE`, MENU_NAME, MENU_URL, MENU_IMAGE,
PARENT_ID, PAGE_CODE, SORT
from sys_menu
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATA, CREATE_USERID, `STATE`, MENU_NAME, MENU_URL, MENU_IMAGE,
PARENT_ID, PAGE_CODE, SORT
from sys_menu
</select>
<select id="selectParentAll" resultMap="sysMenuResultMap">
select ID, CREATE_DATA, CREATE_USERID, "STATE", MENU_NAME, MENU_URL, MENU_IMAGE,
PARENT_ID, PAGE_CODE, SORT
from SYS_MENU
where "STATE"=1
</select>
<select id="selectMenuAllByUser" resultMap="sysMenuResultMap">
select DISTINCT m.ID,m.MENU_NAME,m.MENU_URL,m.MENU_IMAGE,m.PARENT_ID,m.PAGE_CODE,m.SORT,umr.STATE
from
SYS_USER_MENU_RS umr
LEFT JOIN
SYS_MENU m on umr.MENU_ID = m.ID
where m.STATE=1 and umr.USER_ID = #{userId,jdbcType=DECIMAL}
</select>
<select id="selectMenuByRole" resultMap="sysMenuResultMap">
select DISTINCT m.ID,m.MENU_NAME,m.MENU_URL,m.MENU_IMAGE,m.PARENT_ID,m.PAGE_CODE,m.SORT,rmr.STATE
from
SYS_ROLE_MENU_RS rmr
LEFT JOIN
SYS_MENU m on rmr.MENU_ID = m.ID
LEFT JOIN
SYS_USER_ROLE_RS urr on rmr.ROLE_ID = urr.Role_ID
where rmr.STATE=1 and m.STATE=1 and urr.STATE=1 and urr.USER_ID = #{userId,jdbcType=DECIMAL}
</select>
<select id="selectMaxSort" resultType="java.lang.Integer">
select nvl(MAX(SORT),0) AS SORT
from SYS_MENU
where PARENT_ID=#{parentId,jdbcType=DECIMAL}
</select>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysRoleMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysRole">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName" />
<result column="ROLE_CODE" jdbcType="DECIMAL" property="roleCode" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_role
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysRole">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_role (CREATE_DATE, CREATE_USERID, `STATE`,
ROLE_NAME, ROLE_CODE)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{roleName,jdbcType=VARCHAR}, #{roleCode,jdbcType=DECIMAL})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysRole">
update sys_role
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
ROLE_NAME = #{roleName,jdbcType=VARCHAR},
ROLE_CODE = #{roleCode,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, ROLE_NAME, ROLE_CODE
from sys_role
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, ROLE_NAME, ROLE_CODE
from sys_role
</select>
<select id="selectRoleByUser" resultMap="BaseResultMap">
select r.*
from SYS_USER_ROLE_RS rs,SYS_ROLE r
where USER_ID=#{userId,jdbcType=DECIMAL} and rs.ROLE_ID=r.ID
and rs.STATE!=0 and r.STATE!=0
</select>
<select id="selectByCode" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, ROLE_NAME, ROLE_CODE
from SYS_ROLE
where ROLE_CODE = #{roleCode,jdbcType=DECIMAL} and `STATE`!=0
</select>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysRoleMenuRsMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysRoleMenuRs">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="MENU_ID" jdbcType="DECIMAL" property="menuId" />
<result column="ROLE_ID" jdbcType="DECIMAL" property="roleId" />
</resultMap>
<resultMap id="SysRoleMenuRsList" extends="BaseResultMap" type="com.bsoft.admin.model.respmodel.SysRoleMenuRsList">
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_role_menu_rs
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysRoleMenuRs">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_role_menu_rs (CREATE_DATE, CREATE_USERID, `STATE`,
MENU_ID, ROLE_ID)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{menuId,jdbcType=DECIMAL}, #{roleId,jdbcType=DECIMAL})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysRoleMenuRs">
update sys_role_menu_rs
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
MENU_ID = #{menuId,jdbcType=DECIMAL},
ROLE_ID = #{roleId,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, MENU_ID, ROLE_ID
from sys_role_menu_rs
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, MENU_ID, ROLE_ID
from sys_role_menu_rs
</select>
<select id="selectByRole" resultMap="SysRoleMenuRsList">
select MAP.*,m.PARENT_ID
from SYS_ROLE_MENU_RS MAP
join SYS_MENU m on m.ID=MAP.MENU_ID
where MAP."STATE"=1 and MAP.ROLE_ID = #{roleId,jdbcType=DECIMAL}
</select>
<update id="deleteAllByRole">
update SYS_ROLE_MENU_RS set `STATE`=0 where ROLE_ID = #{roleId,jdbcType=DECIMAL}
</update>
<select id="selectByUserWithRole" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, MENU_ID, ROLE_ID
from SYS_ROLE_MENU_RS
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
and MENU_ID=#{menuId,jdbcType=DECIMAL}
</select>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysUserMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysUser">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="USER_CODE" jdbcType="VARCHAR" property="userCode" />
<result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
<result column="PASSWORD" jdbcType="VARCHAR" property="password" />
<result column="IDCARD" jdbcType="VARCHAR" property="idcard" />
<result column="SEX" jdbcType="VARCHAR" property="sex" />
<result column="MOBILE" jdbcType="VARCHAR" property="mobile" />
<result column="PAGE_COUNT" jdbcType="DECIMAL" property="pageCount" />
<result column="ERROR_COUNT" jdbcType="DECIMAL" property="errorCount" />
<result column="ERROR_TIME" jdbcType="TIMESTAMP" property="errorTime" />
<result column="LAST_TIME" jdbcType="TIMESTAMP" property="lastTime" />
<result column="LAST_IP" jdbcType="VARCHAR" property="lastIp" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_user
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysUser">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_user (CREATE_DATE, CREATE_USERID, `STATE`,
USER_CODE, USER_NAME, `PASSWORD`,
IDCARD, SEX, MOBILE,
PAGE_COUNT, ERROR_COUNT, ERROR_TIME,
LAST_TIME, LAST_IP)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{userCode,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{idcard,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{pageCount,jdbcType=DECIMAL}, #{errorCount,jdbcType=DECIMAL}, #{errorTime,jdbcType=TIMESTAMP},
#{lastTime,jdbcType=TIMESTAMP}, #{lastIp,jdbcType=VARCHAR})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysUser">
update sys_user
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
USER_CODE = #{userCode,jdbcType=VARCHAR},
USER_NAME = #{userName,jdbcType=VARCHAR},
`PASSWORD` = #{password,jdbcType=VARCHAR},
IDCARD = #{idcard,jdbcType=VARCHAR},
SEX = #{sex,jdbcType=VARCHAR},
MOBILE = #{mobile,jdbcType=VARCHAR},
PAGE_COUNT = #{pageCount,jdbcType=DECIMAL},
ERROR_COUNT = #{errorCount,jdbcType=DECIMAL},
ERROR_TIME = #{errorTime,jdbcType=TIMESTAMP},
LAST_TIME = #{lastTime,jdbcType=TIMESTAMP},
LAST_IP = #{lastIp,jdbcType=VARCHAR}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_CODE, USER_NAME, `PASSWORD`,
IDCARD, SEX, MOBILE, PAGE_COUNT, ERROR_COUNT, ERROR_TIME, LAST_TIME, LAST_IP
from sys_user
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_CODE, USER_NAME, `PASSWORD`,
IDCARD, SEX, MOBILE, PAGE_COUNT, ERROR_COUNT, ERROR_TIME, LAST_TIME, LAST_IP
from sys_user
</select>
<select id="selectByCode" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, STATE, USER_CODE, USER_NAME, PASSWORD, IDCARD,
SEX, MOBILE, PAGE_COUNT, ERROR_COUNT, ERROR_TIME, LAST_TIME, LAST_IP
from SYS_USER
where USER_CODE=#{userCode,jdbcType=VARCHAR}
and `STATE` != 0
</select>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysUserMenuRsMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysUserMenuRs">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="USER_ID" jdbcType="DECIMAL" property="userId" />
<result column="MENU_ID" jdbcType="DECIMAL" property="menuId" />
</resultMap>
<resultMap id="SysUserMenuRsList" extends="BaseResultMap" type="com.bsoft.admin.model.respmodel.SysUserMenuRsList">
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_user_menu_rs
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysUserMenuRs">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_user_menu_rs (CREATE_DATE, CREATE_USERID, `STATE`,
USER_ID, MENU_ID)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{userId,jdbcType=DECIMAL}, #{menuId,jdbcType=DECIMAL})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysUserMenuRs">
update sys_user_menu_rs
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
USER_ID = #{userId,jdbcType=DECIMAL},
MENU_ID = #{menuId,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, MENU_ID
from sys_user_menu_rs
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, MENU_ID
from sys_user_menu_rs
</select>
<select id="selectByUser" resultMap="SysUserMenuRsList">
select MAP.*,m.PARENT_ID
from SYS_USER_MENU_RS MAP
join SYS_MENU m on m.ID=MAP.MENU_ID
where MAP.`STATE`=1 and MAP.USER_ID = #{userId,jdbcType=DECIMAL}
</select>
<update id="deleteAllByUser">
update SYS_USER_MENU_RS set `STATE`=0 where USER_ID = #{userId,jdbcType=DECIMAL}
</update>
<select id="selectByUserWithMenu" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, MENU_ID
from SYS_USER_MENU_RS
where USER_ID = #{userId,jdbcType=DECIMAL}
and MENU_ID=#{menuId,jdbcType=DECIMAL}
</select>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysUserOrgRsMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysUserOrgRs">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="USER_ID" jdbcType="DECIMAL" property="userId" />
<result column="ORG_ID" jdbcType="DECIMAL" property="orgId" />
</resultMap>
<resultMap id="SysUserOrgRsList" extends="BaseResultMap" type="com.bsoft.admin.model.respmodel.SysUserOrgRsList">
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_user_org_rs
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysUserOrgRs">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_user_org_rs (CREATE_DATE, CREATE_USERID, `STATE`,
USER_ID, ORG_ID)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{userId,jdbcType=DECIMAL}, #{orgId,jdbcType=DECIMAL})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysUserOrgRs">
update sys_user_org_rs
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
USER_ID = #{userId,jdbcType=DECIMAL},
ORG_ID = #{orgId,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, ORG_ID
from sys_user_org_rs
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, ORG_ID
from sys_user_org_rs
</select>
<select id="selectByUser" resultMap="SysUserOrgRsList">
select map.*,o.PARENT_ID
from SYS_USER_ORG_RS MAP
join DIC_ORG o on o.ID=map.ORG_ID
where MAP."STATE" = 1 and MAP.USER_ID = #{userId,jdbcType=DECIMAL}
</select>
<select id="selectByUserWithOrg" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, ORG_ID
from SYS_USER_ORG_RS
where USER_ID = #{userId,jdbcType=DECIMAL} and ORG_ID=#{orgId,jdbcType=DECIMAL}
</select>
<update id="deleteByUser">
update SYS_USER_ORG_RS
set `STATE` = 0
where USER_ID = #{userId,jdbcType=DECIMAL}
</update>
</mapper>
\ No newline at end of file
<?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.bsoft.admin.mapper.SysUserRoleRsMapper">
<resultMap id="BaseResultMap" type="com.bsoft.admin.model.SysUserRoleRs">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="USER_ID" jdbcType="DECIMAL" property="userId" />
<result column="ROLE_ID" jdbcType="DECIMAL" property="roleId" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_user_role_rs
where ID = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.bsoft.admin.model.SysUserRoleRs">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_user_role_rs (CREATE_DATE, CREATE_USERID, `STATE`,
USER_ID, ROLE_ID)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{userId,jdbcType=DECIMAL}, #{roleId,jdbcType=DECIMAL})
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.admin.model.SysUserRoleRs">
update sys_user_role_rs
set CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
`STATE` = #{state,jdbcType=DECIMAL},
USER_ID = #{userId,jdbcType=DECIMAL},
ROLE_ID = #{roleId,jdbcType=DECIMAL}
where ID = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, ROLE_ID
from sys_user_role_rs
where ID = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, ROLE_ID
from sys_user_role_rs
</select>
<update id="deleteByUser">
update SYS_USER_ROLE_RS
set `STATE` = 0
where USER_ID = #{userId,jdbcType=DECIMAL}
</update>
<select id="selectByUser" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, USER_ID, ROLE_ID
from SYS_USER_ROLE_RS
where USER_ID = #{userId,jdbcType=DECIMAL}
and ROLE_ID = #{roleId,jdbcType=DECIMAL}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment