mapper层接口
@Mapper
public interface MachineBaseInfoMapper extends BaseDao<MachineBaseInfo> {
List<CategoryVO> getMachineCategoryList(@Param("companyCode") String companyCode);
}
配置文件
当某个条件不为空时当作条件查询条件,为空时不作为查询条件
<select id="getMachineCategoryList" resultType="com.hx.telematics.domain.vo.response.CategoryVO">
select distinct category_id, category_code, category_name
from t_machine_base_info
<where>
deleted = 0 and category_code is not null
<if test="companyCode != null and companyCode != ''">
and belong_company_code=#{companyCode}
</if>
</where>
</select>
这里的id表示的接口的名字,resultType返回的结果类型是一个CategoryVO的list列表,查询条件变量是@Param(“companyCode”)里的companyCode