后端 CUID 开发小技巧
1.不在用HashMap存储条件 只需要一行代码 将传输对象存储转换成Map 进行查询
Map<String, Object> conditions = JSON.parseObject(JSON.toJSONString(dataReceiveNotify), Map.class);
对象本身可以通过JSON函数编程 Map,Map 作为条件然后传入,然后进行查询
2. 不再用 Collection、association 进行关联 操作如下 即可多表查询
<select id="selectByTaskConditions" parameterType="java.util.Map" resultType="java.util.Map" >
SELECT r.satellite,r.antenna,r.receive_starttime,r.receive_endtime,r.receive_result,
t.priority,t.task_id,t.scout_type,t.scout_starttime,t.scout_endtime,t.orbit_id,t.sensor_mode,
p.data_center
FROM sar_standard_data_receive r
LEFT JOIN sar_standard_task t ON t.task_id=r.task_id
LEFT JOIN
(select p.data_center,p.plan_id FROM sar_standard_plan p left join sar_standard_task t on p.task_id=t.task_id) p
ON p.plan_id=r.plan_id
where 1=1
<if test="satellite!=null and satellite!=''">
and r.satellite like '%${satellite}%'
</if>
<if test="antenna!=null and antenna!=''">
and r.antenna like '%${antenna}%'
</if>
<if test="receiveStartTime!=null and receiveStartTime!=''">
and r.receive_starttime >= #{receiveStartTime}
</if>
<if test="receiveEndTime!=null and receiveEndTime!=''">
and r.receive_endtime <= #{receiveEndTime}
</if>
<if test="receiveResult!=null and receiveResult!=''">
and r.receive_result=#{receiveResult}
</if>
<if test="priority!=null and priority!=''">
and t.priority=#{priority}
</if>
<if test="taskID!=null and taskID!=''">
and t.task_id=#{taskID}
</if>
<if test="scoutType!=null and scoutType!=''">
and t.scout_type=#{scoutType}
</if>
<if test="scoutStartTime!=null and scoutStartTime!=''">
and t.scout_starttime >= #{scoutStartTime}
</if>
<if test="scoutEndTime!=null and scoutEndTime!=''">
and t.scout_endtime <= #{scoutEndTime}
</if>
<if test="orbitID!=null and orbitID!=''">
and t.orbit_id=#{orbitID}
</if>
<if test="sensorMode!=null and sensorMode!=''">
and t.sensor_mode=#{sensorMode}
</if>
<if test="dataCenter!=null and dataCenter!=''">
and p.data_center=#{dataCenter}
</if>
<if test="orderColumn==null">
order by r.antenna desc
</if>
<if test="pageNum!=null and pageSize!=null">
limit #{pageSize} offset #{pageNum}
</if>
</select>