2024.4.12
加入了SaToken的注解鉴权
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package com.hongliang.videotask.config;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||||
|
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
||||||
|
registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hongliang.videotask.controller;
|
package com.hongliang.videotask.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||||
import com.hongliang.videotask.common.Response;
|
import com.hongliang.videotask.common.Response;
|
||||||
import com.hongliang.videotask.common.ResponseCode;
|
import com.hongliang.videotask.common.ResponseCode;
|
||||||
import com.hongliang.videotask.service.impl.NodeServiceImpl;
|
import com.hongliang.videotask.service.impl.NodeServiceImpl;
|
||||||
@@ -17,6 +18,7 @@ public class NodeControl {
|
|||||||
@Resource
|
@Resource
|
||||||
private NodeServiceImpl nodeService;
|
private NodeServiceImpl nodeService;
|
||||||
|
|
||||||
|
@SaCheckLogin
|
||||||
@PostMapping("list")
|
@PostMapping("list")
|
||||||
public ResponseEntity<?> GetNodeListByCondition(@RequestBody String condition){
|
public ResponseEntity<?> GetNodeListByCondition(@RequestBody String condition){
|
||||||
return ResponseEntity.ok(new Response(ResponseCode.OK,"success",
|
return ResponseEntity.ok(new Response(ResponseCode.OK,"success",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hongliang.videotask.controller;
|
package com.hongliang.videotask.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.hongliang.videotask.bean.LoginBean;
|
import com.hongliang.videotask.bean.LoginBean;
|
||||||
import com.hongliang.videotask.bean.LoginResultBean;
|
import com.hongliang.videotask.bean.LoginResultBean;
|
||||||
@@ -56,8 +57,9 @@ public class UserControl {
|
|||||||
return ResponseEntity.ok(new Response(ResponseCode.OK,"成功退出",null));
|
return ResponseEntity.ok(new Response(ResponseCode.OK,"成功退出",null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("getuserbyid")
|
@SaCheckLogin
|
||||||
public ResponseEntity<?> GetUserByID(@RequestParam("id") int id){
|
@GetMapping("/user/{id}")
|
||||||
|
public ResponseEntity<?> GetUserByID(@PathVariable("id") int id){
|
||||||
return ResponseEntity.ok(new Response(ResponseCode.OK,"成功",userService.GetUserByID(id)));
|
return ResponseEntity.ok(new Response(ResponseCode.OK,"成功",userService.GetUserByID(id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package com.hongliang.videotask.mappers;
|
|||||||
|
|
||||||
import com.hongliang.videotask.MapperProvider.NodeProvider;
|
import com.hongliang.videotask.MapperProvider.NodeProvider;
|
||||||
import com.hongliang.videotask.bean.NodeBean;
|
import com.hongliang.videotask.bean.NodeBean;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
|
import org.apache.ibatis.annotations.Options;
|
||||||
import org.apache.ibatis.annotations.SelectProvider;
|
import org.apache.ibatis.annotations.SelectProvider;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,4 +18,13 @@ public interface NodeMapper {
|
|||||||
|
|
||||||
@SelectProvider(type=NodeProvider.class,method="GetTotal")
|
@SelectProvider(type=NodeProvider.class,method="GetTotal")
|
||||||
int GetTotal(Map<String,Object> condition);
|
int GetTotal(Map<String,Object> condition);
|
||||||
|
|
||||||
|
@Insert("insert into node (nodename) values (#nodename)")
|
||||||
|
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||||
|
int InsertNode(NodeBean nodeBean);
|
||||||
|
|
||||||
|
@Update("update node set nodename=#{#nodename} where id=#{id}")
|
||||||
|
int UpdateNode(NodeBean nodeBean);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user