更新语句,更新两个字段
@Update("update bank_file_info set save_type = #{saveType},format_type_id=#{formatTypeId} where id = #{fileId}") void updateSaveType(@Param("fileId") Integer fileId, @Param("saveType") Integer saveType, @Param("formatTypeId") Integer formatTypeId);
批量插入一个对象集合:
@Insert({ "<script>", "insert into bank_file_info(p_id, rate, folder_name, source_name, file_code, size, format, file_name, source_url,new_source_url,file_type,upload_time,is_border,is_turn) values ", "<foreach collection='list' item='item' index='index' separator=','>", "(#{item.pId}, #{item.rate}, #{item.folderName}, #{item.sourceName}, #{item.fileCode}, #{item.size}, #{item.format}, #{item.fileName}, #{item.sourceUrl}," + "#{item.newSourceUrl},#{item.fileType},#{item.uploadTime},#{item.isBorder},#{item.isTurn})", "</foreach>", "</script>" }) @Options(useGeneratedKeys = true, keyProperty = "id") void insertFileList(@Param(value = "list") List<BankFileInfo> fileInfoList);
数据库新增字段,这里要注意版本问题,有的版本是这种写法default(0),后边是注释
ALTER TABLE bank_file_info add save_type TINYINT(1) DEFAULT 0 COMMENT '保存状态 0:版式与表头均未存储1:存储版式2:存储表头信息';
删除语句:
@Delete("delete from bank_table_head where file_id = #{fileId} ") void delData(@Param("fileId") Integer fileID);
查询语句:
@Select("select * from bank_file_info where rate = '2' and format = 'pdf' and del_flag = 0 and progress = 0 limit 1") BankFileInfo selectPdfFile();
创建索引:create index 索引名 on 表名(列名)注释
CREATE INDEX PersonIndex ON Person (LastName) COMMENT('持续时间索引')