<?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.jeeplus.test.shop.mapper.TestGoodsMapper">

	<sql id="testGoodsColumns">
		a.id AS "id",
		a.name AS "name",
		a.category_id AS "category.id",
		a.price AS "price",
		a.tenant_id AS "tenantId",
		a.create_by_id AS "createBy.id",
		a.create_time AS "createDate",
		a.update_by_id AS "updateBy.id",
		a.update_time AS "updateDate",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		category.name AS "category.name"
	</sql>

	<sql id="testGoodsJoins">

		LEFT JOIN test_category category ON category.id = a.category_id
	</sql>



	<select id="findById" resultType="com.jeeplus.test.shop.service.dto.TestGoodsDTO">
		SELECT
			<include refid="testGoodsColumns"/>
		FROM test_goods a
		<include refid="testGoodsJoins"/>
		WHERE a.id = #{id} and a.del_flag = 0
	</select>

	<select id="findList" resultType="com.jeeplus.test.shop.service.dto.TestGoodsDTO">
		SELECT
			<include refid="testGoodsColumns"/>
		FROM test_goods a
		<include refid="testGoodsJoins"/>
	    ${ew.customSqlSegment}
	</select>

</mapper>
