mcy 5 年之前
父节点
当前提交
62072ea9ab
共有 33 个文件被更改,包括 283 次插入717 次删除
  1. 0 4
      canal-admin/canal-admin-server/pom.xml
  2. 0 25
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/ConfigurationException.java
  3. 0 31
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/ParamValidationException.java
  4. 0 39
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/PermissionDeniedException.java
  5. 0 43
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/ResourceNotFoundException.java
  6. 0 43
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/SystemException.java
  7. 0 30
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/VersionValidationException.java
  8. 0 23
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/config/Config.java
  9. 38 32
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/config/WebConfig.java
  10. 18 2
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/controller/UserController.java
  11. 2 0
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/model/NodeServer.java
  12. 48 4
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/model/User.java
  13. 10 0
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/service/UserService.java
  14. 34 0
      canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/service/impl/UserServiceImpl.java
  15. 二进制
      canal-admin/canal-admin-ui/public/avatar.gif
  16. 8 0
      canal-admin/canal-admin-ui/src/api/user.js
  17. 1 1
      canal-admin/canal-admin-ui/src/components/Breadcrumb/index.vue
  18. 12 9
      canal-admin/canal-admin-ui/src/layout/components/Navbar.vue
  19. 23 113
      canal-admin/canal-admin-ui/src/router/index.js
  20. 4 1
      canal-admin/canal-admin-ui/src/views/dashboard/index.vue
  21. 0 113
      canal-admin/canal-admin-ui/src/views/form/index.vue
  22. 1 1
      canal-admin/canal-admin-ui/src/views/login/index.vue
  23. 0 7
      canal-admin/canal-admin-ui/src/views/nested/menu1/index.vue
  24. 0 7
      canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-1/index.vue
  25. 0 7
      canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-2/index.vue
  26. 0 5
      canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue
  27. 0 5
      canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue
  28. 0 5
      canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-3/index.vue
  29. 0 5
      canal-admin/canal-admin-ui/src/views/nested/menu2/index.vue
  30. 84 0
      canal-admin/canal-admin-ui/src/views/sys/UserInfo.vue
  31. 0 79
      canal-admin/canal-admin-ui/src/views/table/index.vue
  32. 0 78
      canal-admin/canal-admin-ui/src/views/tree/index.vue
  33. 0 5
      canal-admin/pom.xml

+ 0 - 4
canal-admin/canal-admin-server/pom.xml

@@ -29,10 +29,6 @@
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
-        <dependency>
-            <groupId>commons-dbutils</groupId>
-            <artifactId>commons-dbutils</artifactId>
-        </dependency>
         <dependency>
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>

+ 0 - 25
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/ConfigurationException.java

@@ -1,25 +0,0 @@
-/*
- * 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.
- */
-
-package com.alibaba.otter.canal.admin.common.exception;
-
-public class ConfigurationException extends RuntimeException{
-
-    public ConfigurationException(String message) {
-        super(message);
-    }
-}

+ 0 - 31
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/ParamValidationException.java

@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-package com.alibaba.otter.canal.admin.common.exception;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Parameter validation failure exception
- */
-@ResponseStatus(value = HttpStatus.BAD_REQUEST)
-public class ParamValidationException extends SystemException {
-
-    public ParamValidationException(String message) {
-        super(message);
-    }
-}

+ 0 - 39
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/PermissionDeniedException.java

@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-package com.alibaba.otter.canal.admin.common.exception;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Permission denied exception
- */
-@ResponseStatus(value = HttpStatus.UNAUTHORIZED)
-public class PermissionDeniedException extends RuntimeException {
-
-    public PermissionDeniedException(String message) {
-        super(message);
-    }
-
-    public PermissionDeniedException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    protected PermissionDeniedException() {
-        super();
-    }
-}

+ 0 - 43
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/ResourceNotFoundException.java

@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package com.alibaba.otter.canal.admin.common.exception;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Resource not found exception
- */
-@ResponseStatus(value = HttpStatus.NOT_FOUND)
-public class ResourceNotFoundException extends SystemException {
-
-    public ResourceNotFoundException() {
-    }
-
-    public ResourceNotFoundException(String message) {
-        super(message);
-    }
-
-    public ResourceNotFoundException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public ResourceNotFoundException(Throwable cause) {
-        super(cause);
-    }
-
-}

+ 0 - 43
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/SystemException.java

@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package com.alibaba.otter.canal.admin.common.exception;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * System Exception
- */
-@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
-public class SystemException extends RuntimeException {
-
-    public SystemException() {
-        super();
-    }
-
-    public SystemException(String message) {
-        super(message);
-    }
-
-    public SystemException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public SystemException(Throwable cause) {
-        super(cause);
-    }
-}

+ 0 - 30
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/common/exception/VersionValidationException.java

@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-package com.alibaba.otter.canal.admin.common.exception;
-
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-@ResponseStatus(value = HttpStatus.BAD_REQUEST)
-public class VersionValidationException extends SystemException{
-
-    public VersionValidationException(String message) {
-        super(message);
-    }
-}

+ 0 - 23
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/config/Config.java

@@ -1,23 +0,0 @@
-package com.alibaba.otter.canal.admin.config;
-
-import javax.sql.DataSource;
-
-import io.ebean.EbeanServer;
-import org.apache.commons.dbutils.QueryRunner;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class Config {
-
-    @Bean
-    public QueryRunner queryRunner(DataSource dataSource) {
-        return new QueryRunner(dataSource);
-    }
-
-//    @Bean("ebeanServer")
-//    public FactoryBean<EbeanServer> ebeanServer(DataSource dataSource) {
-//        return new EbeanServerFactory(dataSource);
-//    }
-}

+ 38 - 32
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/config/WebConfig.java

@@ -43,37 +43,43 @@ public class WebConfig implements WebMvcConfigurer {
             }
         }).addPathPatterns("/api/**");
 
-//        registry.addInterceptor(new HandlerInterceptor() {
-//
-//            @Override
-//            public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
-//                                     Object o) throws Exception {
-//                String token = httpServletRequest.getHeader("X-Token");
-//                boolean valid = false;
-//                if (token != null) {
-//                    User user = UserController.loginUsers.getIfPresent(token);
-//                    if (user != null) {
-//                        valid = true;
-//                    }
-//                }
-//                if (!valid) {
-//                    BaseModel baseModel = BaseModel.getInstance(null);
-//                    baseModel.setCode(50014);
-//                    baseModel.setMessage("Expired token");
-//                    ObjectMapper mapper = new ObjectMapper();
-//                    String json = mapper.writeValueAsString(baseModel);
-//                    try {
-//                        httpServletResponse.setContentType("application/json;charset=UTF-8");
-//                        PrintWriter out = httpServletResponse.getWriter();
-//                        out.print(json);
-//                    } catch (Exception e) {
-//                        e.printStackTrace();
-//                    }
-//                    return false;
-//                }
-//
-//                return true;
-//            }
-//        }).addPathPatterns("/api/**").excludePathPatterns("/api/**/user/**");
+        registry.addInterceptor(new HandlerInterceptor() {
+
+            @Override
+            public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
+                                     Object o) throws Exception {
+                String token = httpServletRequest.getHeader("X-Token");
+                boolean valid = false;
+                if (token != null) {
+                    User user = UserController.loginUsers.getIfPresent(token);
+                    if (user != null) {
+                        valid = true;
+                        httpServletRequest.setAttribute("user", user);
+                        httpServletRequest.setAttribute("token", token);
+                    }
+                }
+                if (!valid) {
+                    BaseModel baseModel = BaseModel.getInstance(null);
+                    baseModel.setCode(50014);
+                    baseModel.setMessage("Expired token");
+                    ObjectMapper mapper = new ObjectMapper();
+                    String json = mapper.writeValueAsString(baseModel);
+                    try {
+                        httpServletResponse.setContentType("application/json;charset=UTF-8");
+                        PrintWriter out = httpServletResponse.getWriter();
+                        out.print(json);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                    return false;
+                }
+
+                return true;
+            }
+        })
+            .addPathPatterns("/api/**")
+            .excludePathPatterns("/api/**/user/login")
+            .excludePathPatterns("/api/**/user/logout")
+            .excludePathPatterns("/api/**/user/info");
     }
 }

+ 18 - 2
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/controller/UserController.java

@@ -1,12 +1,15 @@
 package com.alibaba.otter.canal.admin.controller;
 
+import com.alibaba.otter.canal.admin.service.UserService;
 import com.github.benmanes.caffeine.cache.Caffeine;
 import com.github.benmanes.caffeine.cache.LoadingCache;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import com.alibaba.otter.canal.admin.model.BaseModel;
 import com.alibaba.otter.canal.admin.model.User;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
@@ -21,12 +24,16 @@ public class UserController {
         .expireAfterAccess(10, TimeUnit.MINUTES)
         .build(key -> null);
 
+    @Autowired
+    UserService                                    userService;
+
     @PostMapping(value = "/login")
     public BaseModel<Map<String, String>> login(@RequestBody User user, @PathVariable String env) {
-        if ("admin".equals(user.getUsername()) && "121212".equals(user.getPassword())) {
+        User loginUser = userService.find4Login(user.getUsername(), user.getPassword());
+        if (loginUser != null) {
             Map<String, String> tokenResp = new HashMap<>();
             String token = UUID.randomUUID().toString();
-            loginUsers.put(token, user);
+            loginUsers.put(token, loginUser);
             tokenResp.put("token", token);
             return BaseModel.getInstance(tokenResp);
         } else {
@@ -50,6 +57,15 @@ public class UserController {
         }
     }
 
+    @PutMapping(value = "")
+    public BaseModel<String> update(@RequestBody User user, @PathVariable String env,
+                                    HttpServletRequest httpServletRequest) {
+        userService.update(user);
+        String token = (String) httpServletRequest.getAttribute("token");
+        loginUsers.put(token, user);
+        return BaseModel.getInstance("success");
+    }
+
     @PostMapping(value = "/logout")
     public BaseModel<String> logout(@PathVariable String env) {
         return BaseModel.getInstance("success");

+ 2 - 0
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/model/NodeServer.java

@@ -4,10 +4,12 @@ import java.util.Date;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import javax.persistence.Table;
 
 import io.ebean.Finder;
 
 @Entity
+@Table(name = "canal_node_server")
 public class NodeServer extends Model {
 
     public static final NodeServerFinder find = new NodeServerFinder();

+ 48 - 4
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/model/User.java

@@ -1,14 +1,42 @@
 package com.alibaba.otter.canal.admin.model;
 
-public class User {
+import io.ebean.Finder;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.util.Date;
+
+@Entity
+@Table(name = "canal_user")
+public class User extends Model{
+
+    public static final UserFinder find = new UserFinder();
+
+    public static class UserFinder extends Finder<Long, User> {
+
+        /**
+         * Construct using the default EbeanServer.
+         */
+        public UserFinder(){
+            super(User.class);
+        }
+
+    }
+
+    @Id
     private Long   id;
     private String username;
     private String password;
-    private String roles  = "admin";
+    private String roles;
     private String introduction;
-    private String avatar = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif";
-    private String name   = "Canal Manager";
+    private String avatar;
+    private String name;
+    private Date   creationDate;
+
+    @Transient
+    private String oldPassword;
 
     public Long getId() {
         return id;
@@ -65,4 +93,20 @@ public class User {
     public void setName(String name) {
         this.name = name;
     }
+
+    public Date getCreationDate() {
+        return creationDate;
+    }
+
+    public void setCreationDate(Date creationDate) {
+        this.creationDate = creationDate;
+    }
+
+    public String getOldPassword() {
+        return oldPassword;
+    }
+
+    public void setOldPassword(String oldPassword) {
+        this.oldPassword = oldPassword;
+    }
 }

+ 10 - 0
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/service/UserService.java

@@ -0,0 +1,10 @@
+package com.alibaba.otter.canal.admin.service;
+
+import com.alibaba.otter.canal.admin.model.User;
+
+public interface UserService {
+
+    User find4Login(String username, String password);
+
+    void update(User user);
+}

+ 34 - 0
canal-admin/canal-admin-server/src/main/java/com/alibaba/otter/canal/admin/service/impl/UserServiceImpl.java

@@ -0,0 +1,34 @@
+package com.alibaba.otter.canal.admin.service.impl;
+
+import com.alibaba.otter.canal.admin.common.exception.ServiceException;
+import com.alibaba.otter.canal.admin.model.User;
+import com.alibaba.otter.canal.admin.service.UserService;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UserServiceImpl implements UserService {
+
+    public User find4Login(String username, String password) {
+        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
+            return null;
+        }
+        User user = User.find.query().where().eq("username", username).eq("password", password).findOne();
+        if (user != null) {
+            user.setPassword("");
+        }
+        return user;
+    }
+
+    public void update(User user) {
+        User userTmp = User.find.byId(1L);
+        if (userTmp == null) {
+            throw new ServiceException();
+        }
+        if (!userTmp.getPassword().equals(user.getOldPassword())) {
+            throw new ServiceException("错误的旧密码");
+        }
+        user.setId(1L);
+        user.update("username", "nn:password");
+    }
+}

二进制
canal-admin/canal-admin-ui/public/avatar.gif


+ 8 - 0
canal-admin/canal-admin-ui/src/api/user.js

@@ -22,3 +22,11 @@ export function logout() {
     method: 'post'
   })
 }
+
+export function updateUser(data) {
+  return request({
+    url: '/user',
+    method: 'put',
+    data
+  })
+}

+ 1 - 1
canal-admin/canal-admin-ui/src/components/Breadcrumb/index.vue

@@ -33,7 +33,7 @@ export default {
       const first = matched[0]
 
       if (!this.isDashboard(first)) {
-        matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched)
+        matched = [{ path: '/dashboard', meta: { title: '主页' }}].concat(matched)
       }
 
       this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)

+ 12 - 9
canal-admin/canal-admin-ui/src/layout/components/Navbar.vue

@@ -7,23 +7,21 @@
     <div class="right-menu">
       <el-dropdown class="avatar-container" trigger="click">
         <div class="avatar-wrapper">
-          <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
+          <!-- avatar+'?imageView2/1/w/80/h/80' -->
+          <img :src="avat+'?imageView2/1/w/80/h/80'" class="user-avatar">
           <i class="el-icon-caret-bottom" />
         </div>
         <el-dropdown-menu slot="dropdown" class="user-dropdown">
           <router-link to="/">
             <el-dropdown-item>
-              Home
+              主页
             </el-dropdown-item>
           </router-link>
-          <a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/">
-            <el-dropdown-item>Github</el-dropdown-item>
-          </a>
-          <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
-            <el-dropdown-item>Docs</el-dropdown-item>
-          </a>
+          <router-link to="/sys/user">
+            <el-dropdown-item>账号管理</el-dropdown-item>
+          </router-link>
           <el-dropdown-item divided>
-            <span style="display:block;" @click="logout">Log Out</span>
+            <span style="display:block;" @click="logout">退出</span>
           </el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
@@ -41,6 +39,11 @@ export default {
     Breadcrumb,
     Hamburger
   },
+  data() {
+    return {
+      avat: './avatar.gif'
+    }
+  },
   computed: {
     ...mapGetters([
       'sidebar',

+ 23 - 113
canal-admin/canal-admin-ui/src/router/index.js

@@ -49,158 +49,68 @@ export const constantRoutes = [
     redirect: '/dashboard',
     children: [{
       path: 'dashboard',
-      name: 'Dashboard',
+      name: '主页',
       component: () => import('@/views/dashboard/index'),
-      meta: { title: 'Dashboard', icon: 'dashboard' }
-    }]
+      meta: { title: '主页', icon: 'dashboard' }
+    }],
+    hidden: true
+  },
+
+  {
+    path: '/sys',
+    component: Layout,
+    redirect: '/user',
+    children: [{
+      path: 'user',
+      name: '用户信息',
+      component: () => import('@/views/sys/UserInfo'),
+      meta: { title: '用户信息' }
+    }],
+    hidden: true
   },
 
   {
     path: '/canalServer',
     component: Layout,
-    redirect: '/canalServer/config',
+    redirect: '/canalServer/nodeServers',
     name: 'Canal Server',
     meta: { title: 'Canal Server', icon: 'example' },
     children: [
       {
         path: 'nodeServers',
         name: '节点状态',
-        component: () => import('@/views/canalServer/nodeServer'),
+        component: () => import('@/views/canalServer/NodeServer'),
         meta: { title: '节点管理', icon: 'tree' }
       },
       {
         path: 'config',
         name: 'Canal主配置',
-        component: () => import('@/views/canalServer/config'),
+        component: () => import('@/views/canalServer/Config'),
         meta: { title: 'Canal主配置', icon: 'form' }
       },
       {
         path: 'canalInstances',
         name: '实例管理',
-        component: () => import('@/views/canalServer/canalInstance'),
+        component: () => import('@/views/canalServer/CanalInstance'),
         meta: { title: '实例管理', icon: 'nested' }
       },
       {
         path: 'canalInstance/add',
         name: '新建实例配置',
-        component: () => import('@/views/canalServer/canalInstanceAdd'),
+        component: () => import('@/views/canalServer/CanalInstanceAdd'),
         meta: { title: '新建实例配置' },
         hidden: true
       },
       {
         path: 'canalInstance/modify',
         name: '修改实例配置',
-        component: () => import('@/views/canalServer/canalInstanceUpdate'),
+        component: () => import('@/views/canalServer/CanalInstanceUpdate'),
         meta: { title: '修改实例配置' },
         hidden: true
       }
     ]
   },
 
-  {
-    path: '/example',
-    component: Layout,
-    redirect: '/example/table',
-    name: 'Example',
-    meta: { title: 'Example', icon: 'example' },
-    children: [
-      {
-        path: 'table',
-        name: 'Table',
-        component: () => import('@/views/table/index'),
-        meta: { title: 'Table', icon: 'table' }
-      },
-      {
-        path: 'tree',
-        name: 'Tree',
-        component: () => import('@/views/tree/index'),
-        meta: { title: 'Tree', icon: 'tree' }
-      }
-    ]
-  },
-
-  {
-    path: '/form',
-    component: Layout,
-    children: [
-      {
-        path: 'index',
-        name: 'Form',
-        component: () => import('@/views/form/index'),
-        meta: { title: 'Form', icon: 'form' }
-      }
-    ]
-  },
-
-  {
-    path: '/nested',
-    component: Layout,
-    redirect: '/nested/menu1',
-    name: 'Nested',
-    meta: {
-      title: 'Nested',
-      icon: 'nested'
-    },
-    children: [
-      {
-        path: 'menu1',
-        component: () => import('@/views/nested/menu1/index'), // Parent router-view
-        name: 'Menu1',
-        meta: { title: 'Menu1' },
-        children: [
-          {
-            path: 'menu1-1',
-            component: () => import('@/views/nested/menu1/menu1-1'),
-            name: 'Menu1-1',
-            meta: { title: 'Menu1-1' }
-          },
-          {
-            path: 'menu1-2',
-            component: () => import('@/views/nested/menu1/menu1-2'),
-            name: 'Menu1-2',
-            meta: { title: 'Menu1-2' },
-            children: [
-              {
-                path: 'menu1-2-1',
-                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
-                name: 'Menu1-2-1',
-                meta: { title: 'Menu1-2-1' }
-              },
-              {
-                path: 'menu1-2-2',
-                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
-                name: 'Menu1-2-2',
-                meta: { title: 'Menu1-2-2' }
-              }
-            ]
-          },
-          {
-            path: 'menu1-3',
-            component: () => import('@/views/nested/menu1/menu1-3'),
-            name: 'Menu1-3',
-            meta: { title: 'Menu1-3' }
-          }
-        ]
-      },
-      {
-        path: 'menu2',
-        component: () => import('@/views/nested/menu2/index'),
-        meta: { title: 'menu2' }
-      }
-    ]
-  },
-
-  {
-    path: 'external-link',
-    component: Layout,
-    children: [
-      {
-        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
-        meta: { title: 'External Link', icon: 'link' }
-      }
-    ]
-  },
-
   // 404 page must be placed at the end !!!
   { path: '*', redirect: '/404', hidden: true }
 ]

+ 4 - 1
canal-admin/canal-admin-ui/src/views/dashboard/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="dashboard-container">
-    <div class="dashboard-text">name: {{ name }}</div>
+    <div class="dashboard-text">&nbsp;</div>
   </div>
 </template>
 
@@ -13,6 +13,9 @@ export default {
     ...mapGetters([
       'name'
     ])
+  },
+  mounted() {
+    this.$router.push('/canalServer')
   }
 }
 </script>

+ 0 - 113
canal-admin/canal-admin-ui/src/views/form/index.vue

@@ -1,113 +0,0 @@
-<template>
-  <div>
-    <el-form ref="form" :model="form">
-      <div style="padding-left: 10px;padding-top: 20px;">
-        <el-form-item>
-          canal.properties&nbsp;&nbsp;&nbsp;&nbsp;
-          <el-button type="primary" @click="onSubmit">修改</el-button>
-          <el-button @click="onCancel">返回</el-button>
-        </el-form-item>
-      </div>
-      <editor v-model="content" lang="yaml" theme="chrome" width="100%" :height="800" @init="editorInit" />
-    </el-form>
-  </div>
-  <!-- <div class="app-container">
-    <el-form ref="form" :model="form" label-width="120px">
-      <el-form-item label="Activity name">
-        <el-input v-model="form.name" />
-      </el-form-item>
-      <el-form-item label="Activity zone">
-        <el-select v-model="form.region" placeholder="please select your zone">
-          <el-option label="Zone one" value="shanghai" />
-          <el-option label="Zone two" value="beijing" />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="Activity time">
-        <el-col :span="11">
-          <el-date-picker v-model="form.date1" type="date" placeholder="Pick a date" style="width: 100%;" />
-        </el-col>
-        <el-col :span="2" class="line">-</el-col>
-        <el-col :span="11">
-          <el-time-picker v-model="form.date2" type="fixed-time" placeholder="Pick a time" style="width: 100%;" />
-        </el-col>
-      </el-form-item>
-      <el-form-item label="Instant delivery">
-        <el-switch v-model="form.delivery" />
-      </el-form-item>
-      <el-form-item label="Activity type">
-        <el-checkbox-group v-model="form.type">
-          <el-checkbox label="Online activities" name="type" />
-          <el-checkbox label="Promotion activities" name="type" />
-          <el-checkbox label="Offline activities" name="type" />
-          <el-checkbox label="Simple brand exposure" name="type" />
-        </el-checkbox-group>
-      </el-form-item>
-      <el-form-item label="Resources">
-        <el-radio-group v-model="form.resource">
-          <el-radio label="Sponsor" />
-          <el-radio label="Venue" />
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item label="Activity form">
-        <el-input v-model="form.desc" type="textarea" />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" @click="onSubmit">Create</el-button>
-        <el-button @click="onCancel">Cancel</el-button>
-      </el-form-item>
-      <el-form-item>
-        <editor v-model="content" lang="properties" theme="chrome" width="500" height="100" @init="editorInit" />
-      </el-form-item>
-    </el-form>
-  </div> -->
-</template>
-
-<script>
-export default {
-  components: {
-    editor: require('vue2-ace-editor')
-  },
-  data() {
-    return {
-      form: {
-        name: '',
-        region: '',
-        date1: '',
-        date2: '',
-        delivery: false,
-        type: [],
-        resource: '',
-        desc: ''
-      }
-    }
-  },
-  methods: {
-    editorInit() {
-      require('brace/ext/language_tools')
-      require('brace/mode/html')
-      require('brace/mode/yaml')
-      require('brace/mode/properties')
-      require('brace/mode/javascript')
-      require('brace/mode/less')
-      require('brace/theme/chrome')
-      require('brace/snippets/javascript')
-    },
-    onSubmit() {
-      this.$message('submit!')
-    },
-    onCancel() {
-      this.$message({
-        message: 'cancel!',
-        type: 'warning'
-      })
-    }
-  }
-}
-</script>
-
-<style scoped>
-.line{
-  text-align: center;
-}
-</style>
-

+ 1 - 1
canal-admin/canal-admin-ui/src/views/login/index.vue

@@ -3,7 +3,7 @@
     <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
 
       <div class="title-container">
-        <h3 class="title">Login Form</h3>
+        <h3 class="title">Canal Admin Login</h3>
       </div>
 
       <el-form-item prop="username">

+ 0 - 7
canal-admin/canal-admin-ui/src/views/nested/menu1/index.vue

@@ -1,7 +0,0 @@
-<template>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 1">
-      <router-view />
-    </el-alert>
-  </div>
-</template>

+ 0 - 7
canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-1/index.vue

@@ -1,7 +0,0 @@
-<template>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 1-1" type="success">
-      <router-view />
-    </el-alert>
-  </div>
-</template>

+ 0 - 7
canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-2/index.vue

@@ -1,7 +0,0 @@
-<template>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 1-2" type="success">
-      <router-view />
-    </el-alert>
-  </div>
-</template>

+ 0 - 5
canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue

@@ -1,5 +0,0 @@
-<template functional>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 1-2-1" type="warning" />
-  </div>
-</template>

+ 0 - 5
canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue

@@ -1,5 +0,0 @@
-<template functional>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 1-2-2" type="warning" />
-  </div>
-</template>

+ 0 - 5
canal-admin/canal-admin-ui/src/views/nested/menu1/menu1-3/index.vue

@@ -1,5 +0,0 @@
-<template functional>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 1-3" type="success" />
-  </div>
-</template>

+ 0 - 5
canal-admin/canal-admin-ui/src/views/nested/menu2/index.vue

@@ -1,5 +0,0 @@
-<template>
-  <div style="padding:30px;">
-    <el-alert :closable="false" title="menu 2" />
-  </div>
-</template>

+ 84 - 0
canal-admin/canal-admin-ui/src/views/sys/UserInfo.vue

@@ -0,0 +1,84 @@
+<template>
+  <div class="app-container" style="width: 600px;">
+    <el-form ref="form" :rules="rules" :model="form" label-width="120px">
+      <el-form-item label="用户名" prop="username">
+        <el-input v-model="form.username" style="width: 200px;" />
+      </el-form-item>
+      <el-form-item label="旧密码" prop="oldPassword">
+        <el-input v-model="form.oldPassword" type="password" style="width: 200px;" />
+      </el-form-item>
+      <el-form-item label="密码" prop="password">
+        <el-input v-model="form.password" placeholder="空为不修改密码" type="password" style="width: 200px;" />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="onSubmit">修改</el-button>
+        <el-button @click="onCancel">取消</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import { getInfo, updateUser } from '@/api/user'
+import { getToken } from '@/utils/auth'
+
+export default {
+  data() {
+    return {
+      form: {
+        username: '',
+        oldPassword: '',
+        password: null
+      },
+      rules: {
+        username: [{ required: true, message: '用户名能为空', trigger: 'change' }],
+        oldPassword: [{ required: true, message: '旧密码不能为空', trigger: 'change' }]
+      }
+    }
+  },
+  created() {
+    this.fetchUserInfo()
+  },
+  methods: {
+    fetchUserInfo() {
+      getInfo(getToken()).then(res => {
+        this.form.username = res.data.username
+      })
+    },
+    onSubmit() {
+      this.$refs['form'].validate((valid) => {
+        if (valid) {
+          updateUser(this.form).then(res => {
+            if (res.data === 'success') {
+              this.form.oldPassword = ''
+              this.form.password = null
+              this.$nextTick(() => {
+                this.$refs['form'].clearValidate()
+              })
+              this.$message({
+                message: '修改用户信息成功',
+                type: 'success'
+              })
+            } else {
+              this.$message({
+                message: '修改用户信息成功',
+                type: 'error'
+              })
+            }
+          })
+        }
+      })
+    },
+    onCancel() {
+      history.go(-1)
+    }
+  }
+}
+</script>
+
+<style scoped>
+.line{
+  text-align: center;
+}
+</style>
+

+ 0 - 79
canal-admin/canal-admin-ui/src/views/table/index.vue

@@ -1,79 +0,0 @@
-<template>
-  <div class="app-container">
-    <el-table
-      v-loading="listLoading"
-      :data="list"
-      element-loading-text="Loading"
-      border
-      fit
-      highlight-current-row
-    >
-      <el-table-column align="center" label="ID" width="95">
-        <template slot-scope="scope">
-          {{ scope.$index }}
-        </template>
-      </el-table-column>
-      <el-table-column label="Title">
-        <template slot-scope="scope">
-          {{ scope.row.title }}
-        </template>
-      </el-table-column>
-      <el-table-column label="Author" width="110" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.author }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="Pageviews" width="110" align="center">
-        <template slot-scope="scope">
-          {{ scope.row.pageviews }}
-        </template>
-      </el-table-column>
-      <el-table-column class-name="status-col" label="Status" width="110" align="center">
-        <template slot-scope="scope">
-          <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column align="center" prop="created_at" label="Display_time" width="200">
-        <template slot-scope="scope">
-          <i class="el-icon-time" />
-          <span>{{ scope.row.display_time }}</span>
-        </template>
-      </el-table-column>
-    </el-table>
-  </div>
-</template>
-
-<script>
-import { getList } from '@/api/table'
-
-export default {
-  filters: {
-    statusFilter(status) {
-      const statusMap = {
-        published: 'success',
-        draft: 'gray',
-        deleted: 'danger'
-      }
-      return statusMap[status]
-    }
-  },
-  data() {
-    return {
-      list: null,
-      listLoading: true
-    }
-  },
-  created() {
-    this.fetchData()
-  },
-  methods: {
-    fetchData() {
-      this.listLoading = true
-      getList().then(response => {
-        this.list = response.data.items
-        this.listLoading = false
-      })
-    }
-  }
-}
-</script>

+ 0 - 78
canal-admin/canal-admin-ui/src/views/tree/index.vue

@@ -1,78 +0,0 @@
-<template>
-  <div class="app-container">
-    <el-input v-model="filterText" placeholder="Filter keyword" style="margin-bottom:30px;" />
-
-    <el-tree
-      ref="tree2"
-      :data="data2"
-      :props="defaultProps"
-      :filter-node-method="filterNode"
-      class="filter-tree"
-      default-expand-all
-    />
-
-  </div>
-</template>
-
-<script>
-export default {
-
-  data() {
-    return {
-      filterText: '',
-      data2: [{
-        id: 1,
-        label: 'Level one 1',
-        children: [{
-          id: 4,
-          label: 'Level two 1-1',
-          children: [{
-            id: 9,
-            label: 'Level three 1-1-1'
-          }, {
-            id: 10,
-            label: 'Level three 1-1-2'
-          }]
-        }]
-      }, {
-        id: 2,
-        label: 'Level one 2',
-        children: [{
-          id: 5,
-          label: 'Level two 2-1'
-        }, {
-          id: 6,
-          label: 'Level two 2-2'
-        }]
-      }, {
-        id: 3,
-        label: 'Level one 3',
-        children: [{
-          id: 7,
-          label: 'Level two 3-1'
-        }, {
-          id: 8,
-          label: 'Level two 3-2'
-        }]
-      }],
-      defaultProps: {
-        children: 'children',
-        label: 'label'
-      }
-    }
-  },
-  watch: {
-    filterText(val) {
-      this.$refs.tree2.filter(val)
-    }
-  },
-
-  methods: {
-    filterNode(value, data) {
-      if (!value) return true
-      return data.label.indexOf(value) !== -1
-    }
-  }
-}
-</script>
-

+ 0 - 5
canal-admin/pom.xml

@@ -38,11 +38,6 @@
                 <artifactId>mysql-connector-java</artifactId>
                 <version>5.1.40</version>
             </dependency>
-            <dependency>
-                <groupId>commons-dbutils</groupId>
-                <artifactId>commons-dbutils</artifactId>
-                <version>1.6</version>
-            </dependency>
             <dependency>
                 <groupId>com.github.ben-manes.caffeine</groupId>
                 <artifactId>caffeine</artifactId>