@Data @Builder public class ICoverageDao { private String className; private String methodName; private String counterType; private String counterMissed; private String counterCovered; }
Mapper添加语法
private SqlSessionTemplate template; template.insert("insertCoverage",iCoverageDao);
Mapper映射
<select id="insertCoverage" resultType="com.coverage.model.coverage.ICoverageDao"> <!-- resultType 返回的数据类型--> insert into coverage_coverage(className,methodName,counterType,counterMissed,counterCovered) values(#{className},#{methodName},#{counterType},#{counterMissed},#{counterCovered}); </select>
删除语法
private SqlSessionTemplate template; template.delete("deleteCoverage",iCoverageDao);
Mapper映射
<select id="deleteCoverage" resultType="com.coverage.model.coverage.ICoverageDao"> <!-- resultType 返回的数据类型--> delete from coverage_coverage where className = #{className}; </select>
修改语法
template.update("updateDeploy",updateReportData);
<select id="updateDeploy" resultType="Integer"> <!-- resultType 返回的数据类型--> update coverage_deploy set report_path = #{reportPath} where project_name = #{projectName} and job_name = #{jobName} and build_id = #{buildId}; </select>
查询一条数据
ReportDao reportDao = template.selectOne("getReportData",params);
<select id="getReportData" resultType="com.coverage.model.ReportDao"> <!-- resultType 返回的数据类型--> select project_id,name,exec_path,ip,port,report_path,class_path,source_path from api_git_server where project_id=#{projectId} and name = #{jobName}; </select>
插入一个对象集合
template.insert("insertCoverageList",iCoverageDaoList);
<select id="insertCoverageList" resultType="java.util.List"> <!-- resultType 返回的数据类型--> insert into coverage_coverage(className,methodName,counterType,counterMissed,counterCovered) values <foreach collection="list" item="coverage_coverage" separator=","> (#{coverage_coverage.className}, #{coverage_coverage.methodName}, #{coverage_coverage.counterType}, #{coverage_coverage.counterMissed}, #{coverage_coverage.counterCovered}) </foreach> </select>
标签:className,Java,template,private,语法,coverage,mybatis,counterCovered,String From: https://www.cnblogs.com/chenchengzi/p/17664937.html