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

温州哪里做网站设计wordpress免签约支付

温州哪里做网站设计,wordpress免签约支付,现在网站给源码,营销型网站设计注意AOP到底是啥 前言面向切面编程到底是啥意思那么要怎么实现面向切面编程呢#xff1f;成果 前言 回忆起来#xff0c;第一次听到这三字母是博主在上大二的时候#xff0c;那时候看的一脸懵逼#xff0c;现在马上研二了才想起来回顾下。 只记得当时面向对象编程还没整明白成果 前言 回忆起来第一次听到这三字母是博主在上大二的时候那时候看的一脸懵逼现在马上研二了才想起来回顾下。 只记得当时面向对象编程还没整明白这一下子又来个面向切面编程这直接给整懵了。。。。 面向对象相信大家都很了解了那咱们接下来看看什么是面向切面编程。 面向切面编程到底是啥意思 咱不整哪些官方话术了整点通俗的。 想象以下这样的一个场景你接手了一个人员管理系统这个项目并没有做任何的权限管理并且大部分功能已经完成这时候甲方突然来了个新需求我现在希望你加上对人员管理的权限即部门经理只能管理其部门的人员不能管理其他部门的人员。 这时候你可能想到要不加个安全框架但很快你就放弃了因为这种需要给权限的接口实在是太多了总不能一个个根据用户权限限制管理权限这么去改吧。 这时候aop的作用就出现了 那可以怎么做呢 我们通常会将包含接口的Controller都放在一个package中这时候我们就在想我们可不可以在职工id传递给接口之前对传递的职工id操作一下呢 即前端传递过来之后我们在对这些id再进行一次审核将没有权限管理的职工id删掉可以不 很幸运可以 我们可以认为客户端到调用接口这之间存在一个面在这个面上我们可以处理将要传递给接口的id参数进行处理将那些没有权限操作的id直接删除。这个面就可以认为是切面面向切面编程就是这样。 这里只是一个例子切面不仅存在这种情况中对象和对象之间方法和方法之间等等之间都可以认为是一个切面。 那么要怎么实现面向切面编程呢 这里我们用注解的方式实现 首先就是我们怎么监视这个面呢 先看下接口 package com.xiaow.springsecuriydemo.controller;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.xiaow.springsecuriydemo.entity.Person; import com.xiaow.springsecuriydemo.service.PersonService; import com.xiaow.springsecuriydemo.vo.Result; import io.jsonwebtoken.lang.Collections; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import java.util.Collection; import java.util.List;/*** p* 前端控制器* /p** author xiaow* since 2023-09-01*/ RestController RequestMapping(/person) public class PersonController {AutowiredPersonService personService;GetMapping(getPersons)public Result getPersons(int adminid, int[] personids) {LambdaQueryWrapperPerson personLambdaQueryWrapper new LambdaQueryWrapper();List list1 Collections.arrayToList(personids);personLambdaQueryWrapper.in(Person::getId, list1);ListPerson list personService.list(personLambdaQueryWrapper);return Result.succ(list);}} 这里的mplus操作就交给大家去写了。 来了解下怎么写Aspect Before(value execution(* com.xiaow.springsecuriydemo.controller.*.*(..)))Before也就是在接口执行前我们对其进行操作com.xiaow.springsecuriydemo.controller就是我们存放controller的包后面的第一个*代表任意一个Controller第二个* 就是任意的方法 其意义就是在com.xiaow.springsecuriydemo.controller下的所有接口执行前做一步处理那么处理什么呢 当然是处理传递的员工id就是把那些无权限处理的id替代掉这里我们使用-1来代替因为id为-1不会指向任何员工信息。 看下完整的代码 package com.xiaow.springsecuriydemo.aop.advice;import com.xiaow.springsecuriydemo.aop.annotation.ArgsAnnotation; import com.xiaow.springsecuriydemo.aop.annotation.ArraysAnnotation; import com.xiaow.springsecuriydemo.entity.Admin; import com.xiaow.springsecuriydemo.entity.Person; import com.xiaow.springsecuriydemo.service.AdminService; import com.xiaow.springsecuriydemo.service.PersonService; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;import java.lang.annotation.Annotation; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.util.Arrays; import java.util.List;Aspect Component public class PersonAdvice {AutowiredAdminService adminService;AutowiredPersonService personService;// 在进入接口之前执行Before(value execution(* com.xiaow.springsecuriydemo.controller.*.*(..)))public void before(JoinPoint joinPoint) throws IllegalAccessException, NoSuchFieldException {final Signature signature joinPoint.getSignature();MethodSignature methodSignature (MethodSignature) signature;// 获取参数的名字final String[] names methodSignature.getParameterNames();// 获取参数的值final Object[] args joinPoint.getArgs();int admin_index -1;int personid_index -1;// 获取到adminid和personids的下标位置for (int i 0; i names.length; i) {if (names[i].equals(adminid)) {admin_index i;}if (names[i].equals(personids)) {personid_index i;}}Integer adminid (Integer) args[admin_index];int [] personid (int[]) args[personid_index];Admin byId adminService.getById(adminid);if (byId ! null) {Integer deptid byId.getDeptid();ListPerson byDeptIdAndPersonids personService.getByDeptIdAndPersonids(deptid, personid);int[] personids (int[]) args[personid_index];for (Integer i 0; i personids.length; i) {boolean flag false;for (Person byDeptIdAndPersonid : byDeptIdAndPersonids) {if (personids[i] byDeptIdAndPersonid.getId())flag true;} // 若不在有权限的id中则直接设置为-1if (!flag)Array.setInt(personid, i, -1);}}}// 在接口执行完毕后执行After(value execution(* com.xiaow.springsecuriydemo.controller.*.*(..)))public void after() {System.out.println(after);}}成果 就这样我们在不修改原有的接口的情况下实现了权限控制如下图
http://www.pierceye.com/news/568141/

相关文章:

  • 东莞品牌网站建设多少钱网站设计有限公司怎么样
  • dedecms新网站 上传到万网的空间浦口区网站建站公司
  • 龙岗在线网站建设西安房产信息网
  • 如何建立公司企业网站大朗做网站的
  • 怎么做整蛊网站wordpress系统的特点
  • php网站开发视频教程浙江建设局网站
  • 温州seo顾问温州网站优化排名推广
  • qq空间怎么做网站wordpress 分类名
  • 外贸国际网站推广重庆律师网站
  • 唐山建设信息网站wordpress 首页显示产品
  • 建设网站的公司哪个济南兴田德润怎么联系重庆短视频培训
  • 营销型网站的建设方案企业网页设计作品分析
  • 网站建设的费用报价做网站销售这几天你有什么想法
  • 做箱包关注哪个网站类似建站之星网站
  • 口碑好网站建设报价wordpress 微博侧边栏
  • 长沙 建站优化花都区手机版网站建设
  • 网站自动弹窗代码国外哪些网站可以兼职做任务
  • 怎么查看网站服务器位置wordpress 数据表结构
  • 国外做家纺的网站有些网站开发人员工具无反应
  • 泉州做网站个人网站备案号可以做企业网站吗
  • 苏州姑苏区专业做网站国外购物网站建设
  • 蒙牛官网网站怎么做的爱站网备案查询
  • 天津市建设工程监理公司网站电商seo引流
  • 导航网站链接怎么做wordpress教育相关的模板
  • 招聘网站建设人员条件wordpress有后端吗
  • 3g免费网站制作做美图 网站
  • 网站建设有哪些知识点图片制作软件哪个好用
  • 百度站长工具使用方法石岩医院网站建设
  • 网站一直百度上搜不到是怎么回事宝安大型商城网站建设
  • 本地营销型网站建设学校网站制作方案