feat: ASW-22 workspace 接口开发
1.workspace 接口开发 2.新增 application delete, edit, add 按钮
This commit is contained in:
@@ -20,4 +20,10 @@ public class Constants {
|
||||
*/
|
||||
public static final List<String> LANG_LIST = T.ListUtil.of("en", "zh");
|
||||
|
||||
|
||||
/**
|
||||
* 工作空间可见性列表
|
||||
*/
|
||||
public static final List<String> VISIBILITY_LIST = T.ListUtil.of("public", "private");
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ public enum RCode {
|
||||
PARAM_CANNOT_EMPTY(100006, "parameter cannot be empty"), // parameter 不能为空
|
||||
USER_NO_LOGIN(100007, "user not login"), // 用户未登录
|
||||
SYS_RECORD_NOT_FOUND(100008, "record not found"),// 未找到记录
|
||||
USER_ID_CANNOT_EMPTY(100009, "user id cannot be empty"),// 用户 ID 不能为空
|
||||
ROLE_ID_CANNOT_EMPTY(100010, "role id cannot be empty"),// 权限 ID 不能为空
|
||||
USER_NOT_EXIST(100011, "user does not exist"),
|
||||
ROLE_NOT_EXIST(100012, "role does not exist"),
|
||||
|
||||
|
||||
// Application
|
||||
@@ -26,7 +30,7 @@ public enum RCode {
|
||||
APP_LONGNAME_CANNOT_EMPTY(201003, "application longName cannot be empty"),
|
||||
APP_PROPERTIES_CANNOT_EMPTY(201004, "application properties cannot be empty"),
|
||||
APP_SURROGATES_CANNOT_EMPTY(201005, "application surrogates cannot be empty"),
|
||||
APP_DESCRIPTION_CANNOT_EMPTY(201006, "application surrogates cannot be empty"),
|
||||
APP_DESCRIPTION_CANNOT_EMPTY(201006, "application description cannot be empty"),
|
||||
APP_DUPLICATE_RECORD(201007, "application duplicate record"),
|
||||
APP_NOT_EXIST(201008, "application does not exist"),
|
||||
|
||||
@@ -46,6 +50,15 @@ public enum RCode {
|
||||
|
||||
// Workspace
|
||||
WORKSPACE_ID_CANNOT_EMPTY(401001, "workspace id cannot be empty"),
|
||||
WORKSPACE_NAME_CANNOT_EMPTY(401002, "workspace name cannot be empty"),
|
||||
WORKSPACE_VISIBILITY_CANNOT_EMPTY(401003, "workspace visibility cannot be empty"),
|
||||
WORKSPACE_USER_CANNOT_EMPTY(401004, "workspace user cannot be empty"),
|
||||
WORKSPACE_ALREADY_EXISTS(401005, "workspace already exists"),
|
||||
WORKSPACE_MEMBER_CANNOT_EMPTY(401006, "workspace member cannot be empty"),
|
||||
WORKSPACE_CANNOT_DELETE(401007, "Built-in workspace cannot be deleted"),
|
||||
WORKSPACE_VISIBILITY_ERROR(401008, "workspace visibility error"),
|
||||
WORKSPACE_BUILT_IN(401009, "Built-in workspace cannot be update"),
|
||||
|
||||
|
||||
SUCCESS(200, "success"); // 成功
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package net.geedge.asw.module.workspace.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.geedge.asw.common.util.R;
|
||||
import net.geedge.asw.common.util.RCode;
|
||||
import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.common.util.VerifyUtil;
|
||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||
import net.geedge.asw.module.sys.service.ISysUserService;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceMemberService;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/workspace")
|
||||
public class WorkspaceController {
|
||||
|
||||
@Autowired
|
||||
private IWorkspaceService workspaceService;
|
||||
|
||||
@Autowired
|
||||
private IWorkspaceMemberService workspaceMemberService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public R detail(@PathVariable("id") String id) {
|
||||
WorkspaceEntity workspace = workspaceService.getById(id);
|
||||
String createUserId = workspace.getCreateUserId();
|
||||
String updateUserId = workspace.getUpdateUserId();
|
||||
if (T.StrUtil.isNotEmpty(createUserId)) {
|
||||
SysUserEntity createUser = userService.getById(createUserId);
|
||||
workspace.setCreateUser(createUser);
|
||||
}
|
||||
if (T.StrUtil.isNotEmpty(updateUserId)) {
|
||||
SysUserEntity updateUser = userService.getById(updateUserId);
|
||||
workspace.setUpdateUser(updateUser);
|
||||
}
|
||||
return R.ok().putData("record", workspace);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
Page page = workspaceService.queryList(params);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R save(@RequestBody WorkspaceEntity workspace) {
|
||||
VerifyUtil.is(workspace).notNull()
|
||||
.and(workspace.getName()).notEmpty(RCode.WORKSPACE_NAME_CANNOT_EMPTY)
|
||||
.and(workspace.getVisibility()).notEmpty(RCode.WORKSPACE_VISIBILITY_CANNOT_EMPTY);
|
||||
|
||||
WorkspaceEntity workspaceEntity = workspaceService.saveWorkspace(workspace);
|
||||
return R.ok().putData("record", workspaceEntity.getId());
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
public R update(@RequestBody WorkspaceEntity workspace) {
|
||||
VerifyUtil.is(workspace).notNull()
|
||||
.and(workspace.getId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY)
|
||||
.and(workspace.getName()).notEmpty(RCode.WORKSPACE_NAME_CANNOT_EMPTY)
|
||||
.and(workspace.getVisibility()).notEmpty(RCode.WORKSPACE_VISIBILITY_CANNOT_EMPTY);
|
||||
|
||||
WorkspaceEntity workspaceEntity = workspaceService.updateWorkspace(workspace);
|
||||
return R.ok().putData("record", workspaceEntity.getId());
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public R delete(@RequestParam String ids) {
|
||||
VerifyUtil.is(ids).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
workspaceService.deleteWorkspace(ids);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/{workspaceId}/member")
|
||||
public R getMember(@PathVariable String workspaceId) {
|
||||
List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(workspaceId);
|
||||
return R.ok().putData("record", memberEntityList);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/{workspaceId}/member")
|
||||
public R saveMember(@PathVariable String workspaceId, @RequestBody List<WorkspaceMemberEntity> workspaceMembers) {
|
||||
VerifyUtil.is(workspaceMembers).notEmpty(RCode.WORKSPACE_MEMBER_CANNOT_EMPTY)
|
||||
.and(workspaceId).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
List<WorkspaceMemberEntity> workspaceMemberEntityList = workspaceMemberService.saveMember(workspaceId, workspaceMembers);
|
||||
return R.ok().putData("record", workspaceMemberEntityList);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/{workspaceId}/member")
|
||||
public R updateMember(@PathVariable String workspaceId, @RequestBody List<WorkspaceMemberEntity> workspaceMembers) {
|
||||
VerifyUtil.is(workspaceMembers).notEmpty(RCode.WORKSPACE_MEMBER_CANNOT_EMPTY)
|
||||
.and(workspaceId).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
List<WorkspaceMemberEntity> workspaceMemberEntityList = workspaceMemberService.updateMember(workspaceId, workspaceMembers);
|
||||
return R.ok().putData("record", workspaceMemberEntityList);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{workspaceId}/member")
|
||||
public R deleteMember(@PathVariable String workspaceId, @RequestParam String userIds) {
|
||||
VerifyUtil.is(userIds).notEmpty(RCode.USER_ID_CANNOT_EMPTY);
|
||||
List<String> list = Arrays.asList(userIds.split(","));
|
||||
workspaceMemberService.remove(new LambdaQueryWrapper<WorkspaceMemberEntity>()
|
||||
.eq(WorkspaceMemberEntity::getWorkspaceId, workspaceId)
|
||||
.in(WorkspaceMemberEntity::getUserId, list));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
package net.geedge.asw.module.workspace.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface WorkspaceDao extends BaseMapper<WorkspaceEntity> {
|
||||
|
||||
List<WorkspaceEntity> queryList(Page page, Map<String, Object> params);
|
||||
}
|
||||
@@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WorkspaceMemberDao extends BaseMapper<WorkspaceMemberEntity> {
|
||||
|
||||
List<WorkspaceMemberEntity> queryList(String workspaceId);
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package net.geedge.asw.module.workspace.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import net.geedge.asw.module.sys.entity.SysRoleEntity;
|
||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("workspace")
|
||||
@@ -21,5 +26,13 @@ public class WorkspaceEntity {
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUserEntity createUser;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUserEntity updateUser;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<WorkspaceMemberEntity> members;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package net.geedge.asw.module.workspace.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import net.geedge.asw.module.sys.entity.SysRoleEntity;
|
||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("workspace_member")
|
||||
@@ -14,4 +19,13 @@ public class WorkspaceMemberEntity {
|
||||
private Long createTimestamp;
|
||||
private String createUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUserEntity user;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysRoleEntity role;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUserEntity createUser;
|
||||
|
||||
}
|
||||
@@ -3,6 +3,13 @@ package net.geedge.asw.module.workspace.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWorkspaceMemberService extends IService<WorkspaceMemberEntity>{
|
||||
|
||||
List<WorkspaceMemberEntity> queryList(String workspaceId);
|
||||
|
||||
List<WorkspaceMemberEntity> saveMember(String workspaceId ,List<WorkspaceMemberEntity> workspaces);
|
||||
|
||||
List<WorkspaceMemberEntity> updateMember(String workspaceId, List<WorkspaceMemberEntity> workspaces);
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
package net.geedge.asw.module.workspace.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IWorkspaceService extends IService<WorkspaceEntity>{
|
||||
|
||||
Page queryList(Map<String, Object> params);
|
||||
|
||||
WorkspaceEntity saveWorkspace(WorkspaceEntity workspace);
|
||||
|
||||
WorkspaceEntity updateWorkspace(WorkspaceEntity workspace);
|
||||
|
||||
void deleteWorkspace(String ids);
|
||||
}
|
||||
@@ -1,13 +1,78 @@
|
||||
package net.geedge.asw.module.workspace.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.common.util.ASWException;
|
||||
import net.geedge.asw.common.util.RCode;
|
||||
import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.common.util.VerifyUtil;
|
||||
import net.geedge.asw.module.sys.service.ISysRoleService;
|
||||
import net.geedge.asw.module.sys.service.ISysUserService;
|
||||
import net.geedge.asw.module.workspace.dao.WorkspaceMemberDao;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceMemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WorkspaceMemberServiceImpl extends ServiceImpl<WorkspaceMemberDao, WorkspaceMemberEntity> implements IWorkspaceMemberService {
|
||||
|
||||
@Autowired
|
||||
private IWorkspaceMemberService workspaceMemberService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@Override
|
||||
public List<WorkspaceMemberEntity> queryList(String workspaceId) {
|
||||
List<WorkspaceMemberEntity> list = this.baseMapper.queryList(workspaceId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkspaceMemberEntity> saveMember(String workspaceId, List<WorkspaceMemberEntity> workspaces) {
|
||||
validateInfo(workspaceId, workspaces);
|
||||
workspaceMemberService.saveBatch(workspaces);
|
||||
List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(workspaceId);
|
||||
return memberEntityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkspaceMemberEntity> updateMember(String workspaceId, List<WorkspaceMemberEntity> workspaces) {
|
||||
validateInfo(workspaceId, workspaces);
|
||||
workspaceMemberService.remove(new LambdaQueryWrapper<WorkspaceMemberEntity>().eq(WorkspaceMemberEntity::getWorkspaceId, workspaceId));
|
||||
workspaceMemberService.saveBatch(workspaces);
|
||||
List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(workspaceId);
|
||||
return memberEntityList;
|
||||
}
|
||||
|
||||
private void validateInfo(String workspaceId, List<WorkspaceMemberEntity> workspaces) {
|
||||
if (T.StrUtil.equalsIgnoreCase(workspaceId, "1")) {
|
||||
throw new ASWException(RCode.WORKSPACE_BUILT_IN);
|
||||
}
|
||||
List<String> userIds = userService.list().stream().map(x -> x.getId()).toList();
|
||||
List<String> roleIds = roleService.list().stream().map(x -> x.getId()).toList();
|
||||
for (WorkspaceMemberEntity workspace : workspaces) {
|
||||
VerifyUtil.is(workspace).notNull()
|
||||
.and(workspace.getUserId()).notEmpty(RCode.USER_ID_CANNOT_EMPTY)
|
||||
.and(workspace.getRoleId()).notEmpty(RCode.ROLE_ID_CANNOT_EMPTY);
|
||||
if (!userIds.contains(workspace.getUserId())) {
|
||||
throw new ASWException(RCode.USER_NOT_EXIST);
|
||||
}
|
||||
if (!roleIds.contains(workspace.getRoleId())) {
|
||||
throw new ASWException(RCode.ROLE_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
workspaces.stream().forEach(x -> {
|
||||
x.setWorkspaceId(workspaceId);
|
||||
x.setCreateUserId(StpUtil.getLoginIdAsString());
|
||||
x.setCreateTimestamp(System.currentTimeMillis());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,113 @@
|
||||
package net.geedge.asw.module.workspace.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.common.util.ASWException;
|
||||
import net.geedge.asw.common.util.Constants;
|
||||
import net.geedge.asw.common.util.RCode;
|
||||
import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.module.workspace.dao.WorkspaceDao;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceMemberService;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceDao, WorkspaceEntity> implements IWorkspaceService {
|
||||
|
||||
@Autowired
|
||||
private IWorkspaceService workspaceService;
|
||||
|
||||
@Autowired
|
||||
private IWorkspaceMemberService workspaceMemberService;
|
||||
|
||||
@Override
|
||||
public Page queryList(Map<String, Object> params) {
|
||||
Page page = T.PageUtil.getPage(params);
|
||||
List<WorkspaceEntity> workspaceEntityList = this.getBaseMapper().queryList(page, params);
|
||||
page.setRecords(workspaceEntityList);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public WorkspaceEntity saveWorkspace(WorkspaceEntity workspace) {
|
||||
this.validateWorkspaceInfo(workspace, false);
|
||||
workspace.setCreateUserId(StpUtil.getLoginIdAsString());
|
||||
workspace.setUpdateUserId(StpUtil.getLoginIdAsString());
|
||||
workspace.setCreateTimestamp(System.currentTimeMillis());
|
||||
workspace.setUpdateTimestamp(System.currentTimeMillis());
|
||||
workspaceService.save(workspace);
|
||||
|
||||
if (T.CollectionUtil.isNotEmpty(workspace.getMembers())) {
|
||||
List<WorkspaceMemberEntity> members = workspace.getMembers();
|
||||
members.stream().forEach(x -> {
|
||||
x.setWorkspaceId(workspace.getId());
|
||||
x.setCreateTimestamp(System.currentTimeMillis());
|
||||
x.setCreateUserId(StpUtil.getLoginIdAsString());
|
||||
});
|
||||
workspaceMemberService.saveBatch(members);
|
||||
}
|
||||
return workspace;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public WorkspaceEntity updateWorkspace(WorkspaceEntity workspace) {
|
||||
this.validateWorkspaceInfo(workspace, true);
|
||||
workspace.setUpdateUserId(StpUtil.getLoginIdAsString());
|
||||
workspace.setUpdateTimestamp(System.currentTimeMillis());
|
||||
workspaceService.updateById(workspace);
|
||||
|
||||
if (T.CollectionUtil.isNotEmpty(workspace.getMembers())) {
|
||||
List<WorkspaceMemberEntity> members = workspace.getMembers();
|
||||
members.stream().forEach(x -> {
|
||||
x.setWorkspaceId(workspace.getId());
|
||||
x.setCreateTimestamp(System.currentTimeMillis());
|
||||
x.setCreateUserId(StpUtil.getLoginIdAsString());
|
||||
});
|
||||
workspaceMemberService.remove(new LambdaQueryWrapper<WorkspaceMemberEntity>().eq(WorkspaceMemberEntity::getWorkspaceId, workspace.getId()));
|
||||
workspaceMemberService.saveBatch(members);
|
||||
}
|
||||
return workspace;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteWorkspace(String ids) {
|
||||
List workspaceIds = Arrays.asList(ids.split(","));
|
||||
if (workspaceIds.contains("1")) {
|
||||
throw new ASWException(RCode.WORKSPACE_CANNOT_DELETE);
|
||||
}
|
||||
workspaceService.removeBatchByIds(workspaceIds);
|
||||
workspaceMemberService.remove(new LambdaQueryWrapper<WorkspaceMemberEntity>().in(WorkspaceMemberEntity::getWorkspaceId, workspaceIds));
|
||||
}
|
||||
|
||||
private void validateWorkspaceInfo(WorkspaceEntity workspace, boolean isUpdate) {
|
||||
|
||||
if (!Constants.VISIBILITY_LIST.contains(workspace.getVisibility())) {
|
||||
throw new ASWException(RCode.WORKSPACE_VISIBILITY_ERROR);
|
||||
}
|
||||
if (T.StrUtil.equals(workspace.getVisibility(), "private") && T.CollectionUtil.isEmpty(workspace.getMembers())) {
|
||||
throw new ASWException(RCode.WORKSPACE_USER_CANNOT_EMPTY);
|
||||
}
|
||||
|
||||
List<WorkspaceEntity> list = workspaceService.list(new LambdaQueryWrapper<WorkspaceEntity>().eq(WorkspaceEntity::getName, workspace.getName()));
|
||||
if (!isUpdate && T.CollectionUtil.isNotEmpty(list)) {
|
||||
throw new ASWException(RCode.WORKSPACE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
if (isUpdate && T.CollectionUtil.isNotEmpty(list) && T.StrUtil.equals(workspace.getId(), list.getFirst().getId())) {
|
||||
throw new ASWException(RCode.WORKSPACE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/main/resources/db/mapper/workspace/WorkspaceMapper.xml
Normal file
55
src/main/resources/db/mapper/workspace/WorkspaceMapper.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="net.geedge.asw.module.workspace.dao.WorkspaceDao">
|
||||
|
||||
<resultMap id="workspaceResultMap" type="net.geedge.asw.module.workspace.entity.WorkspaceEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="tags" column="tags"/>
|
||||
<result property="visibility" column="visibility"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="createTimestamp" column="create_timestamp"/>
|
||||
<result property="updateTimestamp" column="update_timestamp"/>
|
||||
<result property="createUserId" column="create_user_id"/>
|
||||
<result property="updateUserId" column="update_user_id"/>
|
||||
|
||||
<association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="updateUser" columnPrefix="uu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryList" resultMap="workspaceResultMap">
|
||||
SELECT
|
||||
ws.*,
|
||||
cu.id AS cu_id,
|
||||
cu.name AS cu_name,
|
||||
uu.id AS uu_id,
|
||||
uu.name AS uu_name
|
||||
FROM
|
||||
workspace ws
|
||||
LEFT JOIN sys_user cu ON ws.create_user_id = cu.id
|
||||
LEFT JOIN sys_user uu ON ws.update_user_id = uu.id
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
ws.id in
|
||||
<foreach item="id" collection="params.ids.split(',')" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.q != null and params.q != ''">
|
||||
AND ( locate(#{params.q}, ws.name) OR locate(#{params.q}, ws.description) OR locate(#{params.q},
|
||||
ws.tags) )
|
||||
</if>
|
||||
</where>
|
||||
<if test="params.orderBy == null or params.orderBy == ''">
|
||||
ORDER BY ws.id
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="net.geedge.asw.module.workspace.dao.WorkspaceMemberDao">
|
||||
|
||||
<resultMap id="workspaceMemberResultMap" type="net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity">
|
||||
|
||||
<result property="workspaceId" column="workspace_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="roleId" column="role_id"/>
|
||||
<result property="createTimestamp" column="create_timestamp"/>
|
||||
<result property="createUserId" column="create_user_id"/>
|
||||
|
||||
<association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="user" columnPrefix="su_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="role" columnPrefix="sr_" javaType="net.geedge.asw.module.sys.entity.SysRoleEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
</resultMap>
|
||||
<select id="queryList" resultMap="workspaceMemberResultMap">
|
||||
SELECT
|
||||
wm.*,
|
||||
cu.id AS cu_id,
|
||||
cu.name AS cu_name,
|
||||
su.id AS su_id,
|
||||
su.name AS su_name,
|
||||
sr.id AS sr_id,
|
||||
sr.name AS sr_name
|
||||
FROM
|
||||
workspace_member wm
|
||||
LEFT JOIN sys_user cu ON wm.create_user_id = cu.id
|
||||
LEFT JOIN sys_user su ON wm.user_id = su.id
|
||||
LEFT JOIN sys_role sr ON wm.role_id = sr.id
|
||||
<where>
|
||||
<if test="workspaceId != null and workspaceId != ''">
|
||||
wm.workspace_id = #{workspaceId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -51,6 +51,44 @@ INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (59, '202002', 'PACKAGE_DESCRIPTION_CANNOT_EMPTY', '安装包描述信息不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (61, '401001', 'WORKSPACE_ID_CANNOT_EMPTY', 'workspace id cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (63, '401001', 'WORKSPACE_ID_CANNOT_EMPTY', '工作空间ID不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (65, '401002', 'WORKSPACE_NAME_CANNOT_EMPTY', 'workspace name cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (67, '401002', 'WORKSPACE_NAME_CANNOT_EMPTY', '工作空间名称不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (69, '401003', 'WORKSPACE_VISIBILITY_CANNOT_EMPTY', 'workspace visibility cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (71, '401003', 'WORKSPACE_VISIBILITY_CANNOT_EMPTY', '工作空间可见性不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (73, '401004', 'WORKSPACE_USER_CANNOT_EMPTY', 'workspace user cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (75, '401004', 'WORKSPACE_USER_CANNOT_EMPTY', '工作空间用户不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (77, '401005', 'WORKSPACE_ALREADY_EXISTS', 'workspace already exists', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (79, '401005', 'WORKSPACE_ALREADY_EXISTS', '工作空间已存在', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (81, '401006', 'WORKSPACE_MEMBER_CANNOT_EMPTY', 'workspace member cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (83, '401006', 'WORKSPACE_MEMBER_CANNOT_EMPTY', '工作空间成员不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (85, '401007', 'WORKSPACE_CANNOT_DELETE', 'Built-in workspace cannot be deleted', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (87, '401007', 'WORKSPACE_CANNOT_DELETE', '内置工作空间不能删除', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (89, '100009', 'USER_ID_CANNOT_EMPTY', 'user id cannot be empty ', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (91, '100009', 'USER_ID_CANNOT_EMPTY', '用户 ID 不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (93, '201002', 'APP_NAME_CANNOT_EMPTY', 'application name cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (95, '201002', 'APP_NAME_CANNOT_EMPTY', '应用程序名称不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (97, '201003', 'APP_LONGNAME_CANNOT_EMPTY', 'application longName cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (99, '201003', 'APP_LONGNAME_CANNOT_EMPTY', '应用程序全称不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (101, '201004', 'APP_PROPERTIES_CANNOT_EMPTY', 'application properties cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (103, '201004', 'APP_PROPERTIES_CANNOT_EMPTY', '应用程序属性不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (105, '201005', 'APP_SURROGATES_CANNOT_EMPTY', 'application surrogates cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (107, '201005', 'APP_SURROGATES_CANNOT_EMPTY', '应用程序代理不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (109, '201006', 'APP_DESCRIPTION_CANNOT_EMPTY', 'application descriptioncannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (111, '201006', 'APP_DESCRIPTION_CANNOT_EMPTY', '应用描述不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (113, '201007', 'APP_DUPLICATE_RECORD', 'application duplicate record', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (115, '201007', 'APP_DUPLICATE_RECORD', '应用程序重复记录', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (117, '201008', 'APP_NOT_EXIST', 'application does not exist', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (119, '201008', 'APP_NOT_EXIST', '应用程序不存在', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (121, '401008', 'WORKSPACE_VISIBILITY_ERROR', 'workspace visibility error', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (123, '401008', 'WORKSPACE_VISIBILITY_ERROR', '工作空间可见性错误', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (125, '401009', 'WORKSPACE_BUILT_IN', 'Built-in workspace cannot be update', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (127, '401009', 'WORKSPACE_BUILT_IN', '内置工作空间不可修改', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (129, '100010', 'ROLE_ID_CANNOT_EMPTY', 'role id cannot be empty ', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (131, '100010', 'ROLE_ID_CANNOT_EMPTY', '权限 ID 不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (133, '100011', 'USER_NOT_EXIST', 'user does not exist', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (135, '100011', 'USER_NOT_EXIST', '用户不存在', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (137, '100012', 'ROLE_NOT_EXIST', 'role does not exist', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (139, '100012', 'ROLE_NOT_EXIST', '权限不存在', 'zh', '', 'admin', 1719280800000);
|
||||
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -9,6 +9,9 @@ INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('2000', 'applications', 'overall.applications', '0', 'menu', '', '/applications', 'asw-icon icon-Applications', 1, 1722478572000, 1);
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('2001', 'application_view', 'buttons.view', '2000', 'button', '', '', '', 1, 1722478572000, 1);
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('2002', 'application_add', 'buttons.add', '2000', 'button', '', '', '', 1, 1722478572000, 1);
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('2003', 'application_edit', 'buttons.edit', '2000', 'button', '', '', '', 1, 1722478572000, 1);
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('2004', 'application_delete', 'buttons.delete', '2000', 'button', '', '', '', 1, 1722478572000, 1);
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('3000', 'pcaps', 'overall.pcaps', '0', 'menu', '', '/pcaps', 'asw-icon icon-Pcaps', 2, 1722478572000, 1);
|
||||
INSERT INTO `sys_menu` (`id`, `name`, `i18n`, `pid`, `type`, `perms`, `route`, `icon`, `order`, `create_timestamp`, `state`) VALUES ('3001', 'pacp_view', 'buttons.view', '3000', 'button', '', '', '', 1, 1722478572000, 1);
|
||||
|
||||
@@ -9,6 +9,9 @@ INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '1001');
|
||||
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '2000');
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '2001');
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '2002');
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '2003');
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '2004');
|
||||
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '3000');
|
||||
INSERT INTO `sys_role_menu`(`role_id`, `menu_id`) VALUES ('admin', '3001');
|
||||
|
||||
Reference in New Issue
Block a user