You are viewing a plain text version of this content. The canonical link for it is here.
Posted to submarine-dev@hadoop.apache.org by zt...@apache.org on 2019/09/26 01:45:29 UTC
[hadoop-submarine] branch master updated: [SUBMARINE-181] Submarine
team manager TeamRestApi
This is an automated email from the ASF dual-hosted git repository.
ztang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-submarine.git
The following commit(s) were added to refs/heads/master by this push:
new 553f4c1 [SUBMARINE-181] Submarine team manager TeamRestApi
553f4c1 is described below
commit 553f4c167bb004b734c3eec62a07c0a6e221b6c6
Author: LinhaoZhu <zh...@163.com>
AuthorDate: Wed Sep 25 21:10:05 2019 +0800
[SUBMARINE-181] Submarine team manager TeamRestApi
### What is this PR for?
1. org.apache.submarine.database.service.TeamService
2. TeamMapper.xml, TeamMemberMapper.xml
3. org.apache.submarine.rest.TeamRestApi
4. database table: team, team_member;
### What type of PR is it?
[ Feature ]
### Todos
* [ ] - Task
### What is the Jira issue?
* [SUBMARINE-181](https://issues.apache.org/jira/browse/SUBMARINE-181)
### How should this be tested?
* [CI Pass](https://travis-ci.org/LinhaoZhu/hadoop-submarine/builds/589441765)
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: LinhaoZhu <zh...@163.com>
Closes #12 from LinhaoZhu/SUBMARINE-181 and squashes the following commits:
f795ca0 [LinhaoZhu] [SUBMARINE-181] Submarine team manager TeamRestApi
0d2ae2c [LinhaoZhu] [SUBMARINE-181] Submarine team manager TeamRestApi
065cb01 [LinhaoZhu] [SUBMARINE-181] Submarine team manager TeamRestApi
7217d46 [LinhaoZhu] [SUBMARINE-181] Submarine team manager TeamRestApi
---
docs/database/submarine.sql | 1 +
docs/helper/MybatisGenerator.md | 59 ++++++
pom.xml | 1 +
submarine-workbench/submarine-server/pom.xml | 7 +
.../java/org/apache/submarine/annotation/Dict.java | 17 +-
.../apache/submarine/annotation/SubmarineApi.java | 15 +-
.../org/apache/submarine/database/MyBatisUtil.java | 2 +-
.../submarine/database/entity/SysDeptSelect.java | 2 +-
.../submarine/database/entity/SysMessage.java | 67 +++++++
.../org/apache/submarine/database/entity/Team.java | 8 +-
.../entity/{TeamMemeber.java => TeamMember.java} | 13 +-
.../SysMessageMapper.java} | 36 ++--
.../TeamMemeber.java => mappers/TeamMapper.java} | 37 ++--
.../TeamMemberMapper.java} | 38 ++--
.../database/service/SysMessageService.java | 43 +++++
.../submarine/database/service/SysUserService.java | 12 +-
.../database/service/TeamMemberService.java | 84 +++++++++
.../submarine/database/service/TeamService.java | 179 ++++++++++++++++++
.../submarine/database/utils/DepartmentUtil.java | 2 +-
.../submarine/database/utils/DictAnnotation.java | 6 +-
.../database/utils/MybatisGeneratorMain.java | 67 +++++++
.../org/apache/submarine/entity/Permission.java | 12 +-
.../java/org/apache/submarine/entity/Role.java | 16 +-
.../java/org/apache/submarine/entity/User.java | 30 ++--
.../java/org/apache/submarine/entity/UserInfo.java | 28 +--
.../org/apache/submarine/rest/SysDeptRestApi.java | 2 +-
.../apache/submarine/rest/SysDictItemRestApi.java | 8 +-
.../org/apache/submarine/rest/SysDictRestApi.java | 6 +-
.../org/apache/submarine/rest/SystemRestApi.java | 6 +-
.../org/apache/submarine/rest/TeamRestApi.java | 112 ++++++------
.../submarine/server/JsonExclusionStrategy.java | 15 +-
.../org/apache/submarine/server/JsonResponse.java | 27 ++-
.../submarine/server/SubmarineConfiguration.java | 5 +-
.../src/main/resources/mbgConfiguration.xml | 63 +++++++
.../src/main/resources/mybatis-config.xml | 2 +
.../database/mappers/SysMessageMapper.xml | 200 +++++++++++++++++++++
.../submarine/database/mappers/TeamMapper.xml | 146 +++++++++++++++
.../database/mappers/TeamMemberMapper.xml | 187 +++++++++++++++++++
.../database/service/SysUserServiceTest.java | 6 +-
.../database/service/TeamServiceTest.java | 146 +++++++++++++++
.../org/apache/submarine/rest/CommonDataTest.java | 8 +-
.../apache/submarine/rest/SysDeptRestApiTest.java | 2 +-
.../submarine/rest/SysDictItemRestApiTest.java | 4 +-
.../apache/submarine/rest/SysDictRestApiTest.java | 2 +-
.../apache/submarine/rest/SysUserRestApiTest.java | 2 +-
.../apache/submarine/server/JsonResponseTest.java | 4 +-
46 files changed, 1476 insertions(+), 259 deletions(-)
diff --git a/docs/database/submarine.sql b/docs/database/submarine.sql
index 6d51713..b4194bd 100644
--- a/docs/database/submarine.sql
+++ b/docs/database/submarine.sql
@@ -144,6 +144,7 @@ CREATE TABLE `team` (
DROP TABLE IF EXISTS `team_member`;
CREATE TABLE `team_member` (
`id` varchar(32) NOT NULL,
+ `team_id` varchar(32) NOT NULL COMMENT 'team id',
`team_name` varchar(64) NOT NULL COMMENT 'team name',
`member` varchar(100) NOT NULL COMMENT 'member name',
`inviter` int(1) default 0 COMMENT '0:inviter, 1:accept',
diff --git a/docs/helper/MybatisGenerator.md b/docs/helper/MybatisGenerator.md
new file mode 100644
index 0000000..deffe9d
--- /dev/null
+++ b/docs/helper/MybatisGenerator.md
@@ -0,0 +1,59 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+## Introduction to MyBatis Generator Usage
+
+## summary
+
+[Official Website](http://mybatis.org/generator/ "link")
+
+MyBatis Generator (MBG) is a code generator for MyBatis MyBatis and iBATIS.
+It will generate code for all versions of MyBatis, and versions of iBATIS after
+version 2.2.0. It will introspect a database table (or many tables) and will
+generate artifacts that can be used to access the table(s). This lessens the
+initial nuisance of setting up objects and configuration files to interact
+with database tables. MBG seeks to make a major impact on the large percentage
+of database operations that are simple CRUD (Create, Retrieve, Update, Delete).
+You will still need to hand code SQL and objects for join queries, or stored procedures.
+
+## Quick Start
+
+### Add plug-in dependencies in pom.xml
+The plug-in has been added in the pom.xml of the _submarine-server_.
+
+```
+<dependency>
+ <groupId>org.mybatis.generator</groupId>
+ <artifactId>mybatis-generator-core</artifactId>
+ <version>1.3.7</version>
+</dependency>
+```
+
+### Add plug-in dependencies in pom.xml
+Edit the mbgConfiguration.xml file. We need to modify the following:
+1. We need to modify the JDBC connection information, such as driverClass,
+connectionURL, userId, password.
+2. targetProject: You can specify a specific path as file storage path. e.g./tmp.
+3. **tableName** and **domainObjectName**: List all the table to generate the code.
+
+### Add main class
+We have been added main class named _MybatisGeneratorMain_ in the _submarine-server_
+project _org.apache.submarine.database.utils_ package path.
+
+### Generator file
+Run the main method to get the file, Take the idea development tool as an example:
+The selected MybatisGeneratorMain class, Right click to run the main method.
+We can find the file under the targetProject path that we just configured.
+including: entity, TableNameMapper.java, TableNameMapper.xml
diff --git a/pom.xml b/pom.xml
index 6b7e6ce..fc1f92c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,6 +101,7 @@
<commons-collections.version>3.2.2</commons-collections.version>
<nimbus-jose-jwt.version>4.41.1</nimbus-jose-jwt.version>
<commons-io.version>2.4</commons-io.version>
+ <mybatis-generator.version>1.3.7</mybatis-generator.version>
</properties>
<modules>
diff --git a/submarine-workbench/submarine-server/pom.xml b/submarine-workbench/submarine-server/pom.xml
index eaf6164..1bbc97f 100644
--- a/submarine-workbench/submarine-server/pom.xml
+++ b/submarine-workbench/submarine-server/pom.xml
@@ -181,6 +181,13 @@
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.mybatis.generator</groupId>
+ <artifactId>mybatis-generator-core</artifactId>
+ <version>${mybatis-generator.version}</version>
+ </dependency>
+
</dependencies>
<build>
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/Dict.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/Dict.java
index b620374..945f5ed 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/Dict.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/Dict.java
@@ -1,18 +1,15 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. See accompanying LICENSE file.
*/
package org.apache.submarine.annotation;
@@ -24,5 +21,5 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Dict {
- String Code();
+ String Code();
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java
index 8d95d12..7c18a7d 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java
@@ -1,18 +1,15 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. See accompanying LICENSE file.
*/
package org.apache.submarine.annotation;
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
index 25298f5..1ddad2d 100755
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
@@ -69,7 +69,7 @@ public class MyBatisUtil {
}
/**
- * 获取Session
+ * Get Session
*
* @return
*/
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java
index 1999483..64b38af 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysMessage.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysMessage.java
new file mode 100644
index 0000000..4b95f48
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/SysMessage.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. See accompanying LICENSE file.
+ */
+package org.apache.submarine.database.entity;
+
+public class SysMessage extends BaseEntity {
+
+ private String sender;
+
+ private String receiver;
+
+ private String type;
+
+ private Integer status;
+
+ private String context;
+
+ public String getSender() {
+ return sender;
+ }
+
+ public void setSender(String sender) {
+ this.sender = sender == null ? null : sender.trim();
+ }
+
+ public String getReceiver() {
+ return receiver;
+ }
+
+ public void setReceiver(String receiver) {
+ this.receiver = receiver == null ? null : receiver.trim();
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type == null ? null : type.trim();
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context == null ? null : context.trim();
+ }
+}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/Team.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/Team.java
index 821694d..e76492c 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/Team.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/Team.java
@@ -22,7 +22,7 @@ public class Team extends BaseEntity {
private String teamName;
- private List<TeamMemeber> collaborators;
+ private List<TeamMember> collaborators;
public String getOwner() {
return owner;
@@ -40,15 +40,15 @@ public class Team extends BaseEntity {
this.teamName = teamName;
}
- public List<TeamMemeber> getCollaborators() {
+ public List<TeamMember> getCollaborators() {
return collaborators;
}
- public void setCollaborators(List<TeamMemeber> collaborators) {
+ public void setCollaborators(List<TeamMember> collaborators) {
this.collaborators = collaborators;
}
- public void addCollaborator(TeamMemeber memeber) {
+ public void addCollaborator(TeamMember memeber) {
if (collaborators == null) {
collaborators = new ArrayList<>();
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMember.java
similarity index 85%
copy from submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
copy to submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMember.java
index bcd0e56..43381e9 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMember.java
@@ -13,7 +13,9 @@
*/
package org.apache.submarine.database.entity;
-public class TeamMemeber extends BaseEntity {
+public class TeamMember extends BaseEntity {
+
+ private String teamId;
private String teamName;
@@ -22,6 +24,14 @@ public class TeamMemeber extends BaseEntity {
private Integer inviter;
+ public String getTeamId() {
+ return teamId;
+ }
+
+ public void setTeamId(String teamId) {
+ this.teamId = teamId;
+ }
+
public String getTeamName() {
return teamName;
}
@@ -45,4 +55,5 @@ public class TeamMemeber extends BaseEntity {
public void setInviter(Integer inviter) {
this.inviter = inviter;
}
+
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/SysMessageMapper.java
similarity index 50%
copy from submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
copy to submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/SysMessageMapper.java
index bcd0e56..40c4c69 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/SysMessageMapper.java
@@ -11,38 +11,22 @@
* See the License for the specific language governing permissions and
* limitations under the License. See accompanying LICENSE file.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.database.mappers;
-public class TeamMemeber extends BaseEntity {
+import org.apache.submarine.database.entity.SysMessage;
- private String teamName;
+public interface SysMessageMapper {
+ int deleteByPrimaryKey(String id);
- // user name
- private String member;
+ int insert(SysMessage record);
- private Integer inviter;
+ int insertSelective(SysMessage record);
- public String getTeamName() {
- return teamName;
- }
+ SysMessage selectByPrimaryKey(String id);
- public void setTeamName(String teamName) {
- this.teamName = teamName;
- }
+ int updateByPrimaryKeySelective(SysMessage record);
- public String getMember() {
- return member;
- }
+ int updateByPrimaryKeyWithBLOBs(SysMessage record);
- public void setMember(String member) {
- this.member = member;
- }
-
- public Integer getInviter() {
- return inviter;
- }
-
- public void setInviter(Integer inviter) {
- this.inviter = inviter;
- }
+ int updateByPrimaryKey(SysMessage record);
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/TeamMapper.java
similarity index 51%
copy from submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
copy to submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/TeamMapper.java
index bcd0e56..089c7c8 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/TeamMapper.java
@@ -11,38 +11,27 @@
* See the License for the specific language governing permissions and
* limitations under the License. See accompanying LICENSE file.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.database.mappers;
-public class TeamMemeber extends BaseEntity {
+import org.apache.ibatis.session.RowBounds;
+import org.apache.submarine.database.entity.Team;
- private String teamName;
+import java.util.List;
+import java.util.Map;
- // user name
- private String member;
+public interface TeamMapper {
- private Integer inviter;
+ List<Team> selectAll(Map<String, Object> where, RowBounds rowBounds);
- public String getTeamName() {
- return teamName;
- }
+ int deleteByPrimaryKey(String id);
- public void setTeamName(String teamName) {
- this.teamName = teamName;
- }
+ void insert(Team record);
- public String getMember() {
- return member;
- }
+ int insertSelective(Team record);
- public void setMember(String member) {
- this.member = member;
- }
+ Team selectByPrimaryKey(String id);
- public Integer getInviter() {
- return inviter;
- }
+ int updateByPrimaryKeySelective(Team record);
- public void setInviter(Integer inviter) {
- this.inviter = inviter;
- }
+ int updateByPrimaryKey(Team record);
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/TeamMemberMapper.java
similarity index 51%
rename from submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
rename to submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/TeamMemberMapper.java
index bcd0e56..50d2e0f 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/entity/TeamMemeber.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/mappers/TeamMemberMapper.java
@@ -11,38 +11,28 @@
* See the License for the specific language governing permissions and
* limitations under the License. See accompanying LICENSE file.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.database.mappers;
-public class TeamMemeber extends BaseEntity {
+import org.apache.submarine.database.entity.TeamMember;
- private String teamName;
+import java.util.List;
+import java.util.Map;
- // user name
- private String member;
+public interface TeamMemberMapper {
- private Integer inviter;
+ List<TeamMember> selectAll(Map<String, Object> where);
- public String getTeamName() {
- return teamName;
- }
+ int deleteByPrimaryKey(String id);
- public void setTeamName(String teamName) {
- this.teamName = teamName;
- }
+ int deleteSelective(TeamMember record);
- public String getMember() {
- return member;
- }
+ int insert(TeamMember record);
- public void setMember(String member) {
- this.member = member;
- }
+ int insertSelective(TeamMember record);
- public Integer getInviter() {
- return inviter;
- }
+ TeamMember selectByPrimaryKey(String id);
- public void setInviter(Integer inviter) {
- this.inviter = inviter;
- }
+ int updateSelective(TeamMember record);
+
+ int updateByPrimaryKey(TeamMember record);
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysMessageService.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysMessageService.java
new file mode 100644
index 0000000..2ca57ed
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysMessageService.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. See accompanying LICENSE file.
+ */
+package org.apache.submarine.database.service;
+
+import org.apache.ibatis.session.SqlSession;
+import org.apache.submarine.database.MyBatisUtil;
+import org.apache.submarine.database.entity.SysMessage;
+import org.apache.submarine.database.mappers.SysMessageMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SysMessageService {
+ private static final Logger LOG = LoggerFactory.getLogger(SysMessageService.class);
+
+ public void add(SysMessage sysMessage) throws Exception {
+ LOG.info("add({})", sysMessage.toString());
+
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ SysMessageMapper sysMessageMapper = sqlSession.getMapper(SysMessageMapper.class);
+ sysMessageMapper.insert(sysMessage);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysUserService.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysUserService.java
index 87b26ab..cdd1e2b 100755
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysUserService.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/SysUserService.java
@@ -70,12 +70,12 @@ public class SysUserService {
}
public List<SysUser> queryPageList(String userName,
- String email,
- String deptCode,
- String column,
- String field,
- int pageNo,
- int pageSize) throws Exception {
+ String email,
+ String deptCode,
+ String column,
+ String field,
+ int pageNo,
+ int pageSize) throws Exception {
LOG.info("SysUserService::queryPageList userName:{}, email:{}, deptCode:{}, " +
"column:{}, field:{}, pageNo:{}, pageSize:{}",
userName, email, deptCode, column, field, pageNo, pageSize);
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/TeamMemberService.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/TeamMemberService.java
new file mode 100644
index 0000000..c9939dd
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/TeamMemberService.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. See accompanying LICENSE file.
+ */
+package org.apache.submarine.database.service;
+
+import org.apache.ibatis.session.SqlSession;
+import org.apache.submarine.database.MyBatisUtil;
+import org.apache.submarine.database.entity.TeamMember;
+import org.apache.submarine.database.mappers.TeamMemberMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TeamMemberService {
+ private static final Logger LOG = LoggerFactory.getLogger(TeamMemberService.class);
+
+ public List<TeamMember> queryList(String teamName) throws Exception {
+ LOG.info("queryList teamName:{}", teamName);
+
+ List<TeamMember> list = null;
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ Map<String, Object> where = new HashMap<>();
+ where.put("teamName", teamName);
+ list = teamMemberMapper.selectAll(where);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ return list;
+ }
+
+ public void add(TeamMember teamMember) throws Exception {
+ LOG.info("add({})", teamMember.toString());
+
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ teamMemberMapper.insert(teamMember);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ public void deleteByPrimaryKey(String id) throws Exception {
+ LOG.info("deleteByPrimaryKey({})", id);
+
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ teamMemberMapper.deleteByPrimaryKey(id);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/TeamService.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/TeamService.java
new file mode 100644
index 0000000..9ad9c8a
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/service/TeamService.java
@@ -0,0 +1,179 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. See accompanying LICENSE file.
+ */
+package org.apache.submarine.database.service;
+
+import org.apache.ibatis.session.RowBounds;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.submarine.database.MyBatisUtil;
+import org.apache.submarine.database.entity.Team;
+import org.apache.submarine.database.entity.TeamMember;
+import org.apache.submarine.database.mappers.TeamMapper;
+import org.apache.submarine.database.mappers.TeamMemberMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TeamService {
+ private static final Logger LOG = LoggerFactory.getLogger(TeamService.class);
+
+ public List<Team> queryPageList(String owner,
+ String column,
+ String order,
+ int pageNo,
+ int pageSize) throws Exception {
+ LOG.info("queryDictList owner:{}, column:{}, order:{}, pageNo:{}, pageSize:{}",
+ owner, column, order, pageNo, pageSize);
+
+ List<Team> list = null;
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class);
+ Map<String, Object> where = new HashMap<>();
+ where.put("owner", owner);
+ where.put("column", column);
+ where.put("order", order);
+ list = teamMapper.selectAll(where, new RowBounds(pageNo, pageSize));
+
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ // query from team_member table, and set to team
+ for (Team team : list) {
+ Map<String, Object> whereMember = new HashMap<>();
+ whereMember.put("teamId", team.getId());
+ List<TeamMember> teamMembers = teamMemberMapper.selectAll(whereMember);
+ for (TeamMember teamMember : teamMembers) {
+ team.addCollaborator(teamMember);
+ }
+ }
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ return list;
+ }
+
+ public boolean add(Team team) throws Exception {
+ LOG.info("add({})", team.toString());
+
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class);
+ teamMapper.insert(team);
+
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ // add teamMember, when add team, should insert 'Collaborators' to team_member
+ List<TeamMember> list = team.getCollaborators();
+ for (TeamMember teamMember : list) {
+ // todo: teamMember's member is sys_user's id now.
+ teamMember.setTeamId(team.getId());
+ teamMemberMapper.insert(teamMember);
+ }
+
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ return true;
+ }
+
+ public boolean updateByPrimaryKeySelective(Team team) throws Exception {
+ LOG.info("updateByPrimaryKeySelective({})", team.toString());
+
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class);
+ teamMapper.updateByPrimaryKeySelective(team);
+
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ Map<String, Object> where = new HashMap<>();
+ where.put("teamId", team.getId());
+
+ // Take two lists of difference
+ List<TeamMember> old_teamMembers = teamMemberMapper.selectAll(where);
+ List<String> old_teamMembers_member = new ArrayList<>();
+ for (TeamMember old_teamMember : old_teamMembers) {
+ old_teamMembers_member.add(old_teamMember.getMember());
+ }
+
+ List<TeamMember> curr_teamMembers = team.getCollaborators();
+ List<String> curr_teamMembers_member = new ArrayList<>();
+ for (TeamMember curr_teamMember : curr_teamMembers) {
+ curr_teamMembers_member.add(curr_teamMember.getMember());
+ }
+
+ for (TeamMember old : old_teamMembers) {
+ if (!curr_teamMembers_member.contains(old.getMember())) {
+ teamMemberMapper.deleteByPrimaryKey(old.getId());
+ }
+ }
+
+ for (TeamMember curr : curr_teamMembers) {
+ if (!old_teamMembers_member.contains(curr.getMember())) {
+ // todo:teamId Send it by the front desk, here there is no assignment
+ curr.setTeamId(team.getId());
+ curr.setTeamName(team.getTeamName());
+ teamMemberMapper.insert(curr);
+ }
+ }
+
+ // Updates all team_name of corresponding members in the teamMember table
+ TeamMember teamMember = new TeamMember();
+ teamMember.setTeamName(team.getTeamName());
+ teamMember.setTeamId(team.getId());
+ teamMemberMapper.updateSelective(teamMember);
+
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ return true;
+ }
+
+ public boolean delete(String id) throws Exception {
+ LOG.info("delete({})", id);
+ SqlSession sqlSession = null;
+ try {
+ sqlSession = MyBatisUtil.getSqlSession();
+ TeamMapper teamMapper = sqlSession.getMapper(TeamMapper.class);
+ teamMapper.deleteByPrimaryKey(id);
+
+ TeamMemberMapper teamMemberMapper = sqlSession.getMapper(TeamMemberMapper.class);
+ TeamMember teamMember = new TeamMember();
+ teamMember.setTeamId(id);
+ teamMemberMapper.deleteSelective(teamMember);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new Exception(e);
+ } finally {
+ sqlSession.close();
+ }
+ return true;
+ }
+
+}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java
index b382a41..efd8e2c 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java
index 7c421b0..836084d 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java
@@ -57,7 +57,7 @@ public class DictAnnotation {
BeanGenerator generator = new BeanGenerator();
Set keySet = mapProperty.keySet();
- for (Iterator<String> it = keySet.iterator(); it.hasNext();) {
+ for (Iterator<String> it = keySet.iterator(); it.hasNext(); ) {
String key = it.next();
generator.addProperty(key, (Class) mapProperty.get(key));
}
@@ -126,7 +126,7 @@ public class DictAnnotation {
// Map to entity object
DictAnnotation bean = new DictAnnotation(mapFieldAndType);
Set<String> keys = mapFieldAndType.keySet();
- for (Iterator<String> it = keys.iterator(); it.hasNext();) {
+ for (Iterator<String> it = keys.iterator(); it.hasNext(); ) {
String key = it.next();
bean.setValue(key, mapFieldValues.get(key));
}
@@ -152,7 +152,7 @@ public class DictAnnotation {
for (Field field : getAllFields(object)) {
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).Code();
- List<SysDictItem> dictItems = sysDictItemService.queryDictByCode(code);
+ List<SysDictItem> dictItems = sysDictItemService.queryDictByCode(code);
if (dictItems.size() > 0) {
mapDictItems.put(field.getName(), dictItems);
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/MybatisGeneratorMain.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/MybatisGeneratorMain.java
new file mode 100644
index 0000000..b1c3783
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/database/utils/MybatisGeneratorMain.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. See accompanying LICENSE file.
+ */
+package org.apache.submarine.database.utils;
+
+import org.apache.submarine.database.service.TeamService;
+import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.config.Configuration;
+import org.mybatis.generator.config.xml.ConfigurationParser;
+import org.mybatis.generator.exception.InvalidConfigurationException;
+import org.mybatis.generator.exception.XMLParserException;
+import org.mybatis.generator.internal.DefaultShellCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MybatisGeneratorMain {
+ private static final Logger LOG = LoggerFactory.getLogger(TeamService.class);
+
+ public static void main(String[] args) {
+ List<String> warnings = new ArrayList<String>();
+ boolean overwrite = true;
+ // If a null pointer here, write directly absolute path.
+ String genCfg = "/mbgConfiguration.xml";
+ File configFile = new File(MybatisGeneratorMain.class.getResource(genCfg).getFile());
+ ConfigurationParser cp = new ConfigurationParser(warnings);
+ Configuration config = null;
+ try {
+ config = cp.parseConfiguration(configFile);
+ } catch (IOException e) {
+ LOG.error(e.getMessage(), e);
+ } catch (XMLParserException e) {
+ LOG.error(e.getMessage(), e);
+ }
+ DefaultShellCallback callback = new DefaultShellCallback(overwrite);
+ MyBatisGenerator myBatisGenerator = null;
+ try {
+ myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
+ } catch (InvalidConfigurationException e) {
+ LOG.error(e.getMessage(), e);
+ }
+ try {
+ myBatisGenerator.generate(null);
+ } catch (SQLException e) {
+ LOG.error(e.getMessage(), e);
+ } catch (IOException e) {
+ LOG.error(e.getMessage(), e);
+ } catch (InterruptedException e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Permission.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Permission.java
index 10ab0d8..cd53cf9 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Permission.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Permission.java
@@ -34,7 +34,7 @@ public class Permission {
this.actionEntitySet = builder.actionEntitySet;
}
- public static class Builder{
+ public static class Builder {
private final String roleId;
private final String permissionId;
private final String permissionName;
@@ -50,27 +50,27 @@ public class Permission {
this.permissionName = permissionName;
}
- public Builder dataAccess(String dataAccess){
+ public Builder dataAccess(String dataAccess) {
this.dataAccess = dataAccess;
return this;
}
- public Builder actionList(List<Action> actionList){
+ public Builder actionList(List<Action> actionList) {
this.actionList = actionList;
return this;
}
- public Builder actions(List<Action> actions){
+ public Builder actions(List<Action> actions) {
this.actions = actions;
return this;
}
- public Builder actionEntitySet(List<Action> actionEntitySet){
+ public Builder actionEntitySet(List<Action> actionEntitySet) {
this.actionEntitySet = actionEntitySet;
return this;
}
- public Permission build(){
+ public Permission build() {
return new Permission(this);
}
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Role.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Role.java
index 3f6d2de..42e9630 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Role.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/Role.java
@@ -36,7 +36,7 @@ public class Role {
this.permissions = builder.permissions;
}
- public static class Builder{
+ public static class Builder {
private final String id;
private final String name;
@@ -52,37 +52,37 @@ public class Role {
this.name = name;
}
- public Builder describe(String describe){
+ public Builder describe(String describe) {
this.describe = describe;
return this;
}
- public Builder status(int status){
+ public Builder status(int status) {
this.status = status;
return this;
}
- public Builder creatorId(String creatorId){
+ public Builder creatorId(String creatorId) {
this.creatorId = creatorId;
return this;
}
- public Builder createTime(long createTime){
+ public Builder createTime(long createTime) {
this.createTime = createTime;
return this;
}
- public Builder deleted(int deleted){
+ public Builder deleted(int deleted) {
this.deleted = deleted;
return this;
}
- public Builder permissions(List<Permission> permissions){
+ public Builder permissions(List<Permission> permissions) {
this.permissions = permissions;
return this;
}
- public Role build(){
+ public Role build() {
return new Role(this);
}
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/User.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/User.java
index 1694446..ff8d455 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/User.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/User.java
@@ -48,7 +48,7 @@ public class User {
this.token = builder.token;
}
- public static class Builder{
+ public static class Builder {
private final String id;
private final String name;
private String username;
@@ -70,72 +70,72 @@ public class User {
this.name = name;
}
- public Builder username(String username){
+ public Builder username(String username) {
this.username = username;
return this;
}
- public Builder password(String password){
+ public Builder password(String password) {
this.password = password;
return this;
}
- public Builder avatar(String avatar){
+ public Builder avatar(String avatar) {
this.avatar = avatar;
return this;
}
- public Builder status(int status){
+ public Builder status(int status) {
this.status = status;
return this;
}
- public Builder lastLoginIp(String lastLoginIp){
+ public Builder lastLoginIp(String lastLoginIp) {
this.lastLoginIp = lastLoginIp;
return this;
}
- public Builder lastLoginTime(long lastLoginTime){
+ public Builder lastLoginTime(long lastLoginTime) {
this.lastLoginTime = lastLoginTime;
return this;
}
- public Builder creatorId(String creatorId){
+ public Builder creatorId(String creatorId) {
this.creatorId = creatorId;
return this;
}
- public Builder telephone(String telephone){
+ public Builder telephone(String telephone) {
this.telephone = telephone;
return this;
}
- public Builder createTime(long createTime){
+ public Builder createTime(long createTime) {
this.createTime = createTime;
return this;
}
- public Builder deleted(int deleted){
+ public Builder deleted(int deleted) {
this.deleted = deleted;
return this;
}
- public Builder roleId(String roleId){
+ public Builder roleId(String roleId) {
this.roleId = roleId;
return this;
}
- public Builder lang(String lang){
+ public Builder lang(String lang) {
this.lang = lang;
return this;
}
- public Builder token(String token){
+ public Builder token(String token) {
this.token = token;
return this;
}
- public User build(){
+ public User build() {
return new User(this);
}
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/UserInfo.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/UserInfo.java
index e18fd47..1a01038 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/UserInfo.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/entity/UserInfo.java
@@ -71,72 +71,72 @@ public class UserInfo {
this.name = name;
}
- public Builder username(String username){
+ public Builder username(String username) {
this.username = username;
return this;
}
- public Builder password(String password){
+ public Builder password(String password) {
this.password = password;
return this;
}
- public Builder avatar(String avatar){
+ public Builder avatar(String avatar) {
this.avatar = avatar;
return this;
}
- public Builder status(int status){
+ public Builder status(int status) {
this.status = status;
return this;
}
- public Builder lastLoginIp(String lastLoginIp){
+ public Builder lastLoginIp(String lastLoginIp) {
this.lastLoginIp = lastLoginIp;
return this;
}
- public Builder lastLoginTime(long lastLoginTime){
+ public Builder lastLoginTime(long lastLoginTime) {
this.lastLoginTime = lastLoginTime;
return this;
}
- public Builder creatorId(String creatorId){
+ public Builder creatorId(String creatorId) {
this.creatorId = creatorId;
return this;
}
- public Builder telephone(String telephone){
+ public Builder telephone(String telephone) {
this.telephone = telephone;
return this;
}
- public Builder createTime(long createTime){
+ public Builder createTime(long createTime) {
this.createTime = createTime;
return this;
}
- public Builder deleted(int deleted){
+ public Builder deleted(int deleted) {
this.deleted = deleted;
return this;
}
- public Builder roleId(String roleId){
+ public Builder roleId(String roleId) {
this.roleId = roleId;
return this;
}
- public Builder merchantCode(String merchantCode){
+ public Builder merchantCode(String merchantCode) {
this.merchantCode = merchantCode;
return this;
}
- public Builder role(Role role){
+ public Builder role(Role role) {
this.role = role;
return this;
}
- public UserInfo build(){
+ public UserInfo build() {
return new UserInfo(this);
}
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java
index 9e1ae26..7a0f0c7 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java
index ee790d3..cd1025e 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java
@@ -2,9 +2,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -212,7 +212,7 @@ public class SysDictItemRestApi {
LOG.info("dictCode : " + dictCode);
SysDictItemService sysDictItemService = new SysDictItemService();
- List<SysDictItem> dictItems = sysDictItemService.queryDictByCode(dictCode);
+ List<SysDictItem> dictItems = sysDictItemService.queryDictByCode(dictCode);
ListResult<SysDictItem> listResult = new ListResult(dictItems, dictItems.size());
return new JsonResponse.Builder<ListResult<SysDictItem>>(Response.Status.OK)
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java
index e45ed3f..ddf38aa 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java
@@ -2,9 +2,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java
index 34ec8ee..f2477e4 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java
@@ -2,9 +2,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java
index ccf0376..ec269ab 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java
@@ -2,9 +2,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -14,10 +14,10 @@
package org.apache.submarine.rest;
import com.github.pagehelper.PageInfo;
-import com.google.gson.Gson;
import org.apache.submarine.annotation.SubmarineApi;
import org.apache.submarine.database.entity.Team;
-import org.apache.submarine.database.entity.TeamMemeber;
+import org.apache.submarine.database.service.SysMessageService;
+import org.apache.submarine.database.service.TeamService;
import org.apache.submarine.server.JsonResponse;
import org.apache.submarine.server.JsonResponse.ListResult;
import org.slf4j.Logger;
@@ -25,16 +25,15 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
import javax.ws.rs.Path;
+import javax.ws.rs.GET;
import javax.ws.rs.Produces;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.PUT;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
@Path("/team")
@@ -43,7 +42,8 @@ import java.util.List;
public class TeamRestApi {
private static final Logger LOG = LoggerFactory.getLogger(TeamRestApi.class);
- private static final Gson gson = new Gson();
+ private TeamService teamService = new TeamService();
+ private SysMessageService sysMessageService = new SysMessageService();
@Inject
public TeamRestApi() {
@@ -59,37 +59,15 @@ public class TeamRestApi {
@QueryParam("pageSize") int pageSize) {
LOG.info("TeamRestApi.list() owner:{}, pageNo:{}, pageSize:{}", owner, pageNo, pageSize);
- // mock data
List<Team> teams = new ArrayList<>();
- for (int i = 0; i < 3; i++) {
- Team team = new Team();
- team.setId("team" + i);
-
- // test different owner
- if (i == 0) {
- team.setOwner("admin");
- } else if (i == 1) {
- team.setOwner("liuxun");
- } else {
- team.setOwner("test");
- }
-
- team.setTeamName("test-team" + i);
-
- for (int j = 0; j < 3; j++) {
- TeamMemeber memeber = new TeamMemeber();
- memeber.setId("team" + i + "name" + j + "-id");
- memeber.setMember("team" + i + "name" + j);
- if (j == 0) {
- memeber.setInviter(0);
- } else {
- memeber.setInviter(1);
- }
- team.addCollaborator(memeber);
- }
- teams.add(team);
+ try {
+ // TODO(zhulinhao): Front need to correct 'owner' value, and Whether need the
+ // front to create_by value(At the time of pr commited)
+ teams = teamService.queryPageList("liuxun", column, order, pageNo, pageSize);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<>(Response.Status.OK).success(false).build();
}
-
PageInfo<Team> page = new PageInfo<>(teams);
ListResult<Team> listResult = new ListResult(teams, page.getTotal());
return new JsonResponse.Builder<ListResult<Team>>(Response.Status.OK)
@@ -103,11 +81,25 @@ public class TeamRestApi {
LOG.info("add team:{}", team.toString());
// insert into database, return id
- Date mockId = new Date();
- team.setId(String.valueOf(mockId.getTime()));
+ try {
+ teamService.add(team);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<>(Response.Status.OK).success(false)
+ .message("Save team failed!").build();
+ }
- // 为每个成员,增加邀请信息保存到 sys_message 表中
+ // TODO(zhulinhao): add message
+ // For each of the members, increase the invitation information saved to sys_message table
+ /**SysMessage sysMessage = new SysMessage();
+ try {
+ sysMessageService.add(sysMessage);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<>(Response.Status.OK).success(false)
+ .message("Save team failed!").build();
+ }*/
return new JsonResponse.Builder<Team>(Response.Status.OK)
.message("Save team successfully!").result(team).success(true).build();
@@ -119,31 +111,41 @@ public class TeamRestApi {
public Response edit(Team team) {
LOG.info("edit team:{}", team.toString());
- // todo(zhulinhao)
- // 把 team 保存到 team 表中
+ // TODO(zhulinhao): need set update_by value
+ try {
+ // update team
+ teamService.updateByPrimaryKeySelective(team);
- List<TeamMemeber> memebers = team.getCollaborators();
- // 将每个 TeamMemeber 保存到 team_member table 中
- // 前端有如下情况:
- // 1. 前端没有对成员进行修改
- // 2. 前端新增了成员
- // 3. 前端删除了成员
+ // TODO(zhulinhao)
+ // Save inviter=0 in the newly added member and the invitation
+ // message to join the team that has not been sent into the message
+ // table sys_message to avoid sending the invitation message repeatedly
- // 将新增的成员中inviter=0,并且没有发送过加入 team 邀请信息
- // 保存到消息表 sys_message 中,避免重复发送邀请信息
+ } catch (Exception e) {
+ return new JsonResponse.Builder<>(Response.Status.OK).success(false)
+ .message("update team failed!").build();
+ }
return new JsonResponse.Builder<>(Response.Status.OK)
- .message("Save team successfully!").success(true).build();
+ .message("update team successfully!").success(true).build();
}
@DELETE
@Path("/delete")
@SubmarineApi
public Response delete(@QueryParam("id") String id) {
+ // TODO(zhulinhao): At the front desk need to id
LOG.info("delete team:{}", id);
- // 删除 team 和 team_member 表中的数据
- // 删除 sys_message 中的邀请信息
+ // Delete data in a team and team_member table
+ // TODO(zhulinhao):delete sys_message's invite messages
+ try {
+ teamService.delete(id);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<>(Response.Status.OK).success(false)
+ .message("delete team failed!").build();
+ }
return new JsonResponse.Builder<>(Response.Status.OK)
.message("Delete team successfully!").success(true).build();
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java
index 78c5946..bc1af9b 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java
@@ -1,18 +1,15 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. See accompanying LICENSE file.
*/
package org.apache.submarine.server;
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonResponse.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonResponse.java
index 3bf7b80..fd6bfa0 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonResponse.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/JsonResponse.java
@@ -1,18 +1,15 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. See accompanying LICENSE file.
*/
package org.apache.submarine.server;
@@ -100,27 +97,27 @@ public class JsonResponse<T> {
return this;
}
- public Builder success(Boolean success){
+ public Builder success(Boolean success) {
this.success = success;
return this;
}
- public Builder message(String message){
+ public Builder message(String message) {
this.message = message;
return this;
}
- public Builder result(T result){
+ public Builder result(T result) {
this.result = result;
return this;
}
- public Builder code(int code){
+ public Builder code(int code) {
this.code = code;
return this;
}
- public Builder cookies(ArrayList<NewCookie> newCookies){
+ public Builder cookies(ArrayList<NewCookie> newCookies) {
if (cookies == null) {
cookies = new ArrayList<>();
}
@@ -128,7 +125,7 @@ public class JsonResponse<T> {
return this;
}
- public javax.ws.rs.core.Response build(){
+ public javax.ws.rs.core.Response build() {
JsonResponse jsonResponse = new JsonResponse(this);
return jsonResponse.build();
}
diff --git a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java
index d63a15c..350fdea 100644
--- a/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java
+++ b/submarine-workbench/submarine-server/src/main/java/org/apache/submarine/server/SubmarineConfiguration.java
@@ -205,7 +205,7 @@ public class SubmarineConfiguration extends XMLConfiguration {
}
}
- public boolean isWindowsPath(String path){
+ public boolean isWindowsPath(String path) {
return path.matches("^[A-Za-z]:\\\\.*");
}
@@ -482,7 +482,8 @@ public class SubmarineConfiguration extends XMLConfiguration {
enum VarType {
STRING {
@Override
- void checkType(String value) throws Exception {}
+ void checkType(String value) throws Exception {
+ }
},
INT {
@Override
diff --git a/submarine-workbench/submarine-server/src/main/resources/mbgConfiguration.xml b/submarine-workbench/submarine-server/src/main/resources/mbgConfiguration.xml
new file mode 100644
index 0000000..604c01f
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/resources/mbgConfiguration.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<!DOCTYPE generatorConfiguration
+ PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+ "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+<generatorConfiguration>
+ <context id="sqlserverTables" targetRuntime="MyBatis3">
+ <commentGenerator>
+ <!-- Whether to remove automatically generated annotation -->
+ <property name="suppressAllComments" value="true"/>
+ </commentGenerator>
+
+ <jdbcConnection driverClass="com.mysql.jdbc.Driver"
+ connectionURL="jdbc:mysql://127.0.0.1:3306/submarineDB"
+ userId="submarine"
+ password="password">
+ </jdbcConnection>
+
+ <javaTypeResolver>
+ <property name="forceBigDecimals" value="false"/>
+ </javaTypeResolver>
+
+ <!-- Generation model, the corresponding package path and file storage path (targetProject),
+ You can specify a specific path, such as: ./src/main/java, -->
+ <javaModelGenerator targetPackage="org.apache.submarine.database.entity" targetProject="/tmp">
+ <property name="enableSubPackages" value="true"/>
+ <!-- From the database of Spaces before and after the value returned is cleared -->
+ <property name="trimStrings" value="true"/>
+ </javaModelGenerator>
+
+ <!-- The corresponding mapper.xml file -->
+ <sqlMapGenerator targetPackage="org.apache.submarine.database.mappers" targetProject="/tmp">
+ <property name="enableSubPackages" value="true"/>
+ </sqlMapGenerator>
+
+ <!-- The corresponding Mapper interfaces class files -->
+ <javaClientGenerator type="XMLMAPPER" targetPackage="org.apache.submarine.database.mappers" targetProject="/tmp">
+ <property name="enableSubPackages" value="true"/>
+ </javaClientGenerator>
+
+ <!-- List all the table to generate the code, configuration is not generate Example files here -->
+ <table tableName="team_member" domainObjectName="TeamMember"
+ enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
+ enableSelectByExample="false" selectByExampleQueryId="false">
+ <property name="useActualColumnNames" value="false"/>
+ </table>
+ </context>
+</generatorConfiguration>
diff --git a/submarine-workbench/submarine-server/src/main/resources/mybatis-config.xml b/submarine-workbench/submarine-server/src/main/resources/mybatis-config.xml
index 76fd7cd..2264910 100755
--- a/submarine-workbench/submarine-server/src/main/resources/mybatis-config.xml
+++ b/submarine-workbench/submarine-server/src/main/resources/mybatis-config.xml
@@ -55,5 +55,7 @@
<mapper resource='org/apache/submarine/database/mappers/SysDictMapper.xml'/>
<mapper resource='org/apache/submarine/database/mappers/SysDictItemMapper.xml'/>
<mapper resource='org/apache/submarine/database/mappers/SysDeptMapper.xml'/>
+ <mapper resource='org/apache/submarine/database/mappers/TeamMapper.xml'/>
+ <mapper resource='org/apache/submarine/database/mappers/TeamMemberMapper.xml'/>
</mappers>
</configuration>
diff --git a/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml b/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
new file mode 100644
index 0000000..7a62bf5
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.submarine.database.mappers.SysMessageMapper">
+ <resultMap id="BaseEntityResultMap" type="org.apache.submarine.database.entity.BaseEntity">
+ <id property="id" column="id"/>
+ <result column="create_by" property="createBy"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_by" property="updateBy"/>
+ <result column="update_time" property="updateTime"/>
+ </resultMap>
+
+ <resultMap id="resultMap" type="org.apache.submarine.database.entity.SysMessage" extends="BaseEntityResultMap">
+ <result column="sender" jdbcType="VARCHAR" property="sender"/>
+ <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
+ <result column="type" jdbcType="VARCHAR" property="type"/>
+ <result column="status" jdbcType="INTEGER" property="status"/>
+ <result column="context" jdbcType="LONGVARCHAR" property="context"/>
+ </resultMap>
+
+ <resultMap extends="resultMap" id="ResultMapWithBLOBs" type="org.apache.submarine.database.entity.SysMessage">
+ <result column="context" jdbcType="LONGVARCHAR" property="context"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id, sender, receiver, type, status, create_by, create_time, update_by, update_time
+ </sql>
+ <sql id="Blob_Column_List">
+ context
+ </sql>
+
+ <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
+ select
+ <include refid="Base_Column_List"/>
+ ,
+ <include refid="Blob_Column_List"/>
+ from sys_message
+ where id = #{id,jdbcType=VARCHAR}
+ </select>
+
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+ delete from sys_message
+ where id = #{id,jdbcType=VARCHAR}
+ </delete>
+
+ <insert id="insert" parameterType="org.apache.submarine.database.entity.SysMessage">
+ insert into sys_message (id, sender, receiver,
+ type, status, create_by,
+ create_time, update_time,
+ context)
+ values (REPLACE(UUID(),"-",""), #{sender,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR},
+ #{type,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR},
+ now(), now()
+ #{context,jdbcType=LONGVARCHAR})
+ </insert>
+
+ <insert id="insertSelective" parameterType="org.apache.submarine.database.entity.SysMessage">
+ insert into sys_message
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ id,
+ </if>
+ <if test="sender != null">
+ sender,
+ </if>
+ <if test="receiver != null">
+ receiver,
+ </if>
+ <if test="type != null">
+ type,
+ </if>
+ <if test="status != null">
+ status,
+ </if>
+ <if test="createBy != null">
+ create_by,
+ </if>
+ <if test="createTime != null">
+ create_time,
+ </if>
+ <if test="updateBy != null">
+ update_by,
+ </if>
+ <if test="updateTime != null">
+ update_time,
+ </if>
+ <if test="context != null">
+ context,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ #{id,jdbcType=VARCHAR},
+ </if>
+ <if test="sender != null">
+ #{sender,jdbcType=VARCHAR},
+ </if>
+ <if test="receiver != null">
+ #{receiver,jdbcType=VARCHAR},
+ </if>
+ <if test="type != null">
+ #{type,jdbcType=VARCHAR},
+ </if>
+ <if test="status != null">
+ #{status,jdbcType=INTEGER},
+ </if>
+ <if test="createBy != null">
+ #{createBy,jdbcType=VARCHAR},
+ </if>
+ <if test="createTime != null">
+ #{createTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="updateBy != null">
+ #{updateBy,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null">
+ #{updateTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="context != null">
+ #{context,jdbcType=LONGVARCHAR},
+ </if>
+ </trim>
+ </insert>
+
+ <update id="updateByPrimaryKeySelective" parameterType="org.apache.submarine.database.entity.SysMessage">
+ update sys_message
+ <set>
+ <if test="sender != null">
+ sender = #{sender,jdbcType=VARCHAR},
+ </if>
+ <if test="receiver != null">
+ receiver = #{receiver,jdbcType=VARCHAR},
+ </if>
+ <if test="type != null">
+ type = #{type,jdbcType=VARCHAR},
+ </if>
+ <if test="status != null">
+ status = #{status,jdbcType=INTEGER},
+ </if>
+ <if test="createBy != null">
+ create_by = #{createBy,jdbcType=VARCHAR},
+ </if>
+ <if test="createTime != null">
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="updateBy != null">
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null">
+ update_time = #{updateTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="context != null">
+ context = #{context,jdbcType=LONGVARCHAR},
+ </if>
+ </set>
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+
+ <update id="updateByPrimaryKeyWithBLOBs" parameterType="org.apache.submarine.database.entity.SysMessage">
+ update sys_message
+ set sender = #{sender,jdbcType=VARCHAR},
+ receiver = #{receiver,jdbcType=VARCHAR},
+ type = #{type,jdbcType=VARCHAR},
+ status = #{status,jdbcType=INTEGER},
+ create_by = #{createBy,jdbcType=VARCHAR},
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ update_time = #{updateTime,jdbcType=TIMESTAMP},
+ context = #{context,jdbcType=LONGVARCHAR}
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+
+ <update id="updateByPrimaryKey" parameterType="org.apache.submarine.database.entity.SysMessage">
+ update sys_message
+ set sender = #{sender,jdbcType=VARCHAR},
+ receiver = #{receiver,jdbcType=VARCHAR},
+ type = #{type,jdbcType=VARCHAR},
+ status = #{status,jdbcType=INTEGER},
+ create_by = #{createBy,jdbcType=VARCHAR},
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ update_time = #{updateTime,jdbcType=TIMESTAMP}
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+</mapper>
\ No newline at end of file
diff --git a/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/TeamMapper.xml b/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/TeamMapper.xml
new file mode 100644
index 0000000..7f6dc53
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/TeamMapper.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.submarine.database.mappers.TeamMapper">
+ <resultMap id="BaseEntityResultMap" type="org.apache.submarine.database.entity.BaseEntity">
+ <id property="id" column="id"/>
+ <result column="create_by" property="createBy"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_by" property="updateBy"/>
+ <result column="update_time" property="updateTime"/>
+ </resultMap>
+
+ <resultMap id="resultMap" type="org.apache.submarine.database.entity.Team" extends="BaseEntityResultMap">
+ <result column="owner" jdbcType="VARCHAR" property="owner"/>
+ <result column="team_name" jdbcType="VARCHAR" property="teamName"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id, owner, team_name, create_by, create_time, update_by, update_time
+ </sql>
+
+ <select id="selectAll" parameterType="java.util.Map" resultMap="resultMap">
+ SELECT
+ <include refid="Base_Column_List"/>
+ FROM team
+ WHERE 1 = 1
+ <if test="owner!=null and owner!=''">AND `owner` = #{owner}</if>
+ ORDER BY #{column} #{order}
+ </select>
+
+ <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="resultMap">
+ select
+ <include refid="Base_Column_List"/>
+ from team
+ where id = #{id,jdbcType=VARCHAR}
+ </select>
+
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+ delete from team
+ where id = #{id,jdbcType=VARCHAR}
+ </delete>
+
+ <insert id="insert" parameterType="org.apache.submarine.database.entity.Team">
+ <selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
+ SELECT REPLACE(UUID(),"-","")
+ </selectKey>
+ insert into team (id, owner, team_name, create_by, create_time, update_time)
+ values (#{id,jdbcType=VARCHAR}, #{owner,jdbcType=VARCHAR}, #{teamName,jdbcType=VARCHAR},
+ #{createBy,jdbcType=VARCHAR}, now(), now())
+ </insert>
+
+ <insert id="insertSelective" parameterType="org.apache.submarine.database.entity.Team">
+ insert into team
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ id,
+ </if>
+ <if test="owner != null">
+ owner,
+ </if>
+ <if test="teamName != null">
+ team_name,
+ </if>
+ <if test="createBy != null">
+ create_by,
+ </if>
+ <if test="createTime != null">
+ create_time,
+ </if>
+ <if test="updateBy != null">
+ update_by,
+ </if>
+ <if test="updateTime != null">
+ update_time,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ #{id,jdbcType=VARCHAR},
+ </if>
+ <if test="owner != null">
+ #{owner,jdbcType=VARCHAR},
+ </if>
+ <if test="teamName != null">
+ #{teamName,jdbcType=VARCHAR},
+ </if>
+ <if test="createBy != null">
+ #{createBy,jdbcType=VARCHAR},
+ </if>
+ <if test="createTime != null">
+ #{createTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="updateBy != null">
+ #{updateBy,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null">
+ #{updateTime,jdbcType=TIMESTAMP},
+ </if>
+ </trim>
+ </insert>
+
+ <update id="updateByPrimaryKeySelective" parameterType="org.apache.submarine.database.entity.Team">
+ update team
+ <set>
+ <if test="owner != null">
+ owner = #{owner,jdbcType=VARCHAR},
+ </if>
+ <if test="teamName != null">
+ team_name = #{teamName,jdbcType=VARCHAR},
+ </if>
+ <if test="updateBy != null">
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null">
+ update_time = now()
+ </if>
+ </set>
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+
+ <update id="updateByPrimaryKey" parameterType="org.apache.submarine.database.entity.Team">
+ update team
+ set owner = #{owner,jdbcType=VARCHAR},
+ team_name = #{teamName,jdbcType=VARCHAR},
+ create_by = #{createBy,jdbcType=VARCHAR},
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ update_time = #{updateTime,jdbcType=TIMESTAMP}
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+</mapper>
\ No newline at end of file
diff --git a/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/TeamMemberMapper.xml b/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/TeamMemberMapper.xml
new file mode 100644
index 0000000..e9ae7c9
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/main/resources/org/apache/submarine/database/mappers/TeamMemberMapper.xml
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.submarine.database.mappers.TeamMemberMapper">
+ <resultMap id="BaseEntityResultMap" type="org.apache.submarine.database.entity.BaseEntity">
+ <id property="id" column="id" />
+ <result column="create_by" property="createBy"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_by" property="updateBy"/>
+ <result column="update_time" property="updateTime"/>
+ </resultMap>
+
+ <resultMap id="resultMap" type="org.apache.submarine.database.entity.TeamMember" extends="BaseEntityResultMap">
+ <result column="team_id" jdbcType="VARCHAR" property="teamId"/>
+ <result column="team_name" jdbcType="VARCHAR" property="teamName"/>
+ <result column="member" jdbcType="VARCHAR" property="member"/>
+ <result column="inviter" jdbcType="INTEGER" property="inviter"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id, team_id, team_name, member, inviter, create_by, create_time, update_by, update_time
+ </sql>
+
+ <select id="selectAll" parameterType="java.util.Map" resultMap="resultMap">
+ SELECT
+ <include refid="Base_Column_List"/>
+ FROM team_member
+ WHERE 1 = 1
+ <if test="teamId != null">
+ AND team_id = #{teamId,jdbcType=VARCHAR}
+ </if>
+ </select>
+
+ <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="resultMap">
+ select
+ <include refid="Base_Column_List"/>
+ from team_member
+ where id = #{id,jdbcType=VARCHAR}
+ </select>
+
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+ delete from team_member
+ where id = #{id,jdbcType=VARCHAR}
+ </delete>
+
+ <delete id="deleteSelective" parameterType="org.apache.submarine.database.entity.TeamMember">
+ delete from team_member
+ where 1 = 1
+ <if test="teamId != null">
+ AND team_id = #{teamId,jdbcType=VARCHAR}
+ </if>
+ </delete>
+
+ <insert id="insert" parameterType="org.apache.submarine.database.entity.TeamMember">
+ <selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
+ SELECT REPLACE(UUID(),"-","")
+ </selectKey>
+ insert into team_member (id, team_id, team_name, member,
+ inviter, create_by, create_time, update_time)
+ values (#{id,jdbcType=VARCHAR}, #{teamId,jdbcType=VARCHAR}, #{teamName,jdbcType=VARCHAR}, #{member,jdbcType=VARCHAR},
+ #{inviter,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, now(), now())
+ </insert>
+
+ <insert id="insertSelective" parameterType="org.apache.submarine.database.entity.TeamMember">
+ insert into team_member
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ id,
+ </if>
+ <if test="teamId != null">
+ team_id,
+ </if>
+ <if test="teamName != null">
+ team_name,
+ </if>
+ <if test="member != null">
+ member,
+ </if>
+ <if test="inviter != null">
+ inviter,
+ </if>
+ <if test="createBy != null">
+ create_by,
+ </if>
+ <if test="createTime != null">
+ create_time,
+ </if>
+ <if test="updateBy != null">
+ update_by,
+ </if>
+ <if test="updateTime != null">
+ update_time,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ #{id,jdbcType=VARCHAR},
+ </if>
+ <if test="teamId != null">
+ #{teamId,jdbcType=VARCHAR},
+ </if>
+ <if test="teamName != null">
+ #{teamName,jdbcType=VARCHAR},
+ </if>
+ <if test="member != null">
+ #{member,jdbcType=VARCHAR},
+ </if>
+ <if test="inviter != null">
+ #{inviter,jdbcType=INTEGER},
+ </if>
+ <if test="createBy != null">
+ #{createBy,jdbcType=VARCHAR},
+ </if>
+ <if test="createTime != null">
+ #{createTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="updateBy != null">
+ #{updateBy,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null">
+ #{updateTime,jdbcType=TIMESTAMP},
+ </if>
+ </trim>
+ </insert>
+
+ <update id="updateSelective" parameterType="org.apache.submarine.database.entity.TeamMember">
+ update team_member
+ <set>
+ <if test="teamName != null">
+ team_name = #{teamName,jdbcType=VARCHAR},
+ </if>
+ <if test="member != null">
+ member = #{member,jdbcType=VARCHAR},
+ </if>
+ <if test="inviter != null">
+ inviter = #{inviter,jdbcType=INTEGER},
+ </if>
+ <if test="createBy != null">
+ create_by = #{createBy,jdbcType=VARCHAR},
+ </if>
+ <if test="createTime != null">
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="updateBy != null">
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null">
+ update_time = #{updateTime,jdbcType=TIMESTAMP},
+ </if>
+ </set>
+ where 1 = 1
+ <if test="id != null">
+ AND id = #{id,jdbcType=VARCHAR}
+ </if>
+ <if test="teamId != null">
+ AND team_id = #{teamId,jdbcType=VARCHAR}
+ </if>
+ </update>
+
+ <update id="updateByPrimaryKey" parameterType="org.apache.submarine.database.entity.TeamMember">
+ update team_member
+ set team_id = #{teamId,jdbcType=VARCHAR},
+ team_name = #{teamName,jdbcType=VARCHAR},
+ member = #{member,jdbcType=VARCHAR},
+ inviter = #{inviter,jdbcType=INTEGER},
+ create_by = #{createBy,jdbcType=VARCHAR},
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ update_by = #{updateBy,jdbcType=VARCHAR},
+ update_time = #{updateTime,jdbcType=TIMESTAMP}
+ where id = #{id,jdbcType=VARCHAR}
+ </update>
+</mapper>
\ No newline at end of file
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/SysUserServiceTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/SysUserServiceTest.java
index 621d4ad..09e69c1 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/SysUserServiceTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/SysUserServiceTest.java
@@ -2,9 +2,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/TeamServiceTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/TeamServiceTest.java
new file mode 100644
index 0000000..56ad735
--- /dev/null
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/database/service/TeamServiceTest.java
@@ -0,0 +1,146 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. See accompanying LICENSE file.
+ */
+package org.apache.submarine.database.service;
+
+import org.apache.submarine.database.entity.Team;
+import org.apache.submarine.database.entity.TeamMember;
+import org.junit.After;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TeamServiceTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TeamServiceTest.class);
+ TeamService teamService = new TeamService();
+
+ @After
+ public void removeAllRecord() throws Exception {
+ List<Team> teamList = teamService.queryPageList(null, "create_time", "desc", 0, 100);
+ LOG.info("teamList.size():{}", teamList.size());
+ for (Team team : teamList) {
+ teamService.delete(team.getId());
+ }
+ }
+
+ @Test
+ public void queryPageList() throws Exception {
+ TeamMember teamMember = new TeamMember();
+ teamMember.setTeamName("submarine");
+ teamMember.setInviter(0);
+ teamMember.setMember("admin");
+ teamMember.setCreateBy("createByteamMember");
+
+ Team team = new Team();
+ team.setTeamName("submarine");
+ team.setOwner("test_sub");
+ team.setCreateBy("createByteam");
+ List list = new ArrayList<TeamMember>();
+ list.add(teamMember);
+ team.setCollaborators(list);
+ Boolean ret = teamService.add(team);
+ assertTrue(ret);
+
+ List<Team> teamList = teamService.queryPageList("test_sub", "create_time", "desc", 0, 100);
+ assertEquals(teamList.size(), 1);
+ Team team_db = teamList.get(0);
+ assertEquals(team.getTeamName(), team_db.getTeamName());
+ assertEquals(team.getOwner(), team_db.getOwner());
+ assertEquals(team.getCreateBy(), team_db.getCreateBy());
+
+ assertEquals(team_db.getCollaborators().size(), 1);
+ TeamMember teamMember_db = team_db.getCollaborators().get(0);
+ assertEquals(team.getId(), teamMember_db.getTeamId());
+ assertEquals(teamMember.getTeamName(), teamMember_db.getTeamName());
+ assertEquals(teamMember.getInviter(), teamMember_db.getInviter());
+ assertEquals(teamMember.getMember(), teamMember_db.getMember());
+ assertEquals(teamMember.getCreateBy(), teamMember_db.getCreateBy());
+ }
+
+ @Test
+ public void updateByPrimaryKeySelective() throws Exception {
+ TeamMember teamMember = new TeamMember();
+ teamMember.setTeamName("submarine");
+ teamMember.setInviter(0);
+ teamMember.setMember("admin");
+ teamMember.setCreateBy("createByteamMember");
+
+ Team team = new Team();
+ team.setTeamName("submarine");
+ team.setOwner("test_sub");
+ team.setCreateBy("createByteam");
+ List list = new ArrayList<TeamMember>();
+ list.add(teamMember);
+ team.setCollaborators(list);
+ Boolean ret = teamService.add(team);
+ assertTrue(ret);
+
+ team.setTeamName("submarine_update");
+ TeamMember teamMember_update = new TeamMember();
+ teamMember_update.setTeamName("submarine");
+ teamMember_update.setInviter(0);
+ teamMember_update.setMember("test_member");
+ teamMember_update.setCreateBy("createByteamMember2");
+ list.add(teamMember_update);
+
+ boolean editRet = teamService.updateByPrimaryKeySelective(team);
+ assertTrue(editRet);
+ List<Team> teamList = teamService.queryPageList("test_sub", "create_time", "desc", 0, 100);
+ assertEquals(teamList.size(), 1);
+
+ Team team_db = teamList.get(0);
+ assertEquals(team.getTeamName(), team_db.getTeamName());
+ List<TeamMember> teamMemberList = team_db.getCollaborators();
+ assertEquals(teamMemberList.size(), 2);
+ for (TeamMember member : teamMemberList) {
+ assertEquals(member.getTeamName(), team.getTeamName());
+ }
+
+ }
+
+ @Test
+ public void delete() throws Exception {
+ TeamMember teamMember = new TeamMember();
+ teamMember.setTeamName("submarine");
+ teamMember.setInviter(0);
+ teamMember.setMember("admin");
+ teamMember.setCreateBy("createByteamMember");
+
+ Team team = new Team();
+ team.setTeamName("submarine");
+ team.setOwner("test_sub");
+ team.setCreateBy("createByteam");
+ List list = new ArrayList<TeamMember>();
+ list.add(teamMember);
+ team.setCollaborators(list);
+ Boolean ret = teamService.add(team);
+ assertTrue(ret);
+
+ Boolean deleteRet = teamService.delete(team.getId());
+ assertTrue(deleteRet);
+
+ List<Team> teamList = teamService.queryPageList("test_sub", "create_time", "desc", 0, 100);
+ assertEquals(teamList.size(), 0);
+
+ TeamMemberService teamMemberService = new TeamMemberService();
+ List<TeamMember> teamMemberList = teamMemberService.queryList(team.getTeamName());
+ assertEquals(teamMemberList.size(), 0);
+ }
+}
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/CommonDataTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/CommonDataTest.java
index 903810f..ac35a75 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/CommonDataTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/CommonDataTest.java
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -172,7 +172,7 @@ public class CommonDataTest {
sysUser.setCreateTime(new Date());
sysUser.setUpdateTime(new Date());
- Response response = userRestApi.add(sysUser);
+ Response response = userRestApi.add(sysUser);
JsonResponse<SysUser> jsonResponse = assertUserResponseSuccess(response);
userId = jsonResponse.getResult().getId();
}
@@ -185,7 +185,7 @@ public class CommonDataTest {
}
public static void clearDictItemTable() {
- Response response = dictItemRestApi.list(null, null, null, null, null, null, 1, 10);
+ Response response = dictItemRestApi.list(null, null, null, null, null, null, 1, 10);
assertDictItemResponseSuccess(response);
JsonResponse<ListResult<SysDictItem>> jsonResponse = assertDictItemResponseSuccess(response);
for (SysDictItem dictItem : jsonResponse.getResult().getRecords()) {
@@ -194,7 +194,7 @@ public class CommonDataTest {
}
public static void clearDictTable() {
- Response response = dictRestApi.list(null, null, null, null, null, 1, 10);
+ Response response = dictRestApi.list(null, null, null, null, null, 1, 10);
assertDictResponseSuccess(response);
JsonResponse<ListResult<SysDict>> jsonResponse = assertDictResponseSuccess(response);
for (SysDict dict : jsonResponse.getResult().getRecords()) {
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDeptRestApiTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDeptRestApiTest.java
index 85ad470..30625f3 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDeptRestApiTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDeptRestApiTest.java
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictItemRestApiTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictItemRestApiTest.java
index a6a087c..f8aa01a 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictItemRestApiTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictItemRestApiTest.java
@@ -154,7 +154,7 @@ public class SysDictItemRestApiTest {
public static ListResult<SysDictItem> queryTestDictItemList() {
Response response = sysDictItemRestApi.list(DICT_CODE, "", "", "", "", "", 0, 10);
String entity = (String) response.getEntity();
- Type type = new TypeToken<JsonResponse<ListResult<SysDictItem>>>(){}.getType();
+ Type type = new TypeToken<JsonResponse<ListResult<SysDictItem>>>() {}.getType();
JsonResponse<ListResult<SysDictItem>> jsonResponse = gson.fromJson(entity, type);
ListResult<SysDictItem> listResult = jsonResponse.getResult();
@@ -164,7 +164,7 @@ public class SysDictItemRestApiTest {
public static ListResult<SysDict> queryTestDictList() {
Response response = sysDictRestApi.list(DICT_CODE, "", "", "", "", 1, 10);
String entity = (String) response.getEntity();
- Type type = new TypeToken<JsonResponse<ListResult<SysDict>>>(){}.getType();
+ Type type = new TypeToken<JsonResponse<ListResult<SysDict>>>() {}.getType();
JsonResponse<ListResult<SysDict>> jsonResponse = gson.fromJson(entity, type);
ListResult listResult = jsonResponse.getResult();
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictRestApiTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictRestApiTest.java
index 081d7e3..c834e93 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictRestApiTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysDictRestApiTest.java
@@ -120,7 +120,7 @@ public class SysDictRestApiTest {
public static ListResult<SysDict> queryTestDictList() {
Response response = sysDictRestApi.list("-SysDictRestApiTest-", "", "", "", "", 1, 10);
String entity = (String) response.getEntity();
- Type type = new TypeToken<JsonResponse<ListResult<SysDict>>>(){}.getType();
+ Type type = new TypeToken<JsonResponse<ListResult<SysDict>>>() {}.getType();
JsonResponse<ListResult<SysDict>> jsonResponse = gson.fromJson(entity, type);
ListResult<SysDict> listResult = jsonResponse.getResult();
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysUserRestApiTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysUserRestApiTest.java
index 4a8784a..3811eb1 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysUserRestApiTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/rest/SysUserRestApiTest.java
@@ -59,7 +59,7 @@ public class SysUserRestApiTest extends CommonDataTest {
sysUser.setCreateTime(new Date());
sysUser.setUpdateTime(new Date());
- Response response = userRestApi.edit(sysUser);
+ Response response = userRestApi.edit(sysUser);
CommonDataTest.assertUserResponseSuccess(response);
List<SysUser> userList = userService.queryPageList("", null, null, null, null, 0, 10);
diff --git a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/server/JsonResponseTest.java b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/server/JsonResponseTest.java
index d01fe67..3f7160a 100644
--- a/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/server/JsonResponseTest.java
+++ b/submarine-workbench/submarine-server/src/test/java/org/apache/submarine/server/JsonResponseTest.java
@@ -44,7 +44,7 @@ public class JsonResponseTest {
String entity = (String) response.getEntity();
- Type type = new TypeToken<JsonResponse<SysDict>>(){}.getType();
+ Type type = new TypeToken<JsonResponse<SysDict>>() {}.getType();
JsonResponse<SysDict> jsonResponse = gson.fromJson(entity, type);
@@ -71,7 +71,7 @@ public class JsonResponseTest {
String entity = (String) response.getEntity();
- Type type = new TypeToken<JsonResponse<ListResult<SysDict>>>(){}.getType();
+ Type type = new TypeToken<JsonResponse<ListResult<SysDict>>>() {}.getType();
JsonResponse<ListResult<SysDict>> jsonResponse = gson.fromJson(entity, type);