<?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.muchinfo.mtp3interface.mapper.IArearolemarketMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.muchinfo.mtp3pojos.entity.Arearolemarket">
        <id column="AREAUSERID" property="areauserid" />
        <result column="ROLETYPE" property="roletype" />
        <result column="MARKETID" property="marketid" />
        <result column="MODIFYTIME" property="modifytime" />
        <result column="MODIFIERID" property="modifierid" />
        <result column="SPOTRIGHTTYPE" property="spotrighttype" />
        <result column="BUYSPOTRIGHTTYPE" property="buyspotrighttype" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        AREAUSERID, ROLETYPE, MARKETID, MODIFYTIME, MODIFIERID, SPOTRIGHTTYPE, BUYSPOTRIGHTTYPE
    </sql>

    <delete id="deleteOperateGoodsConfig" parameterType="java.lang.Long">
        delete from AreaGoodsConfig t
        where roletype = 2 and userid = #{userid}
    </delete>

    <select id="getMarketsNameByUseridAndrole" parameterType="map"
            resultType="java.lang.Long">
        select m.marketid
        from market m ,arearolemarket o
        where m.marketid = o.marketid and o.areauserid = #{areauserid}
        and m.marketstatus = 2
        and roletype in
        <foreach collection="types" close=")" open="(" separator="," item="item">
            #{item}
        </foreach>
    </select>

    <insert id="insertOperateGoodsConfigBatch" parameterType="java.util.List">
        begin
        <foreach collection="list" item="vo" separator="">
            insert into AreaGoodsConfig (userid, roletype, goodsid)
            values (#{vo.userid},#{vo.roletype},#{vo.goodsid});
        </foreach>
        commit;
        end;
    </insert>
</mapper>
