<?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.rymcu.forest.mapper.RoleMapper">
    <resultMap id="BaseResultMap" type="com.rymcu.forest.entity.Role">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="idRole"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="input_code" jdbcType="VARCHAR" property="inputCode"/>
        <result column="weights" jdbcType="TINYINT" property="weights"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
    </resultMap>
    <update id="updateStatus">
        update forest_role set status = #{status},updated_time = sysdate() where id = #{idRole}
    </update>
    <update id="update">
        update forest_role set name = #{name}, input_code = #{inputCode}, weights = #{weights}, updated_time = sysdate() where id = #{idRole}
    </update>

    <select id="selectRoleByIdUser" resultMap="BaseResultMap">
        select sr.* from forest_user_role sur left join forest_role sr on sur.id_role = sr.id where id_user = #{id}
    </select>
    <select id="selectRoleByInputCode" resultMap="BaseResultMap">
        select * from forest_role where input_code = #{inputCode}
    </select>

</mapper>