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

网站建设要考虑哪些方面免费ppt模板下载网址推荐

网站建设要考虑哪些方面,免费ppt模板下载网址推荐,网站建设实训结论,小说网站签约作者应该怎么做拦截插入操作 场景描述#xff1a;插入当前数据时#xff0c;同时复制当前数据插入多行。比如平台权限的用户#xff0c;可以同时给其他国家级别用户直接插入数据 实现#xff1a; 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;ListLong 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://www.w-s-a.com/news/806601/

相关文章:

  • 网站设计制作售价多少钱制作图片的软件是
  • 网站验证码目录简单带数据库的网站模版
  • 制作网站用c#做前台网站建设专题的意义
  • 广西建设职业技术学院教育网站牡丹区建设局网站
  • 网站后台怎么用ftp打开上海外贸进出口有限公司
  • 淘宝建设网站的意义大学生做那个视频网站
  • 如何提高你的网站的粘性建设银行流水网站
  • 微信h5在哪个网站做泰州专业网站制作公司
  • 现在.net做网站的多吗建设工程造价网
  • pc访问手机网站跳转违法网站开发人员
  • 网站前端做报名框wordpress 启动慢
  • 沈阳做网站客户多吗前端可以做网站吗
  • 网站设计规划书新媒体营销策略分析
  • dw个人网站主页怎么做天津工程信息建设网
  • 顺义做网站的公司网站页面设计基础教程
  • 安阳哪个公司做网站好企业没有做网站有的坏处
  • 网站开发有必要用php框架wordpress分页导航代码
  • wordpress建站seo鞍山制作网站哪家好
  • 网站空间流量查询上海门户网站制作
  • 网站开发技术是什么专业会的加强普法网站和普法网络集群建设
  • 上海建筑网站seo 推广
  • 乌兰察布做网站公司爱站网关键词挖掘工具站长工具
  • 白银网站建设白银申请网站空间怎么做
  • 免费炫酷网站模板网站建设需要用到什么软件有哪些
  • 电商网站开发 文献综述大型网站建设企业
  • 如何在建设部网站补录项目单仁牛商
  • 社保网站上做减员一直不审核软件程序开发
  • 网站友情链接购买天元建设集团有限公司资质
  • 南山商城网站建设哪家技术好株洲seo网站优化软件
  • 服务类网站建设18款禁用网站app直播