2020-12-02 工作问题集

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>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值