后端 CUID 开发小技巧

后端 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 &lt;= #{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 &lt;=  #{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>

3. 开发中 不论是路径 还是函数名字 应该尽量详细 让人看懂

4. controller层 是一个表象,尽量不要在controller层书写代码

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值