1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-04 22:41:24 +08:00

Added login, logout and getUserinfo (Include ui and server)

This commit is contained in:
2023-05-05 20:59:09 +08:00
parent a8dce8f8e0
commit 60b8460e03
32 changed files with 1022 additions and 151 deletions

View File

@@ -1,8 +1,17 @@
package com.cfive.pinnacle.controller.permission;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.Element;
import com.cfive.pinnacle.service.permission.IElementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 页面元素 前端控制器
@@ -14,5 +23,26 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/element")
public class ElementController {
private IElementService elementService;
@Autowired
public void setElementService(IElementService elementService) {
this.elementService = elementService;
}
@GetMapping
public ResponseResult getAllElement() {
List<Element> elements = elementService.list();
return ResponseResult.databaseSelectSuccess(elements);
}
@GetMapping("/{id}")
public ResponseResult getElement(@PathVariable long id) {
LambdaQueryWrapper<Element> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Element::getId, id);
Element element = elementService.getOne(wrapper);
return ResponseResult.databaseSelectSuccess(element);
}
}

View File

@@ -1,8 +1,17 @@
package com.cfive.pinnacle.controller.permission;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.File;
import com.cfive.pinnacle.service.permission.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 文件 前端控制器
@@ -14,5 +23,26 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/file")
public class FileController {
private IFileService fileService;
@Autowired
public void setFileService(IFileService fileService) {
this.fileService = fileService;
}
@GetMapping
public ResponseResult getAllFile() {
List<File> files = fileService.list();
return ResponseResult.databaseSelectSuccess(files);
}
@GetMapping("/{id}")
public ResponseResult getFile(@PathVariable int id) {
LambdaQueryWrapper<File> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(File::getId, id);
File file = fileService.getOne(wrapper);
return ResponseResult.databaseSelectSuccess(file);
}
}

View File

@@ -5,14 +5,14 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.permission.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@RestController
@CrossOrigin
public class LoginController {
private ILoginService loginService;
@@ -37,4 +37,11 @@ public class LoginController {
return ResponseResult.build(ResponseCode.LOGOUT_FAILED, "Logout Failed", null);
}
}
@GetMapping("/userInfo")
public ResponseResult getUserInfo() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Object principal = authentication.getPrincipal();
return ResponseResult.success(principal);
}
}

View File

@@ -1,8 +1,17 @@
package com.cfive.pinnacle.controller.permission;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.Menu;
import com.cfive.pinnacle.service.permission.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 菜单 前端控制器
@@ -14,5 +23,26 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/menu")
public class MenuController {
private IMenuService menuService;
@Autowired
public void setMenuService(IMenuService menuService) {
this.menuService = menuService;
}
@GetMapping
public ResponseResult getAllMenu() {
List<Menu> menus = menuService.list();
return ResponseResult.databaseSelectSuccess(menus);
}
@GetMapping("/{id}")
public ResponseResult getMenu(@PathVariable int id) {
LambdaQueryWrapper<Menu> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Menu::getId, id);
Menu menu = menuService.getOne(wrapper);
return ResponseResult.databaseSelectSuccess(menu);
}
}

View File

@@ -1,8 +1,17 @@
package com.cfive.pinnacle.controller.permission;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.Operation;
import com.cfive.pinnacle.service.permission.IOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 功能 前端控制器
@@ -14,5 +23,26 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/operation")
public class OperationController {
private IOperationService operationService;
@Autowired
public void setOperationService(IOperationService operationService) {
this.operationService = operationService;
}
@GetMapping
public ResponseResult getAllOperation() {
List<Operation> operations = operationService.list();
return ResponseResult.databaseSelectSuccess(operations);
}
@GetMapping("/{id}")
public ResponseResult getOperation(@PathVariable int id) {
LambdaQueryWrapper<Operation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Operation::getId, id);
Operation operation = operationService.getOne(wrapper);
return ResponseResult.databaseSelectSuccess(operation);
}
}

View File

@@ -1,8 +1,17 @@
package com.cfive.pinnacle.controller.permission;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.OperationLog;
import com.cfive.pinnacle.service.permission.IOperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 操作日志 前端控制器
@@ -14,5 +23,26 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/operationLog")
public class OperationLogController {
private IOperationLogService operationLogService;
@Autowired
public void setOperationLogService(IOperationLogService operationLogService) {
this.operationLogService = operationLogService;
}
@GetMapping
public ResponseResult getAllOperationLog() {
List<OperationLog> operationLogs = operationLogService.list();
return ResponseResult.databaseSelectSuccess(operationLogs);
}
@GetMapping("/{id}")
public ResponseResult getOperationLog(@PathVariable int id) {
LambdaQueryWrapper<OperationLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(OperationLog::getId, id);
OperationLog operationLog = operationLogService.getOne(wrapper);
return ResponseResult.databaseSelectSuccess(operationLog);
}
}

View File

@@ -1,5 +1,10 @@
package com.cfive.pinnacle.controller.permission;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.PowerSet;
import com.cfive.pinnacle.service.permission.IPowerService;
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;
@@ -14,5 +19,17 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/power")
public class PowerController {
private IPowerService powerService;
@Autowired
public void setPowerService(IPowerService powerService) {
this.powerService = powerService;
}
@GetMapping
public ResponseResult getAllPower() {
PowerSet powerSet = powerService.getAllPower();
return ResponseResult.databaseSelectSuccess(powerSet);
}
}

View File

@@ -1,11 +1,11 @@
package com.cfive.pinnacle.controller.permission;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.entity.permission.*;
import com.cfive.pinnacle.service.permission.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -22,16 +22,25 @@ import java.util.List;
@RestController
@RequestMapping("/powerType")
public class PowerTypeController {
IPowerService powerTypeService;
IPowerTypeService powerTypeService;
@Autowired
public void setPowerTypeService(IPowerService powerTypeService) {
public void setPowerTypeService(IPowerTypeService powerTypeService) {
this.powerTypeService = powerTypeService;
}
@GetMapping
public ResponseResult getAllPowerType() {
List<Power> powerTypes = powerTypeService.list();
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", powerTypes);
List<PowerType> powerTypes = powerTypeService.list();
return ResponseResult.databaseSelectSuccess(powerTypes);
}
@GetMapping("/{id}")
public ResponseResult getPowerType(@PathVariable int id) {
LambdaQueryWrapper<PowerType> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PowerType::getId, id);
PowerType powerType = powerTypeService.getOne(wrapper);
return ResponseResult.databaseSelectSuccess(powerType);
}
}