sqlmap-brand.xml 2.66 KB
<?xml version="1.0" encoding="UTF-8"?>
<sqlMap namespace="brand">
	<select id="getBrandByState">
		SELECT * FROM tbl_brand where state = :state ORDER BY seq DESC LIMIT :offset, :limit
	</select>
	<select id="getBrand">
	   SELECT * FROM tbl_brand
	</select>
    <select id="getBrandTotal">
		SELECT COUNT(*) FROM tbl_brand WHERE state = :state
	</select>
    <select id="getBrandByID">
	    SELECT * FROM tbl_brand WHERE id = :id
	</select>
	<update id="updateBrand">
		UPDATE tbl_brand SET name =:name,logo=:logo,link=:link, description=:description,state=:state,pics = :pics,person=:person,seq=:seq,news_ids=:news_ids, booth_id = :booth_id WHERE id = :id
	</update>
	<insert id="insertBrand">
		INSERT INTO tbl_brand (name,logo,description,link,pics,person,news_ids,seq,state, booth_id, create_time) VALUES (:name,:logo,:description, :link,:pics,:person,:news_ids,:seq,:state,:booth_id, UNIX_TIMESTAMP()) 
	</insert>
	<insert id="setBooth">
	   INSERT INTO tbl_booth(booth_id, position, create_time) VALUES(:booth_id, :position, UNIX_TIMESTAMP()) ON DUPLICATE KEY UPDATE position = :position
	</insert>	
	<select id="getBoothList">
	   SELECT * FROM tbl_booth
	</select>
	<delete id="delBooth">
	   DELETE FROM tbl_booth WHERE booth_id = :booth_id
	</delete>
	<select id="getSignLayoutList">
	   SELECT * FROM tbl_sign_layout
	</select>
	<select id="getSignPicList">
	   SELECT * FROM tbl_sign_pic
	</select>
	<select id="getSignPosition">
	   SELECT * FROM tbl_sign_position
	</select>
	<select id="getYohobuyBrand">
	   SELECT * FROM tbl_yohobuy_brand
	</select>
	<select id="getSignBrand">
	   SELECT a.booth_id, a.brand_name, b.brand_id FROM tbl_sign_booth_brand a, tbl_yohobuy_brand b WHERE a.yohobuy_brand_name = b.brand_name
	</select>
	<insert id="setBrandNewsRela">
	   INSERT IGNORE  INTO  tbl_news_brand_rela(news_id, brand_id, create_time) VALUES(:news_id, :brand_id, UNIX_TIMESTAMP())
	</insert>
	<select id="getBrandNewsRelaByNewsID">
	   SELECT * FROM tbl_news_brand_rela WHERE news_id IN (#news_id#) ORDER BY id, create_time
	</select>
	<select id="getBrandNewsRelaByBrandID">
	   SELECT * FROM tbl_news_brand_rela WHERE brand_id IN (#brand_id#) ORDER BY id DESC
	</select>
	<select id="deleteBrandNewsRelaByNewsID">
	   DELETE FROM tbl_news_brand_rela WHERE news_id = :news_id
	</select>
	<select id="getBrandByName">
       SELECT * FROM `tbl_brand` WHERE state = :state AND `name` LIKE :name ORDER BY seq DESC, create_time DESC
    </select>
    <select id="getSameNewsByNewsID">
        SELECT DISTINCT news_id FROM tbl_news_brand_rela WHERE brand_id IN  (SELECT brand_id FROM tbl_news_brand_rela WHERE news_id = :news_id) AND news_id &lt;&gt; :news_id ORDER BY create_time
    </select>
</sqlMap>