Commit 61266f59 authored by gary's avatar gary

1、添加后端鉴权

parent cd2eb749
package pwc.taxtech.atms.controller; package pwc.taxtech.atms.controller;
import io.swagger.annotations.ApiOperation;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService; import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService; import org.activiti.engine.TaskService;
...@@ -8,14 +9,13 @@ import org.slf4j.Logger; ...@@ -8,14 +9,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.common.util.MyAsserts; import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.dto.approval.ApprovalDto; import pwc.taxtech.atms.dto.approval.ApprovalDto;
import pwc.taxtech.atms.dto.approval.ApprovalTask;
import pwc.taxtech.atms.entity.Template; import pwc.taxtech.atms.entity.Template;
import pwc.taxtech.atms.exception.Exceptions; import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dpo.ApprovalTaskInfo; import pwc.taxtech.atms.vat.dpo.ApprovalTaskInfo;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import pwc.taxtech.atms.vat.service.impl.ApprovalService; import pwc.taxtech.atms.vat.service.impl.ApprovalService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -35,7 +35,6 @@ public class ApprovalController { ...@@ -35,7 +35,6 @@ public class ApprovalController {
@Autowired @Autowired
RepositoryService repositoryService; RepositoryService repositoryService;
@ResponseBody @ResponseBody
@RequestMapping(value = "/deploy", method = RequestMethod.POST) @RequestMapping(value = "/deploy", method = RequestMethod.POST)
public ResponseEntity deploy() { public ResponseEntity deploy() {
...@@ -43,8 +42,10 @@ public class ApprovalController { ...@@ -43,8 +42,10 @@ public class ApprovalController {
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@ApiOperation(value = "提交报表")
@ResponseBody @ResponseBody
@RequestMapping(value = "/commit", method = RequestMethod.POST) @RequestMapping(value = "/commit", method = RequestMethod.POST)
@Secured("vatApproval:commit")
public ApprovalDto approval(@RequestBody ApprovalDto dto) { public ApprovalDto approval(@RequestBody ApprovalDto dto) {
MyAsserts.assertNotEmpty(dto.getProjectId(), Exceptions.EMPTY_PROJECT_PARAM); MyAsserts.assertNotEmpty(dto.getProjectId(), Exceptions.EMPTY_PROJECT_PARAM);
MyAsserts.assertNotEmpty(dto.getPeriodDate(), Exceptions.EMPTY_PRIODDATE_PARAM); MyAsserts.assertNotEmpty(dto.getPeriodDate(), Exceptions.EMPTY_PRIODDATE_PARAM);
...@@ -64,8 +65,10 @@ public class ApprovalController { ...@@ -64,8 +65,10 @@ public class ApprovalController {
return approvalService.getTemplateInfo(templateId); return approvalService.getTemplateInfo(templateId);
} }
@ApiOperation(value = "审批报表")
@ResponseBody @ResponseBody
@RequestMapping(value = "/check/{projectId}/{period}",method = RequestMethod.PUT) @RequestMapping(value = "/check/{projectId}/{period}",method = RequestMethod.PUT)
@Secured("vatApproval:check")
public void check(@PathVariable String projectId,@PathVariable Integer period, @RequestParam String decide, @RequestParam String comment) {//only for manager role public void check(@PathVariable String projectId,@PathVariable Integer period, @RequestParam String decide, @RequestParam String comment) {//only for manager role
approvalService.checkTask(projectId, period, decide,comment); approvalService.checkTask(projectId, period, decide,comment);
} }
......
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -99,6 +100,7 @@ public class RoleController { ...@@ -99,6 +100,7 @@ public class RoleController {
@ApiOperation(value = "删除角色下用户") @ApiOperation(value = "删除角色下用户")
@RequestMapping(value = "removeUserRole", method = RequestMethod.POST) @RequestMapping(value = "removeUserRole", method = RequestMethod.POST)
@Secured("role:edit")
public @ResponseBody public @ResponseBody
Boolean removeUserRole(@RequestParam("userID") String userId, Boolean removeUserRole(@RequestParam("userID") String userId,
@RequestBody List<String> roleIdList, @RequestParam("serviceTypeID") String serviceTypeId) { @RequestBody List<String> roleIdList, @RequestParam("serviceTypeID") String serviceTypeId) {
...@@ -115,6 +117,7 @@ public class RoleController { ...@@ -115,6 +117,7 @@ public class RoleController {
@ApiOperation(value = "增加角色分类") @ApiOperation(value = "增加角色分类")
@RequestMapping(value = "addRoleCategory", method = RequestMethod.GET) @RequestMapping(value = "addRoleCategory", method = RequestMethod.GET)
@Secured("roleCategory:add")
public @ResponseBody public @ResponseBody
Boolean addRoleCategory(@RequestParam("name") String roleCategoryName, Boolean addRoleCategory(@RequestParam("name") String roleCategoryName,
@RequestParam("roleCategoryID") String roleCategoryId) { @RequestParam("roleCategoryID") String roleCategoryId) {
...@@ -124,6 +127,7 @@ public class RoleController { ...@@ -124,6 +127,7 @@ public class RoleController {
@ApiOperation(value = "更新角色分类名称") @ApiOperation(value = "更新角色分类名称")
@RequestMapping(value = "updateRoleCategory", method = RequestMethod.GET) @RequestMapping(value = "updateRoleCategory", method = RequestMethod.GET)
@Secured("roleCategory:edit")
public @ResponseBody public @ResponseBody
Boolean updateRoleCategory(@RequestParam("updateName") String roleCategoryName, Boolean updateRoleCategory(@RequestParam("updateName") String roleCategoryName,
@RequestParam("id") String roleCategoryId) { @RequestParam("id") String roleCategoryId) {
...@@ -134,6 +138,7 @@ public class RoleController { ...@@ -134,6 +138,7 @@ public class RoleController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "删除角色分类") @ApiOperation(value = "删除角色分类")
@RequestMapping(value = "deleteRoleCategory", method = RequestMethod.GET) @RequestMapping(value = "deleteRoleCategory", method = RequestMethod.GET)
@Secured("roleCategory:edit")
public @ResponseBody public @ResponseBody
OperationResultDto deleteRoleCategory(@RequestParam("id") String roleCategoryId) { OperationResultDto deleteRoleCategory(@RequestParam("id") String roleCategoryId) {
return roleService.deleteRoleCategory(roleCategoryId); return roleService.deleteRoleCategory(roleCategoryId);
...@@ -142,6 +147,7 @@ public class RoleController { ...@@ -142,6 +147,7 @@ public class RoleController {
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@ApiOperation(value = "Add a role info") @ApiOperation(value = "Add a role info")
@RequestMapping(value = "add", method = RequestMethod.POST) @RequestMapping(value = "add", method = RequestMethod.POST)
@Secured("role:add")
public @ResponseBody public @ResponseBody
Map addRole(@RequestBody RoleDisplayDto roleDisplayDto) { Map addRole(@RequestBody RoleDisplayDto roleDisplayDto) {
...@@ -156,6 +162,7 @@ public class RoleController { ...@@ -156,6 +162,7 @@ public class RoleController {
@ApiOperation(value = "Update a role info") @ApiOperation(value = "Update a role info")
@RequestMapping(value = "update", method = RequestMethod.PUT) @RequestMapping(value = "update", method = RequestMethod.PUT)
@Secured("role:edit")
public void updateRole(@RequestBody UpdateRoleInfo updateRole, @RequestParam("roleID") String roleId) { public void updateRole(@RequestBody UpdateRoleInfo updateRole, @RequestParam("roleID") String roleId) {
roleService.updateRole(updateRole, roleId); roleService.updateRole(updateRole, roleId);
...@@ -178,6 +185,7 @@ public class RoleController { ...@@ -178,6 +185,7 @@ public class RoleController {
@ApiOperation(value = "Delete a role info") @ApiOperation(value = "Delete a role info")
@RequestMapping(value = "delete", method = RequestMethod.POST) @RequestMapping(value = "delete", method = RequestMethod.POST)
@Secured("role:edit")
public @ResponseBody public @ResponseBody
List<RoleDtoTree> deleteRole(@RequestBody RoleDto roleDto) { List<RoleDtoTree> deleteRole(@RequestBody RoleDto roleDto) {
...@@ -210,6 +218,7 @@ public class RoleController { ...@@ -210,6 +218,7 @@ public class RoleController {
@ApiOperation(value = "更新用户角色列表") @ApiOperation(value = "更新用户角色列表")
@RequestMapping(value = "updateUserRole", method = RequestMethod.POST) @RequestMapping(value = "updateUserRole", method = RequestMethod.POST)
@Secured("role:edit")
public Boolean updateUserRole(@RequestBody UserRoleUpdateDto userRoleDto) { public Boolean updateUserRole(@RequestBody UserRoleUpdateDto userRoleDto) {
roleService.updateUserRole(userRoleDto); roleService.updateUserRole(userRoleDto);
...@@ -218,6 +227,7 @@ public class RoleController { ...@@ -218,6 +227,7 @@ public class RoleController {
@ApiOperation(value = "用户详情页面,增加范围") @ApiOperation(value = "用户详情页面,增加范围")
@RequestMapping(value = "updateDimensionValues", method = RequestMethod.POST) @RequestMapping(value = "updateDimensionValues", method = RequestMethod.POST)
@Secured("role:edit")
public Boolean updateDimensionValues(@RequestBody DimensionValueUpdateDto dimensionValueUpdateDto) { public Boolean updateDimensionValues(@RequestBody DimensionValueUpdateDto dimensionValueUpdateDto) {
roleService.updateDimensionValues(dimensionValueUpdateDto); roleService.updateDimensionValues(dimensionValueUpdateDto);
...@@ -226,6 +236,7 @@ public class RoleController { ...@@ -226,6 +236,7 @@ public class RoleController {
@ApiOperation(value = "用户详情页面,增加机构") @ApiOperation(value = "用户详情页面,增加机构")
@RequestMapping(value = "updateUserOrg", method = RequestMethod.POST) @RequestMapping(value = "updateUserOrg", method = RequestMethod.POST)
@Secured("role:edit")
public Boolean updateUserOrg(@RequestBody List<String> orgIdList, @RequestParam("userID") String userId) { public Boolean updateUserOrg(@RequestBody List<String> orgIdList, @RequestParam("userID") String userId) {
roleService.updateUserOrg(orgIdList, userId); roleService.updateUserOrg(orgIdList, userId);
......
...@@ -5,6 +5,7 @@ import org.slf4j.Logger; ...@@ -5,6 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -113,6 +114,7 @@ public class UserController { ...@@ -113,6 +114,7 @@ public class UserController {
@ApiOperation(value = "为角色添加用户") @ApiOperation(value = "为角色添加用户")
@RequestMapping(value = "addUsersToRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "addUsersToRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("user:add")
public @ResponseBody public @ResponseBody
Boolean addUsersToRole(@RequestBody UserRoleSaveDto userRoleSaveDto) { Boolean addUsersToRole(@RequestBody UserRoleSaveDto userRoleSaveDto) {
roleService.addUsersToRole(userRoleSaveDto.getRoleId(), userRoleSaveDto.getServiceTypeId(), roleService.addUsersToRole(userRoleSaveDto.getRoleId(), userRoleSaveDto.getServiceTypeId(),
...@@ -122,6 +124,8 @@ public class UserController { ...@@ -122,6 +124,8 @@ public class UserController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "为角色添加用户") @ApiOperation(value = "为角色添加用户")
// todo 这里应该是错的 @ApiOperation(value = "启用或停用用户")
@Secured("user:edit")
@RequestMapping(value = "enableordisableuser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "enableordisableuser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody public @ResponseBody
OperationResultDto enableOrDisableUser(@RequestBody UpdateParam updateParam) { OperationResultDto enableOrDisableUser(@RequestBody UpdateParam updateParam) {
...@@ -131,6 +135,7 @@ public class UserController { ...@@ -131,6 +135,7 @@ public class UserController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "为机构删除用户角色") @ApiOperation(value = "为机构删除用户角色")
@RequestMapping(value = "deleteUserRoleForOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "deleteUserRoleForOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("user:edit")
public @ResponseBody public @ResponseBody
OperationResultDto deleteUserRoleForOrg(@RequestBody UserOrgDto userDto) { OperationResultDto deleteUserRoleForOrg(@RequestBody UserOrgDto userDto) {
logger.debug("enter deleteUserRoleForOrg"); logger.debug("enter deleteUserRoleForOrg");
...@@ -140,6 +145,7 @@ public class UserController { ...@@ -140,6 +145,7 @@ public class UserController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "机构删除,包括维度上的继承删除") @ApiOperation(value = "机构删除,包括维度上的继承删除")
@RequestMapping(value = "deleteUserRoleOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "deleteUserRoleOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("userRole:edit")
public @ResponseBody public @ResponseBody
OperationResultDto deleteUserRoleOrg( OperationResultDto deleteUserRoleOrg(
@RequestBody List<UserRoleDimensionValueDto> userRoleList) { @RequestBody List<UserRoleDimensionValueDto> userRoleList) {
...@@ -203,6 +209,7 @@ public class UserController { ...@@ -203,6 +209,7 @@ public class UserController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "机构用户权限编辑") @ApiOperation(value = "机构用户权限编辑")
@RequestMapping(value = "updateUserRoleOrganization", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "updateUserRoleOrganization", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("user:edit")
public @ResponseBody public @ResponseBody
OperationResultDto updateUserRoleOrganization( OperationResultDto updateUserRoleOrganization(
@RequestBody List<UserRoleDimensionValueDto> userRoleList) { @RequestBody List<UserRoleDimensionValueDto> userRoleList) {
...@@ -211,6 +218,7 @@ public class UserController { ...@@ -211,6 +218,7 @@ public class UserController {
@ApiOperation(value = "添加一个新的用户") @ApiOperation(value = "添加一个新的用户")
@RequestMapping(value = "add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("user:add")
public @ResponseBody public @ResponseBody
OperationResultDto<User> addUser(@RequestBody UserAndUserRoleSaveDto userAndUserRoleSaveDto) { OperationResultDto<User> addUser(@RequestBody UserAndUserRoleSaveDto userAndUserRoleSaveDto) {
return userAccountService.addNewUser(userAndUserRoleSaveDto); return userAccountService.addNewUser(userAndUserRoleSaveDto);
...@@ -219,6 +227,7 @@ public class UserController { ...@@ -219,6 +227,7 @@ public class UserController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "删除可继承权限", notes = "用户管理>点击用户卡片>点击各机构设置数据的修改按钮>点击角色>取消设置下的允许继承>确定") @ApiOperation(value = "删除可继承权限", notes = "用户管理>点击用户卡片>点击各机构设置数据的修改按钮>点击角色>取消设置下的允许继承>确定")
@RequestMapping(value = "deleteUserOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "deleteUserOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("user:edit")
public @ResponseBody public @ResponseBody
OperationResultDto deleteUserOrg(@RequestBody List<UserRoleDimensionValueDto> userRoleList) { OperationResultDto deleteUserOrg(@RequestBody List<UserRoleDimensionValueDto> userRoleList) {
return userService.deleteUserOrg(userRoleList); return userService.deleteUserOrg(userRoleList);
...@@ -227,6 +236,7 @@ public class UserController { ...@@ -227,6 +236,7 @@ public class UserController {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ApiOperation(value = "给机构添加用户", notes = "机构管理>点击机构>用户>添加用户>选中用户并提交") @ApiOperation(value = "给机构添加用户", notes = "机构管理>点击机构>用户>添加用户>选中用户并提交")
@RequestMapping(value = "updateUserRoleForOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "updateUserRoleForOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Secured("user:edit")
public @ResponseBody public @ResponseBody
OperationResultDto updateUserRoleForOrg( OperationResultDto updateUserRoleForOrg(
@RequestBody List<UserRoleDimensionValueDto> userRoleList) { @RequestBody List<UserRoleDimensionValueDto> userRoleList) {
......
...@@ -27,7 +27,16 @@ public class JwtAuthenticationService { ...@@ -27,7 +27,16 @@ public class JwtAuthenticationService {
@Cacheable(value = "apiAuthCache", key = "'userName'") @Cacheable(value = "apiAuthCache", key = "'userName'")
public List<String> getApiAuthList(String userName) { public List<String> getApiAuthList(String userName) {
List<String> apiAuthList = new ArrayList<>(); List<String> apiAuthList = new ArrayList<>();
apiAuthList.add("template:get"); apiAuthList.add("user:add");
apiAuthList.add("user:edit");
apiAuthList.add("userRole:add");
apiAuthList.add("userRole:edit");
apiAuthList.add("role:add");
apiAuthList.add("role:edit");
apiAuthList.add("roleCategory:add");
apiAuthList.add("roleCategory:edit");
apiAuthList.add("vatApproval:commit");
apiAuthList.add("vatApproval:check");
// todo upm return response // todo upm return response
logger.debug("get Cache from upm :"+"apiAuthCache-"+"key :"+userName + " value :"+String.join(",",apiAuthList)); logger.debug("get Cache from upm :"+"apiAuthCache-"+"key :"+userName + " value :"+String.join(",",apiAuthList));
return apiAuthList; return apiAuthList;
......
...@@ -11,8 +11,6 @@ import org.slf4j.LoggerFactory; ...@@ -11,8 +11,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment