You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.6 KiB
XML

5 months ago
<?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="cn.iocoder.yudao.module.basic.dal.mysql.inputsinfo.InputsInfoMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.basic.dal.dataobject.inputsinfo.InputsInfoDO">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="inputs_name" jdbcType="VARCHAR" property="inputsName"/>
<result column="inputs_id" jdbcType="VARCHAR" property="inputsId"/>
<result column="inputs_unit" jdbcType="VARCHAR" property="inputsUnit"/>
<result column="inputs_specs" jdbcType="VARCHAR" property="inputsSpecs"/>
<result column="inputs_remarks" jdbcType="VARCHAR" property="inputsRemarks"/>
<result column="inputs_photo_url" jdbcType="VARCHAR" property="inputsPhotoUrl"/>
<result column="shelf_life" jdbcType="INTEGER" property="shelfLife"/>
<result column="belong_business_id" jdbcType="BIGINT" property="belongBusinessId"/>
<result column="belong_business_name" jdbcType="VARCHAR" property="belongBusinessName"/>
</resultMap>
<select id="selectPageByInfo" resultMap="BaseResultMap">
select bii.*,bbi.id,bbi.business_name from basic_inputs_info bii
left join basic_business_info bbi on bbi.id = bii.belong_business_id
${ew.customSqlSegment}
order by bii.id DESC
</select>
<select id="selectInputsPageByInfo"
resultType="cn.iocoder.yudao.module.basic.dal.dataobject.inputsinfo.InputsInfoDO">
SELECT a.*,b.unit_name inputs_unit_name
FROM basic_inputs_info a
LEFT JOIN basic_unit b ON inputs_unit_id = b.id
WHERE a.deleted = 0
<if test="inputsName != null and inputsName != ''"> and a.inputs_name LIKE CONCAT('%', #{inputsName}, '%') </if>
<if test="inputsId != null and inputsId != ''"> and a.inputs_id = #{inputsId} </if>
<if test="belongBusinessName != null and belongBusinessName != ''"> and a.belong_business_name LIKE CONCAT('%', #{belongBusinessName}, '%') </if>
ORDER BY a.id DESC
</select>
<select id="queryListOfMiniResult" resultType="cn.iocoder.yudao.module.basic.controller.admin.inputsinfo.vo.InputsInfoForTransferRespVO">
SELECT
bii.id, bii.inputs_id, bii.inputs_name,
CASE
bii.is_base_unit
WHEN 1 THEN
'kg'
ELSE bu.unit_name
END inputsUnit
FROM basic_inputs_info bii
LEFT JOIN basic_unit bu ON bii.inputs_unit_id = bu.id
WHERE bii.deleted = 0 AND bii.belong_business_id = #{businessInfoId}
</select>
<select id="getInputsInfoByBusinessInfoId" resultType="cn.iocoder.yudao.module.basic.controller.admin.inputsinfo.vo.InputsInfoRespVO">
SELECT
bii.*,
CASE
bii.is_base_unit
WHEN 1 THEN
'kg'
ELSE bu.unit_name
END inputsUnitName
FROM basic_inputs_info bii
LEFT JOIN basic_unit bu ON bii.inputs_unit_id = bu.id
WHERE bii.deleted = 0 AND bii.belong_business_id = #{businessInfoId}
</select>
</mapper>