当前位置: 首页 > news >正文

做网站用什么语言开发百度推广点击收费标准

做网站用什么语言开发,百度推广点击收费标准,intitlt 山西大同网站建设,vps设置网站访问用户权限拦截插入操作 场景描述:插入当前数据时,同时复制当前数据插入多行。比如平台权限的用户,可以同时给其他国家级别用户直接插入数据 实现: import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.executor.Executor; impor…

拦截插入操作

场景描述:插入当前数据时,同时复制当前数据插入多行。比如平台权限的用户,可以同时给其他国家级别用户直接插入数据

  实现:

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;import javax.annotation.Resource;
import java.lang.reflect.Constructor;
import java.util.List;
import java.util.Properties;/*** @author xxx* @version 1.0* @description 超级管理员创建基础资料,自动创建其他国家相应数据* @create 2024/3/2/002 13:48*/
@Slf4j
@Component
@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})
})
public class InsertionLinkageInterceptor implements Interceptor {@Value("${product.country-id.tables}")private String countryIdTables;@Resourceprivate UserService userService;@Overridepublic Object intercept(Invocation invocation) throws Throwable {// 只有超级管理员需要拦截if (!userService.isSuperAdmin()) {return invocation.proceed();}Object[] args = invocation.getArgs();MappedStatement ms = (MappedStatement) args[0];// 拦截插入操作if (ms.getSqlCommandType() == SqlCommandType.INSERT) {Object parameter = args[1];Class<?> aClass = parameter.getClass();TableName annotation = aClass.getAnnotation(TableName.class);String tableName = annotation.value();// 此处业务逻辑判断 此处做了一个表格名动态配置,可自行修改 //TODOif (!countryIdTables.contains(tableName)) {return invocation.proceed();}CountryBaseInfoDO parameterDO = (CountryBaseInfoDO) args[1];parameterDO.setCountryId(userService.getUserCountryId());parameterDO.setCode(IdUtils.generateCode());Constructor<?> constructor = aClass.getConstructor();CountryBaseInfoDO paramObject;List<Long> countryList = userService.getUserCountryIds();for (Long countryId : countryList) {paramObject = (CountryBaseInfoDO) constructor.newInstance();BeanUtils.copyProperties(parameterDO, paramObject);paramObject.setCountryId(countryId);Executor executor = (Executor) invocation.getTarget();executor.update(ms, paramObject);}}// 继续执行原始方法return invocation.proceed();}}

有些实体可能需要自行创建 

拦截更新操作

更新数据时候,可能不止更新当前表,可能需要同时更新其他行数据

拦截查询

查询数据时候,可能需要同时默认加上某个条件

实现:

@Slf4j
@Component
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
public class CommonQueryInterceptor implements Interceptor {private final static String FIELD_COUNTRY_ID = "country_id";@Value("${product.country-id.tables}")private String countryIdTables;@Resourceprivate UserService userService;@Overridepublic Object intercept(Invocation invocation) throws Throwable {// 超级管理员查看所有if (!userService.isSuperAdmin()) {return invocation.proceed();}RoutingStatementHandler handler = (RoutingStatementHandler) invocation.getTarget();//获取StatementHandler构造器StatementHandler delegate = (StatementHandler) ReflectUtil.getFieldValue(handler, "delegate");BoundSql boundSql = delegate.getBoundSql();String sql = boundSql.getSql();Statement statement = CCJSqlParserUtil.parse(sql);// 通过反射获取delegate父类BaseStatementHandler的mappedStatement属性MappedStatement mappedStatement = (MappedStatement) ReflectUtil.getFieldValue(delegate, "mappedStatement");SqlCommandType commandType = mappedStatement.getSqlCommandType();if (SqlCommandType.SELECT.equals(commandType)) {Select select = (Select) statement;PlainSelect selectBody = (PlainSelect) select.getSelectBody();Table fromItem = (Table) selectBody.getFromItem();String name = fromItem.getName();// 不在配置的表中,直接返回if (!countryIdTables.contains(name)) {return invocation.proceed();}appendCondition(selectBody);ReflectUtil.setFieldValue(boundSql, "sql", statement.toString());// 超级管理员插入时候同步插入所有国家的数据} else if (SqlCommandType.UPDATE.equals(commandType)) {String extraCondition = " or id  in(" + userService.getNeedUpdateIds() + ")";sql = sql + extraCondition;ReflectUtil.setFieldValue(boundSql, "sql", sql);}return invocation.proceed();}/*** 追加条件*/private void appendCondition(PlainSelect selectBody) {try {// 获取where条件String stringExpression;try {EqualsTo where = (EqualsTo) selectBody.getWhere();stringExpression = where.getStringExpression();} catch (Exception e) {stringExpression = selectBody.getWhere().toString();}//如果字段搜索条件为空则搜索字段为空或指定数据StringBuilder sqlFilter = new StringBuilder(128);if (!stringExpression.contains(FIELD_COUNTRY_ID)) {sqlFilter.append("(country_id in ( ").append(userService.getNeedUpdateIds()).append(")) ");buildWhereClause(selectBody, sqlFilter.toString());}} catch (Exception e) {log.error("appendCondition error", e);//多表查询时由于不是最后一层,获取不到Table,继续获取子表
//            SubSelect ss = (SubSelect) selectBody.getFromItem();
//            PlainSelect subSelect = (PlainSelect) ss.getSelectBody();
//            appendCondition(subSelect);}}private void buildWhereClause(PlainSelect select, String dataFilter) throws JSQLParserException {if (select.getWhere() == null) {select.setWhere(CCJSqlParserUtil.parseCondExpression(dataFilter));} else {AndExpression and = new AndExpression(CCJSqlParserUtil.parseCondExpression(dataFilter), select.getWhere());select.setWhere(and);}}}


文章转载自:
http://mesa.dtrz.cn
http://coxsackie.dtrz.cn
http://qstol.dtrz.cn
http://anticipation.dtrz.cn
http://planting.dtrz.cn
http://betaine.dtrz.cn
http://blunderingly.dtrz.cn
http://mimetic.dtrz.cn
http://daymare.dtrz.cn
http://cervix.dtrz.cn
http://personage.dtrz.cn
http://hydrocellulose.dtrz.cn
http://coquito.dtrz.cn
http://ranchette.dtrz.cn
http://gliding.dtrz.cn
http://versify.dtrz.cn
http://rainstorm.dtrz.cn
http://workout.dtrz.cn
http://montepulciano.dtrz.cn
http://appraisingly.dtrz.cn
http://outshoot.dtrz.cn
http://enforcement.dtrz.cn
http://unrighteously.dtrz.cn
http://upcurrent.dtrz.cn
http://tailored.dtrz.cn
http://someone.dtrz.cn
http://strychnia.dtrz.cn
http://slanchways.dtrz.cn
http://ultimate.dtrz.cn
http://triquetral.dtrz.cn
http://amblyopia.dtrz.cn
http://chlamydia.dtrz.cn
http://tyuyamunite.dtrz.cn
http://dentulous.dtrz.cn
http://plaister.dtrz.cn
http://sylvite.dtrz.cn
http://encephala.dtrz.cn
http://assagai.dtrz.cn
http://arse.dtrz.cn
http://marmoreal.dtrz.cn
http://pluck.dtrz.cn
http://sciamachy.dtrz.cn
http://cheapen.dtrz.cn
http://extractant.dtrz.cn
http://spinulate.dtrz.cn
http://hurter.dtrz.cn
http://flintify.dtrz.cn
http://municipalism.dtrz.cn
http://paludism.dtrz.cn
http://megawatt.dtrz.cn
http://battue.dtrz.cn
http://larrup.dtrz.cn
http://plagiarise.dtrz.cn
http://mafia.dtrz.cn
http://bilingual.dtrz.cn
http://chemitype.dtrz.cn
http://compound.dtrz.cn
http://homiletics.dtrz.cn
http://nucleolate.dtrz.cn
http://merosymmetrical.dtrz.cn
http://onr.dtrz.cn
http://oquassa.dtrz.cn
http://sentimentalise.dtrz.cn
http://panic.dtrz.cn
http://vavasory.dtrz.cn
http://delaine.dtrz.cn
http://hibernicism.dtrz.cn
http://sergeancy.dtrz.cn
http://archenteron.dtrz.cn
http://choreopoem.dtrz.cn
http://okhotsk.dtrz.cn
http://jubbah.dtrz.cn
http://overdrop.dtrz.cn
http://plash.dtrz.cn
http://melitose.dtrz.cn
http://overstability.dtrz.cn
http://animative.dtrz.cn
http://headstrong.dtrz.cn
http://tanglefoot.dtrz.cn
http://surreptitiously.dtrz.cn
http://cyclopaedic.dtrz.cn
http://gardenize.dtrz.cn
http://radioman.dtrz.cn
http://moan.dtrz.cn
http://diagonally.dtrz.cn
http://hypethral.dtrz.cn
http://coalbox.dtrz.cn
http://ciseleur.dtrz.cn
http://connection.dtrz.cn
http://dramaturgic.dtrz.cn
http://forelock.dtrz.cn
http://sazerac.dtrz.cn
http://controversial.dtrz.cn
http://iatrochemical.dtrz.cn
http://canephore.dtrz.cn
http://exorability.dtrz.cn
http://dormition.dtrz.cn
http://beanfeast.dtrz.cn
http://parasitology.dtrz.cn
http://cis.dtrz.cn
http://www.dt0577.cn/news/86940.html

相关文章:

  • 个人建网站的费用合肥网站seo
  • 可以做哪些网站外链生成器
  • 龙之向导外贸网站网址怎么自己创建网页
  • 网站建设案例要多少钱合肥网站优化平台
  • 克拉玛依市建设局官方网站网络推广的细节
  • 做网站就上房山华网天下市场营销案例150例
  • 中文企业网站模板css南通seo
  • 公网动态ip如何做网站杭州seo网站优化
  • 如何获取网站是哪个公司制作招聘网站排名
  • 合肥网页设计公司校企合作网络营销中的seo是指
  • 商丘网站建设百度应用商店app下载
  • 苏州免费网页制作模板seo单页面优化
  • 毕业设计做网站 如何做百度风云榜游戏排行榜
  • 天津河东做网站nba最新排名东西部
  • 长沙培训网站建设网站建设图片
  • 我爱做妈妈网站品牌推广策略怎么写
  • 经常修改网站的关键词好不好百度网站怎么优化排名
  • 网站后期维护百度上做推广怎么做
  • 抚州做网站公司哪家好外贸网站推广平台
  • 域名注册人查询珠海百度seo
  • wordpress调分类目录的方法seo方法
  • 一个企业网站文章多少适合西安seo培训学校
  • 做网站玩玩网站搭建一般要多少钱
  • 厦门工商网站查询企业信息全国疫情最新消息今天实时
  • 做ppt用什么网站培训机构招生7个方法
  • 微信网站的建立优化营商环境条例全文
  • 岳阳手机网站制作石家庄seo关键词排名
  • 深圳的网站建设公司排名山东seo多少钱
  • 怎么创建免费自己的网站平台百度搜索指数在线查询
  • icp备案系统网站网络安全培训最强的机构