2021-07-30

Posted 大树叶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2021-07-30相关的知识,希望对你有一定的参考价值。

在Java中使用动态mybatis语句访问DB的例子如下,官方建议不用XML.

package com.test.econtract.esign2bcore.dao;

import com.test.econtract.esign2bcore.dao.model.PlatformInfoDO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PlatformInfoMapper {

   @Insert(value = {
           "<script> ",
           "INSERT INTO platform_info ",
           "<trim prefix='(' suffix=')' suffixOverrides=','> ",
           "<if test='platName!=null'>plat_name,</if> ",
           "<if test='appId!=null'>app_id,</if> ",
           "<if test='appSecrect!=null'>app_secrect,</if> ",
           "<if test='signFrom!=null'>sign_from,</if> ",
           "<if test='description!=null'>description,</if> ",
           "<if test='deletedAt!=null'>deleted_at,</if> ",
           "</trim> ",
           "VALUES ",
           "<trim prefix='(' suffix=')' suffixOverrides=','> ", 
           "<if test='platName!=null'>#{platName},</if> ",
           "<if test='appId!=null'>#{appId},</if> ",
           "<if test='appSecrect!=null'>#{appSecrect},</if> ",
           "<if test='signFrom!=null'>#{signFrom},</if> ",
           "<if test='description!=null'>#{description},</if> ",
           "<if test='deletedAt!=null'>#{deletedAt},</if> ",
           "</trim> ",
           "</script> ",
   })
   @Options(useGeneratedKeys = true, keyColumn = "id")
   Integer insert(PlatformInfoDO insert);

   @Update(value = {
           "<script> ",
           "UPDATE platform_info",
           "<set> ",
           "<if test='id!=null'>id = #{id},</if> ",
           "<if test='platName!=null'>plat_name = #{platName},</if> ",
           "<if test='appId!=null'>app_id = #{appId},</if> ",
           "<if test='appSecrect!=null'>app_secrect = #{appSecrect},</if> ",
           "<if test='signFrom!=null'>sign_from = #{signFrom},</if> ",
           "<if test='description!=null'>description = #{description},</if> ",
           "<if test='deletedAt!=null'>deleted_at = #{deletedAt},</if> ",
           "</set> ",
           "WHERE id = #{id} ",
           "</script>", 
   })
   Integer update(PlatformInfoDO update);

   @Select(value = {
           "<script> ",
           "SELECT * FROM platform_info",
           "<where> ",
           "<if test='id!=null'>AND id = #{id}</if> ",
           "<if test='platName!=null'>AND plat_name = #{platName}</if> ",
           "<if test='appId!=null'>AND app_id = #{appId}</if> ",
           "<if test='appSecrect!=null'>AND app_secrect = #{appSecrect}</if> ",
           "<if test='signFrom!=null'>AND sign_from = #{signFrom}</if> ",
           "<if test='description!=null'>AND description = #{description}</if> ",
           "<if test='deletedAt!=null'>AND deleted_at = #{deletedAt}</if> ",
           "</where> ",
           "LIMIT 0,1 ",
           "</script>", 
   })
   PlatformInfoDO selectOne(PlatformInfoDO query);

   @Select({"SELECT * FROM platform_info WHERE id = #{id} AND deleted_at = 0"})
   PlatformInfoDO selectOneById(Integer id);

   @Select(value = {
           "<script> ",
           "SELECT * FROM platform_info",
           "<where> ",
           "<if test='id!=null'>AND id = #{id}</if> ",
           "<if test='platName!=null'>AND plat_name = #{platName}</if> ",
           "<if test='appId!=null'>AND app_id = #{appId}</if> ",
           "<if test='appSecrect!=null'>AND app_secrect = #{appSecrect}</if> ",
           "<if test='signFrom!=null'>AND sign_from = #{signFrom}</if> ",
           "<if test='description!=null'>AND description = #{description}</if> ",
           "<if test='deletedAt!=null'>AND deleted_at = #{deletedAt}</if> ",
           "</where> ",
           "</script>", 
   })
   List<PlatformInfoDO> selectMany(PlatformInfoDO query);

   @Delete(value = {
           "<script> ",
           "DELETE FROM platform_info",
           "<where> ",
           "<if test='id!=null'>AND id = #{id}</if> ",
           "<if test='platName!=null'>AND plat_name = #{platName}</if> ",
           "<if test='appId!=null'>AND app_id = #{appId}</if> ",
           "<if test='appSecrect!=null'>AND app_secrect = #{appSecrect}</if> ",
           "<if test='signFrom!=null'>AND sign_from = #{signFrom}</if> ",
           "<if test='description!=null'>AND description = #{description}</if> ",
           "<if test='deletedAt!=null'>AND deleted_at = #{deletedAt}</if> ",
           "</where> ",
           "</script>", 
   })
   Integer delete(PlatformInfoDO delete);


@Select(value = {
           "<script> ",
           "SELECT * FROM live_verify ",
           "WHERE deleted_at = 0 ",
           "<if test='liveVerify.id!=null'>AND id = #{liveVerify.id}</if> ",
           "<if test='liveVerify.fkId!=null'>AND fk_id = #{liveVerify.fkId}</if> ",
           "<if test='liveVerify.subFkId!=null'>AND sub_fk_id = #{liveVerify.subFkId}</if> ",
           "<if test='liveVerify.systemType!=null'>AND system_type = #{liveVerify.systemType}</if> ",
           "<if test='liveVerify.username!=null'>AND username = #{liveVerify.username}</if> ",
           "<if test='liveVerify.idNoType!=null'>AND idNo_type = #{liveVerify.idNoType}</if> ",
           "<if test='liveVerify.idNoEncrypt!=null'>AND idNo_encrypt = #{liveVerify.idNoEncrypt}</if> ",
           "<if test='liveVerify.orderNo!=null'>AND order_no = #{liveVerify.orderNo}</if> ",
           "<if test='liveVerify.verifyStatus!=null'>AND verify_status = #{liveVerify.verifyStatus}</if> ",
           "<if test='liveVerify.verifyFrom!=null'>AND verify_from = #{liveVerify.verifyFrom}</if> ",
           "<if test='liveVerify.verifyImage!=null'>AND verify_image = #{liveVerify.verifyImage}</if> ",
           "AND verify_status IN ",
           "<foreach collection='statusList' item='item' open='(' close=')' separator=',' > ",
           "#{item} ",
           "</foreach> ",
           "ORDER BY ID DESC LIMIT 0,1 ",
           "</script> "
   })
   LiveVerifyDO selectLiveVerifyByMultiResult(@Param("liveVerify") LiveVerifyDO liveVerifyDO, @Param("statusList") List<Integer> list);
   
}

 "<foreach collection='dataRecordList' open='(' close=')' separator=',' index='index' item='item' >",

以上是关于2021-07-30的主要内容,如果未能解决你的问题,请参考以下文章

2021-07-30 .NET高级班 123-直播项目专题(微信支付对接)

2021-07-30:两个有序数组间相加和的Topk问题。给定两个有序数组arr1和arr2,再给定一个整数k,返回来自arr1和arr2的两个数相加和最大的前k个,两个数必须分别来自两个数组。按照降

无法根据字符串值减少对象数组

微信小程序代码片段

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js