Search in sources :

Example 1 with SuccessResponseEntity

use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.

the class AuthorizationController method addUserRoles.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/addUserRoles")
public SuccessResponseEntity addUserRoles(@AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace, @AuditParam("needApproval") @RequestParam Boolean needApproval, HttpSession httpSession) throws SaturnJobConsoleException {
    assertIsSystemAdmin();
    String currentLoginUserName = getCurrentLoginUserName();
    Date now = new Date();
    UserRole userRole = new UserRole();
    userRole.setUserName(userName);
    userRole.setRoleKey(roleKey);
    userRole.setNamespace(namespace);
    userRole.setNeedApproval(needApproval);
    userRole.setIsDeleted(false);
    userRole.setCreatedBy(currentLoginUserName);
    userRole.setCreateTime(now);
    userRole.setLastUpdatedBy(currentLoginUserName);
    userRole.setLastUpdateTime(now);
    User user = new User();
    user.setUserName(userName);
    user.setPassword("");
    user.setRealName("");
    user.setEmployeeId("");
    user.setEmail("");
    user.setCreatedBy(currentLoginUserName);
    user.setCreateTime(now);
    user.setLastUpdatedBy(currentLoginUserName);
    user.setLastUpdateTime(now);
    user.setIsDeleted(false);
    userRole.setUser(user);
    authorizationService.addUserRole(userRole);
    return new SuccessResponseEntity();
}
Also used : User(com.vip.saturn.job.console.mybatis.entity.User) UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Date(java.util.Date) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with SuccessResponseEntity

use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.

the class AuthorizationController method deleteUserRole.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/deleteUserRole")
public SuccessResponseEntity deleteUserRole(@AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace, HttpSession httpSession) throws SaturnJobConsoleException {
    assertIsSystemAdmin();
    UserRole userRole = new UserRole();
    userRole.setUserName(userName);
    userRole.setRoleKey(roleKey);
    userRole.setNamespace(namespace);
    String currentLoginUserName = getCurrentLoginUserName();
    userRole.setLastUpdatedBy(currentLoginUserName);
    authorizationService.deleteUserRole(userRole);
    return new SuccessResponseEntity();
}
Also used : UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with SuccessResponseEntity

use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.

the class SystemConfigController method createOrUpdateConfig.

/**
 * 创建或者更新配置项。
 *
 * @param key 配置key
 * @param value 配置值
 */
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping
public SuccessResponseEntity createOrUpdateConfig(@AuditParam(value = "key") @RequestParam String key, @AuditParam(value = "value") @RequestParam String value) throws SaturnJobConsoleException {
    assertIsPermitted(Permissions.systemConfig);
    SystemConfig systemConfig = new SystemConfig();
    systemConfig.setProperty(key);
    systemConfig.setValue(value);
    systemConfigService.insertOrUpdate(systemConfig);
    return new SuccessResponseEntity();
}
Also used : SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with SuccessResponseEntity

use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.

the class AuthenticationController method login.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@RequestMapping(value = "/login", method = { RequestMethod.POST })
public SuccessResponseEntity login(@RequestParam String username, @RequestParam String password, HttpServletRequest request) throws SaturnJobConsoleException {
    User user = authenticationService.authenticate(username, password);
    request.getSession().setAttribute(SessionAttributeKeys.LOGIN_USER_NAME, user.getUserName());
    request.getSession().setAttribute(SessionAttributeKeys.LOGIN_USER_REAL_NAME, user.getRealName());
    AUDIT_LOGGER.info("{}({}) was login where ip={} ", user.getUserName(), user.getRealName(), request.getRemoteAddr());
    return new SuccessResponseEntity();
}
Also used : User(com.vip.saturn.job.console.mybatis.entity.User) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with SuccessResponseEntity

use of com.vip.saturn.job.console.controller.SuccessResponseEntity in project Saturn by vipshop.

the class AuthorizationManageController method updateUserRole.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/updateUserRole")
public SuccessResponseEntity updateUserRole(@AuditParam("preUserName") @RequestParam String preUserName, @AuditParam("preRoleKey") @RequestParam String preRoleKey, @AuditParam("preNamespace") @RequestParam String preNamespace, @AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace, @AuditParam("needApproval") @RequestParam Boolean needApproval) throws SaturnJobConsoleException {
    assertIsSystemAdmin();
    String currentLoginUserName = getCurrentLoginUserName();
    Date now = new Date();
    UserRole pre = new UserRole();
    pre.setUserName(preUserName);
    pre.setRoleKey(preRoleKey);
    pre.setNamespace(preNamespace);
    pre.setLastUpdateTime(now);
    pre.setLastUpdatedBy(currentLoginUserName);
    UserRole cur = new UserRole();
    cur.setUserName(userName);
    cur.setRoleKey(roleKey);
    cur.setNamespace(namespace);
    cur.setNeedApproval(needApproval);
    cur.setCreatedBy(currentLoginUserName);
    cur.setCreateTime(now);
    cur.setLastUpdatedBy(currentLoginUserName);
    cur.setLastUpdateTime(now);
    cur.setIsDeleted(false);
    authorizationManageService.updateUserRole(pre, cur);
    return new SuccessResponseEntity();
}
Also used : UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Date(java.util.Date) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

SuccessResponseEntity (com.vip.saturn.job.console.controller.SuccessResponseEntity)24 ApiResponses (io.swagger.annotations.ApiResponses)23 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)11 Audit (com.vip.saturn.job.console.aop.annotation.Audit)10 PostMapping (org.springframework.web.bind.annotation.PostMapping)10 SaturnStatistics (com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)8 UserRole (com.vip.saturn.job.console.mybatis.entity.UserRole)6 SystemConfig (com.vip.saturn.job.console.mybatis.entity.SystemConfig)4 Date (java.util.Date)4 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)3 User (com.vip.saturn.job.console.mybatis.entity.User)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ContainerConfig (com.vip.saturn.job.console.domain.container.ContainerConfig)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1