Mybatis生成器插件扩展,定制方法生成,list参数生成

Mybatis生成器插件扩展,定制方法生成

        public Criteria andNameIsEmpty() {addCriterion("`name` = ''");setCriterionPattern();return (Criteria) this;}public Criteria andNameFindInSet(String value) {addCriterion("find_in_set($value, `name`)", value, "name");setCriterionPattern();return (Criteria) this;}public Criteria andNameFindInSetIn(List<String> value) {addCriterion("find_in_set($value, `name`)", value, "name");setCriterionPattern();return (Criteria) this;}

 

一、生成模式原理

(1)Example.Criterion添加pattern字段

 public static class Criterion {private String condition;private Object value;private Object secondValue;private boolean noValue;private boolean singleValue;private boolean betweenValue;private boolean listValue;private String typeHandler;private boolean pattern;
}

(2)Example.GeneratedCriteria加方法setCriterionPattern

protected abstract static class GeneratedCriteriaprotected void setCriterionPattern() {Criterion criterion = (Criterion)criteria.get(criteria.size()-1);criterion.setPattern(true);}
}

(3) 加对应列方法

protected abstract static class GeneratedCriteria {public Criteria andXXXOp(String value) {addCriterion("Op(##value##, `xxx`)", value, "xxx");setCriterionPattern();return (Criteria) this;}
}

(4)改造XXXSqlProvider.applyWhere的 if (criterion.isNoValue()) 前增加模式代码

if (criterion.isPattern()) {if (criterion.isListValue()) {//list参数sb.append(" (");List<?> listItems = (List<?>) criterion.getValue();boolean comma = false;for (int k = 0; k < listItems.size(); k++) {if (comma) {sb.append(" or ");} else {comma = true;}String value;if (criterion.getTypeHandler() == null) {value = String.format(parmPhrase3, i, j, k);} else {value = String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler());}sb.append(criterion.getCondition().replace("##value##", value));}sb.append(')');} else {//其他参数String value;if (criterion.getTypeHandler() == null) {value = String.format(parmPhrase1, "", i, j).trim();} else {value = String.format(parmPhrase1_th, "", i, j, criterion.getTypeHandler()).trim();}sb.append(criterion.getCondition().replace("##value##", value));}
} else if (criterion.isNoValue()) {sb.append(criterion.getCondition());
}

(5)改造XXXMapper.xml的<when test="criterion.noValue">前增加模式代码

<when test="criterion.pattern">and<choose><when test="criterion.listValue"><foreach close=")" collection="criterion.value" item="listItem" open="(" separator=" or  "><foreach collection="criterion.condition.split('##value##')" item="criterionCond" separator="#{listItem}">${criterionCond}</foreach></foreach></when><otherwise><foreach collection="criterion.condition.split('##value##')" item="criterionCond" separator="#{criterion.value}">${criterionCond}</foreach></otherwise></choose>
</when>
<when test="criterion.noValue">and ${criterion.condition}
</when>

 

二、插件代码

package com.mk.mybatisgenerator.plugins;import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.*;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.Element;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.codegen.ibatis2.Ibatis2FormattingUtilities;import java.util.*;public class MySQLMethodPlugin extends PluginAdapter {private String valueName = "##value##";//值占位符private String columnName = "##column##";//列名占位符private boolean listValue = true;//是否开启生成list参数private Map<String, String> methods = new HashMap<>();public MySQLMethodPlugin() {super();}@Overridepublic void setProperties(Properties properties) {super.setProperties(properties);final String valueNameStr = "VALUE_NAME";final String columnNameStr = "COLUMN_NAME";final String listValueStr = "LIST_VALUE";for (String name : properties.stringPropertyNames()) {String value = properties.getProperty(name);if (valueNameStr.equals(name)) {if (value != null && (value = value.trim()).length() > 0) {this.valueName = value;}} else if (columnNameStr.equals(name)) {if (value != null && (value = value.trim()).length() > 0) {this.columnName = value;}} else if (listValueStr.equals(name)) {if (value != null) {this.listValue = Boolean.parseBoolean(value);}} else {methods.put(name, value);}}}@Overridepublic boolean validate(List<String> warnings) {return true;}/*** 重写example** @param topLevelClass* @param introspectedTable* @return*/@Overridepublic boolean modelExampleClassGenerated(TopLevelClass topLevelClass,IntrospectedTable introspectedTable) {addCriterionPattern(topLevelClass, introspectedTable);//增加模式匹配if (methods.isEmpty()) {addFindInSet(topLevelClass, introspectedTable);//增加find_in_set方法addPattern(topLevelClass, introspectedTable);//增加模式方法} else {for (Map.Entry<String, String> entry : methods.entrySet()) {boolean hasValue = entry.getValue().contains(valueName);addMethodPattern(topLevelClass, introspectedTable, entry.getKey(), entry.getValue(), hasValue);}}return true;}//<when test="criterion.pattern">//	and//	<choose>//		<when test="criterion.listValue">//			<foreach close=")" collection="criterion.value" item="listItem" open="("//					 separator=" or  ">//				<foreach collection="criterion.conditionList('##value##')"//						 item="criterionCond" separator="#{listItem}">//					${criterionCond}//				</foreach>//			</foreach>////		</when>//		<otherwise>//			<foreach collection="criterion.conditionSplit('##value##')"//					 item="criterionCond" separator="#{criterion.value}">//				${criterionCond}//			</foreach>//		</otherwise>//	</choose>//</when>//<when test="criterion.noValue">//	and ${criterion.condition}//</when>/*** xml ExampleWhere重写** @param xmlElement* @param introspectedTable* @return*/@Overridepublic boolean sqlMapExampleWhereClauseElementGenerated(XmlElement xmlElement, IntrospectedTable introspectedTable) {List<Element> elementList = new LinkedList<>();elementList.add(xmlElement);while (!elementList.isEmpty()) {Element parent = elementList.remove(0);if(!(parent instanceof XmlElement)){continue;}XmlElement xmlParent = (XmlElement) parent;List<Element> elements = xmlParent.getElements();elementList.addAll(0, elements);for (int i = 0, len = elements.size(); i < len; i++) {Element ele = elements.get(i);if(!(ele instanceof XmlElement)){continue;}XmlElement element = (XmlElement) ele;if(!element.getName().equals("when")){continue;}for (Attribute attribute : element.getAttributes()) {//找到criterion.noValue行插入模式代码if (attribute.getName().equals("test") && attribute.getValue().equals("criterion.noValue")) {//isListXmlElement patternListWhenElement = new XmlElement("when");{XmlElement condForElement = new XmlElement("foreach");condForElement.addAttribute(new Attribute("collection", "criterion.conditionSplit('" + valueName + "')"));condForElement.addAttribute(new Attribute("item", "criterionCond"));condForElement.addAttribute(new Attribute("separator", "#{listItem}"));condForElement.addElement(new TextElement("${criterionCond}"));XmlElement listForElement = new XmlElement("foreach");listForElement.addAttribute(new Attribute("collection", "criterion.value"));listForElement.addAttribute(new Attribute("item", "listItem"));listForElement.addAttribute(new Attribute("separator", " or  "));listForElement.addAttribute(new Attribute("open", "("));listForElement.addAttribute(new Attribute("close", ")"));listForElement.addElement(condForElement);patternListWhenElement.addAttribute(new Attribute("test", "criterion.listValue"));patternListWhenElement.addElement(listForElement);}//otherwiseXmlElement otherwiseElement = new XmlElement("otherwise");{XmlElement condForElement = new XmlElement("foreach");condForElement.addAttribute(new Attribute("collection", "criterion.conditionSplit('" + valueName + "')"));condForElement.addAttribute(new Attribute("item", "criterionCond"));condForElement.addAttribute(new Attribute("separator", "#{criterion.value}"));condForElement.addElement(new TextElement("${criterionCond}"));otherwiseElement.addElement(condForElement);}XmlElement patternChooseElement = new XmlElement("choose");patternChooseElement.addElement(patternListWhenElement);patternChooseElement.addElement(otherwiseElement);XmlElement patternElement = new XmlElement("when");patternElement.addAttribute(new Attribute("test", "criterion.pattern"));patternElement.addElement(new TextElement("and"));patternElement.addElement(patternChooseElement);xmlParent.addElement(i, patternElement);return true;}}}}throw new RuntimeException("ChooseElement not exist");}//if (criterion.isPattern()) {//	if (criterion.isListValue()) {//		sb.append(" (");//		List<?> listItems = (List<?>) criterion.getValue();//		boolean comma = false;//		for (int k = 0; k < listItems.size(); k++) {//			if (comma) {//				sb.append(" or ");//			} else {//				comma = true;//			}//			String value;//			if (criterion.getTypeHandler() == null) {//				value = String.format(parmPhrase3, i, j, k);//			} else {//				value = String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler());//			}//			sb.append(criterion.getCondition().replace("##value##", value));//		}//		sb.append(')');//	} else {//		String value;//		if (criterion.getTypeHandler() == null) {//			value = String.format(parmPhrase1, "", i, j).trim();//		} else {//			value = String.format(parmPhrase1_th, "", i, j, criterion.getTypeHandler()).trim();//		}//		sb.append(criterion.getCondition().replace("##value##", value));//	}//} else if (criterion.isNoValue()) {//	sb.append(criterion.getCondition());//}/*** 重写ApplyWhere方法** @param method* @param topLevelClass* @param introspectedTable* @return*/@Overridepublic boolean providerApplyWhereMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {List<String> lines = method.getBodyLines();for (int i = 0, len = lines.size(); i < len; i++) {String line = lines.get(i).trim();//找到criterion.noValue行插入模式代码if (line.matches("if\\s*\\(criterion\\.isNoValue\\(\\)\\)\\s*\\{")) {lines.remove(i);List<String> appends = new ArrayList<>();appends.add("if (criterion.isPattern()) {");appends.add("if (criterion.isListValue()) {");appends.add("sb.append(\" (\");");appends.add("List<?> listItems = (List<?>) criterion.getValue();");appends.add("boolean comma = false;");appends.add("for (int k = 0; k < listItems.size(); k++) {");appends.add("if (comma) {");appends.add("sb.append(\" or \");");appends.add("} else {");appends.add("comma = true;");appends.add("}");appends.add("String value;");appends.add("if (criterion.getTypeHandler() == null) {");appends.add("value = String.format(parmPhrase3, i, j, k);");appends.add("} else {");appends.add("value = String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler());");appends.add("}");appends.add("sb.append(criterion.getCondition().replace(\"" + valueName + "\", value));");appends.add("}");appends.add("sb.append(')');");appends.add("} else {");appends.add("String value;");appends.add("if (criterion.getTypeHandler() == null) {");appends.add("value = String.format(parmPhrase1, \"\", i, j).trim();");appends.add("} else {");appends.add("value = String.format(parmPhrase1_th, \"\", i, j, criterion.getTypeHandler()).trim();");appends.add("}");appends.add("sb.append(criterion.getCondition().replace(\"" + valueName + "\", value));");appends.add("}");appends.add("} else " + line);method.addBodyLines(i, appends);return true;}}throw new RuntimeException("criterion.isNoValue() not exist");}/*protected void setCriterionPattern() {Criterion criterion = (Criterion)criteria.get(criteria.size()-1);criterion.setPattern(true);}*/public void addCriterionPattern(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {addCriterionPatternField(topLevelClass, introspectedTable);InnerClass criteria = null;// first, find the Criteria inner classfor (InnerClass innerClass : topLevelClass.getInnerClasses()) {if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$criteria = innerClass;break;}}if (criteria == null) {throw new RuntimeException("GeneratedCriteria not exist");}//模式方法Method setCriterionPattern = new Method();setCriterionPattern.setVisibility(JavaVisibility.PROTECTED);setCriterionPattern.setName("setCriterionPattern");setCriterionPattern.addBodyLine("Criterion criterion = (Criterion)criteria.get(criteria.size()-1);");setCriterionPattern.addBodyLine("criterion.setPattern(true);");criteria.addMethod(setCriterionPattern);}public void addCriterionPatternField(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {InnerClass criterion = null;// first, find the Criteria inner classfor (InnerClass innerClass : topLevelClass.getInnerClasses()) {if ("Criterion".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$criterion = innerClass;break;}}if (criterion == null) {throw new RuntimeException("Criterion not exist");}FullyQualifiedJavaType booleanPrimitive = FullyQualifiedJavaType.getBooleanPrimitiveInstance();Field pattern = new Field();pattern.setName("pattern");pattern.setVisibility(JavaVisibility.PRIVATE);pattern.setType(booleanPrimitive);criterion.addField(pattern);Method setPattern = new Method();setPattern.setVisibility(JavaVisibility.PUBLIC);setPattern.setName("setPattern");setPattern.addParameter(new Parameter(booleanPrimitive, "pattern"));setPattern.addBodyLine("this.pattern = pattern;");criterion.addMethod(setPattern);Method isPattern = new Method();isPattern.setVisibility(JavaVisibility.PUBLIC);isPattern.setReturnType(booleanPrimitive);isPattern.setName("isPattern");isPattern.addBodyLine("return pattern;");criterion.addMethod(isPattern);Method conditionList = new Method();conditionList.setVisibility(JavaVisibility.PUBLIC);conditionList.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "valueName"));conditionList.setName("conditionSplit");conditionList.setReturnType(new FullyQualifiedJavaType("String[]"));conditionList.addBodyLine("return java.util.regex.Pattern.compile(valueName, java.util.regex.Pattern.LITERAL).split(this.condition);");criterion.addMethod(conditionList);}public void addFindInSet(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {String opName = "findInSet";String pattern = "find_in_set(" + valueName + ", " + columnName + ")";addMethodPattern(topLevelClass, introspectedTable, opName, pattern, true);}public void addMethodPattern(TopLevelClass topLevelClass, IntrospectedTable introspectedTable, String opName, String pattern, boolean hasValue) {addMethodPattern(topLevelClass, introspectedTable, opName, pattern, hasValue, false);if (hasValue && listValue) {addMethodPattern(topLevelClass, introspectedTable, opName, pattern, true, true);}}public void addMethodPattern(TopLevelClass topLevelClass, IntrospectedTable introspectedTable, String opName,String pattern, boolean hasValue, boolean isList) {InnerClass criteria = null;// first, find the Criteria inner classfor (InnerClass innerClass : topLevelClass.getInnerClasses()) {if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$criteria = innerClass;break;}}if (criteria == null) {throw new RuntimeException("GeneratedCriteria not exist");}for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {if (!introspectedColumn.isJdbcCharacterColumn()|| !introspectedColumn.isStringColumn()) {continue;}Method method = new Method();method.setVisibility(JavaVisibility.PUBLIC);//判断是否有参数if (hasValue) {FullyQualifiedJavaType javaType = introspectedColumn.getFullyQualifiedJavaType();if (isList) {//判断是否是list参数javaType = FullyQualifiedJavaType.getNewListInstance();javaType.addTypeArgument(introspectedColumn.getFullyQualifiedJavaType());}method.addParameter(new Parameter(javaType, "value")); //$NON-NLS-1$}StringBuilder opNameBuilder = new StringBuilder(opName);opNameBuilder.setCharAt(0, Character.toUpperCase(opNameBuilder.charAt(0)));opName = opNameBuilder.toString();StringBuilder sb = new StringBuilder();sb.append(introspectedColumn.getJavaProperty());sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));sb.insert(0, "and"); //$NON-NLS-1$sb.append(opName);//list参数加In后缀if (hasValue && isList) {sb.append("In");}method.setName(sb.toString());method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());sb.setLength(0);//addCriterion方法sb.append("addCriterion(\"").append(pattern.replace(columnName, Ibatis2FormattingUtilities.getAliasedActualColumnName(introspectedColumn)));//有参数使用有参方法if (hasValue) {sb.append("\", value, \"").append(introspectedColumn.getJavaProperty());}sb.append("\");");method.addBodyLine(sb.toString());method.addBodyLine("setCriterionPattern();");method.addBodyLine("return (Criteria) this;");criteria.addMethod(method);}}public void addPattern(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {addPatternMethod(topLevelClass, introspectedTable, "pattern");}public void addPatternMethod(TopLevelClass topLevelClass, IntrospectedTable introspectedTable, String opName) {InnerClass criteria = null;// first, find the Criteria inner classfor (InnerClass innerClass : topLevelClass.getInnerClasses()) {if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$criteria = innerClass;break;}}if (criteria == null) {throw new RuntimeException("GeneratedCriteria not exist");}for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {if (!introspectedColumn.isJdbcCharacterColumn()|| !introspectedColumn.isStringColumn()) {continue;}Method method = new Method();method.setVisibility(JavaVisibility.PUBLIC);method.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "pattern"));method.addParameter(new Parameter(introspectedColumn.getFullyQualifiedJavaType(), "value"));StringBuilder opNameBuilder = new StringBuilder(opName);opNameBuilder.setCharAt(0, Character.toUpperCase(opNameBuilder.charAt(0)));opName = opNameBuilder.toString();StringBuilder sb = new StringBuilder();sb.append(introspectedColumn.getJavaProperty());sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));sb.insert(0, "and"); //$NON-NLS-1$sb.append(opName);method.setName(sb.toString());method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());sb.setLength(0);sb.append("addCriterion(pattern.replace(\"").append(columnName).append("\", \"").append(Ibatis2FormattingUtilities.getAliasedActualColumnName(introspectedColumn)).append("\")").append(", value, \"").append(introspectedColumn.getJavaProperty());sb.append("\");");method.addBodyLine(sb.toString());method.addBodyLine("setCriterionPattern();");method.addBodyLine("return (Criteria) this;");criteria.addMethod(method);}}}

 

三、配置插件

<plugin type="com.mk.mybatisgenerator.plugins.MySQLMethodPlugin"><!--是否开启生成list参数,默认true开启--><property name="LIST_VALUE" value="true"/><!--value参数占位符自定义,默认##value##--><property name="VALUE_NAME" value="$value"/><!--column列名占位符自定义,默认##column##--><property name="COLUMN_NAME" value="$column"/><!--其他定义,name为方法后缀名,属性值为模式--><property name="isEmpty" value="$column = ''"/><property name="findInSet" value="find_in_set($value, $column)"/>
</plugin>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/322330.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

欢乐纪中某A组赛【2019.7.5】

前言 被花式暴虐&#xff0c;T1T1T1签到后两题神仙 成绩 JJJ表示初中&#xff0c;HHH表示高中后面加的是几年级 RankRankRankPersonPersonPersonScoreScoreScoreAAABBBCCC111(J−3)ZZY(J-3)ZZY(J−3)ZZY200200200100100100100100100000888(J−3)WHF(J-3)WHF(J−3)WHF145145145…

Mybatis生成器插件扩展,生成OR操作

Mybatis生成器插件扩展&#xff0c;生成OR操作 ManExample example new ManExample();ManExample.Criteria and example.createCriteria();and.andNameIsEmpty().andNameFindInSet("a").andNameFindInSetIn(Arrays.asList("1", "2", "3&q…

.NET Core单文件发布静态编译AOT CoreRT

.NET Core单文件发布静态编译AOT CoreRT&#xff0c;将.NET Core应用打包成一个可执行文件并包含运行时。支持Windows, MacOS and Linux x64 w/ RyuJIT codegen。示例项目&#xff1a;https://github.com/dotnet/corert/tree/master/samples/WebApi下面来实际体验。首先确保安装…

2019纪中暑假游记+总结

Travels总篇\texttt{Travels总篇}Travels总篇 7/4\texttt{7/4}7/4 下午才去纪中&#xff0c;早上就一大早和同学出去玩&#xff0c;看了蜘蛛侠然后到3点多才出发。 因为走南沙大桥所以很快就到了(具体有多快忘了&#xff0c;反正路上一点都不塞车)。就愉快的去整理宿舍洗个早…

使用xUnit为.net core程序进行单元测试(上)

一. 导读为什么要编写自动化测试程序&#xff08;Automated Tests&#xff09;&#xff1f;可以频繁的进行测试可以在任何时间进行测试&#xff0c;也可以按计划定时进行&#xff0c;例如&#xff1a;可以在半夜进行自动测试。肯定比人工测试要快。可以更快速的发现错误。基本上…

select2删除选中项,allowClear设置

转载自 select2删除选中项&#xff0c;allowClear设置 在使用select2过程中&#xff0c;有时候需要删除我们选中的选项&#xff0c;如下图&#xff1a; 这时候就需要设置select2的allowClear属性了。 有两种方法&#xff1a; 第一种&#xff1a; 直接用select2定义的一个c…

jzoj2679-跨时代【背包,dfs,状压】

正题 题目大意 若干根棍子&#xff0c;不能折&#xff0c;不能多余求能够组成的最大长方形。 解题思路 首先我们发现如果棍子集合SSS长度为lll且它有子集GGG长度为l2\frac{l}{2}2l​那么就表示这个集合的棍子可以作为一个矩形的对应两边&#xff0c;这样我们只要枚举两个不相…

LeetCode算法总结-回溯法与深度优先搜索

转载自 LeetCode算法总结-回溯法与深度优先搜索 回溯法&#xff08;探索与回溯法&#xff09;是一种选优搜索法&#xff0c;又称为试探法&#xff0c;按选优条件向前搜索&#xff0c;以达到目标。但当探索到某一步时&#xff0c;发现原先选择并不优或达不到目标&#xff0c;就…

Mybatis的配置与使用

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录前言一、Mybatis所用jar包二、使用步骤1.配置mybatis.xml文件2.创建与数据库对应的po类&#xff0c;提供get、set、toString方法3.创建与Dept对应的接口类&#xff1…

入门干货之用DVG打造你的项目主页-Docfx、Vs、Github

由于这三项技术涉及到的要点以及内容较多&#xff0c;希望大家有空能自己挖掘一下更多更深的用法。0x01、介绍VS&#xff0c;即VS2017以及以上版本&#xff0c;宇宙最好的IDE&#xff0c;集成了宇宙最有前景的平台&#xff0c;前阶段也支持了宇宙最好的语言。Github&#xff0c…

P2579,jzoj2288-[ZJOI2005]沼泽鳄鱼【矩阵乘法】

正题 题目链接:https://www.luogu.org/problemnew/show/P2579 题目大意 一张无向图&#xff0c;一个起点一个终点。 有食人鱼&#xff0c;在若干个点之间有周期的移动&#xff0c;周期为222或333或444个点为循环。 然后要求从起点到终点走kkk步且不碰到食人鱼的方案数。 解…

ASP.NET Core中使用IOC三部曲(一.使用ASP.NET Core自带的IOC容器)

前言本文主要是详解一下在ASP.NET Core中,自带的IOC容器相关的使用方式和注入类型的生命周期.这里就不详细的赘述IOC是什么 以及DI是什么了.. emm..不懂的可以自行百度.正文今天我们主要讲讲如何使用自带IOC容器,emm..虽然自带的功能不是那么强大,但是胜在轻量级..而且..不用引…

P4130,jzoj1214-[NOI2007]项链工厂【线段树】

正题 题目链接:https://www.luogu.org/problemnew/show/P4130 题目大意 一个环形颜色珠子链&#xff0c;位置(注意不是上面的珠子)从最上顺时针下来位置依次标号1∼n1\sim n1∼n。 然后要求支持以下操作 Rk:R\ k:R k:将所有珠子顺时针旋转kkk个。F:F:F:将所有珠子以111向下翻…

LeetCode常用算法模式大厂面试题整理

转载自 LeetCode常用算法模式&大厂面试题整理 文章目录 1、滑动窗口 2、双指针 3、快慢指针 4、合并区间 5、循环排序 6、就地反转链表 7、堆-优先队列问题 8、Top K 9、归并 10、单调栈 11、回溯法 BATJ等大厂面试真题汇总 1、滑动窗口 1 一个左指针&#xff0c;一个右…

ABPZero系列教程之拼多多卖家工具

此系列文章围绕着拼多多卖家工具来介绍ABPZero的使用&#xff0c;内容包括手机登录、手机注册、拼团提醒、微信公众号绑定帐号、有拼团发送消息到微信公众号&#xff08;只要关注过微信公众号并已绑定系统帐号&#xff09;。学习此系列必备&#xff1a;手机验证码&#xff1a;使…

欢乐纪中某A组赛【2019.7.6】

前言 斐大爷NBNBNB 成绩 JJJ表示初中&#xff0c;HHH表示高中后面加的是几年级 RankRankRankPersonPersonPersonScoreScoreScoreAAABBBCCC555(J−2)WYC(J-2)WYC(J−2)WYC210210210100100100100100100101010666(J−3)ZZY(J-3)ZZY(J−3)ZZY200200200100100100100100100000666(J−…

详解Vue中watch的高级用法

转载自 详解Vue中watch的高级用法 我们通过实例代码给大家分享了Vue中watch的高级用法&#xff0c;对此知识点有需要的朋友可以跟着学习下。 假设有如下代码&#xff1a; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <div> <p>FullName: {{fullName}}<…

g4e基础篇#4 了解Git存储库(Repo)

Git 存储库看上去就是一个文件夹&#xff0c;只是在这个文件夹中不仅仅保存了所有文件的当前版本&#xff0c;也同时保存了所有的历史记录&#xff0c;这些额外的信息都保存在当前文件夹下面的.git子目录中。因为前面我们所描述的git跟踪改动的特殊方式 &#xff0c;git可以在很…

P3846-[TJOI2007]可爱的质数【BSGS,数论】

正题 题目链接:https://www.luogu.org/problemnew/show/P3846 题目大意 BL≡N(modP)B^L\equiv N(mod\ P)BL≡N(mod P) 求最小的LLL。 解题思路 首先为了顺眼改一下变量名 Ax≡B(modP)A^x\equiv B(mod\ P)Ax≡B(mod P) 然后我们设xi∗t−j(0≤i≤t,0≤j≤t−1)xi*t-j(0\leq i\…