1.将根据条件mdmDataType和system查找分发系统(模糊查询like)
(1)distributeSystemController控制层代码实现
@RequiresPermissions("workbench:distributeSystem:view")
@RequestMapping(value = {"list", ""})
public String list(DistributeSystem distributeSystem, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<DistributeSystem> page = distributeSystemService.findPage(new Page<DistributeSystem>(request, response), distributeSystem);
/*修改位置
* for(DistributeSystem dis:page.getList()){
* MdmSystem mdms = mdmSystemService.get(dis.getSystem());
* if(mdms!=null){
* dis.setSystem(mdms.getName());
* }
*}
*/
model.addAttribute("page", page);
return "modules/workbench/distributeSystemList";
}
(2)distributeSystemDao.xml 动态sql的编写
<select id="findList" resultType="DistributeSystem">
SELECT
<include refid="selectAllColumns"/>
FROM <include refid="tableName"/>
<!-- <include refid="where_fragement"/> -->
<where>
1=1
<if test="mainDataType != null and mainDataType != ''">
AND a.main_data_type LIKE
<if test="dbName == 'oracle'">'%'||#{mainDataType}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{mainDataType}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{mainDataType},'%')</if>
</if>
<if test="system != null and system != ''">
AND a.system LIKE
<if test="dbName == 'oracle'">'%'||#{system}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{system}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{system},'%')</if>
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.system DESC
</otherwise>
</choose>
</select>