Explorar el Código

rest设计,前端右键菜单

haha600 hace 5 años
padre
commit
8ee18fb202

BIN
1.dmp


+ 9 - 0
facade/src/app/routes/sys/list/list.component.html

@@ -0,0 +1,9 @@
1
+<!-- <ng-template #template>
2
+    <ul nz-menu nzInDropDown >
3
+    <li nz-menu-item >修改</li>
4
+    <li nz-menu-item>增加</li>
5
+    <li nz-menu-item nzDisabled>删除</li>
6
+    </ul>
7
+</ng-template>
8
+
9
+<h2 [SpContextmenu]="template">hahah</h2> -->

+ 6 - 2
facade/src/app/routes/sys/list/list.component.ts

@@ -1,9 +1,9 @@
1 1
 import { SysEditComponent } from './../edit/edit.component';
2
-import { AccesstorService } from './../../../service/accesstor.service';
3 2
 import { ModuleService } from '../../../service/module.service';
4
-import { Component, OnInit, ViewContainerRef, NgModuleRef, Input } from '@angular/core';
3
+import { Component, OnInit, ViewContainerRef, NgModuleRef, Input, TemplateRef } from '@angular/core';
5 4
 import { _HttpClient, ModalHelper } from '@delon/theme';
6 5
 import { ActivatedRoute } from '@angular/router';
6
+import { NzDropdownService, NzDropdownContextComponent } from 'ng-zorro-antd';
7 7
 
8 8
 // import * as CodeMirror from 'codemirror';
9 9
 // import { NzDrawerService, NzDrawerRef } from 'ng-zorro-antd';
@@ -51,11 +51,13 @@ export class SysListComponent implements OnInit {
51 51
   //   }
52 52
   // ];
53 53
 
54
+  dropdownCmp: NzDropdownContextComponent;
54 55
   constructor(private http: _HttpClient,
55 56
     private modal: ModalHelper,
56 57
     private route: ActivatedRoute,
57 58
     private container: ViewContainerRef,
58 59
     private moduleRef: NgModuleRef<any>,
60
+    private dropdownSvr: NzDropdownService,
59 61
     private moduleSvr: ModuleService) {
60 62
 
61 63
    }
@@ -75,8 +77,10 @@ export class SysListComponent implements OnInit {
75 77
 
76 78
 
77 79
 
80
+
78 81
   }
79 82
 
80 83
 
81 84
 
85
+
82 86
 }

+ 3 - 1
facade/src/app/service/module.service.ts

@@ -21,7 +21,7 @@ import { TranslateModule } from '@ngx-translate/core';
21 21
 
22 22
 // #region third libs
23 23
 import { NgZorroAntdModule, NzMessageService, NzNotificationService,
24
-  NzModalService, UploadXHRArgs, NzDrawerService, NzDrawerRef } from 'ng-zorro-antd';
24
+  NzModalService, UploadXHRArgs, NzDrawerService, NzDrawerRef, NzDropdownService } from 'ng-zorro-antd';
25 25
 import { CountdownModule } from 'ngx-countdown';
26 26
 import { DelonModule } from 'app/delon.module';
27 27
 import { SharedModule } from '@shared';
@@ -93,6 +93,7 @@ constructor(private http: _HttpClient,
93 93
       private drawerSvr: NzDrawerService,
94 94
       private aclSvr: ACLService,
95 95
       private settingSvr: SettingsService,
96
+      private dropdownSvr: NzDropdownService,
96 97
     ) {
97 98
       this.injectObj = {
98 99
         accesstor: this.accesstor,
@@ -105,6 +106,7 @@ constructor(private http: _HttpClient,
105 106
         env: environment,
106 107
         aclSvr: this.aclSvr,
107 108
         settingSvr: this.settingSvr,
109
+        dropdownSvr: this.dropdownSvr,
108 110
       };
109 111
     }
110 112
 

+ 2 - 1
facade/src/app/shared/shared.module.ts

@@ -19,6 +19,7 @@ import { CountdownModule } from 'ngx-countdown';
19 19
 import { DrawerWrapperComponent } from './drawer-wrapper/drawer-wrapper.component';
20 20
 import { NgxTreeDnDModule } from '@notadd/ngx-tree-dnd';
21 21
 // import { FullCalendarModule } from '@fullcalendar/angular'; // for FullCalendar!
22
+import { SpContextMenuDirective } from './sp-contextmenu.directive';
22 23
 
23 24
 const THIRDMODULES = [
24 25
   NgZorroAntdModule,
@@ -29,7 +30,7 @@ const THIRDMODULES = [
29 30
 
30 31
 // #region your componets & directives
31 32
 const COMPONENTS = [Codemirror2Component, DrawerWrapperComponent, SpAutocompleteComponent];
32
-const DIRECTIVES = [];
33
+const DIRECTIVES = [SpContextMenuDirective];
33 34
 // #endregion
34 35
 
35 36
 @NgModule({

+ 23 - 0
facade/src/app/shared/sp-contextmenu.directive.ts

@@ -0,0 +1,23 @@
1
+import { Directive, ElementRef, HostListener, Input, TemplateRef } from '@angular/core';
2
+import { NzDrawerService, NzDropDownComponent, NzDropdownService, NzDropdownContextComponent } from 'ng-zorro-antd';
3
+
4
+@Directive({
5
+// tslint:disable-next-line: directive-selector
6
+  selector: '[SpContextmenu]',
7
+})
8
+// tslint:disable-next-line: directive-class-suffix
9
+export class SpContextMenuDirective {
10
+    @Input('SpContextmenu') menu: TemplateRef<void> ;
11
+
12
+    dropdownCmp: NzDropdownContextComponent;
13
+
14
+    constructor(private dropdownSvr: NzDropdownService,
15
+            private el: ElementRef
16
+        ) {}
17
+
18
+    @HostListener('contextmenu') oncontextmenu() {
19
+        this.el.nativeElement['dropdownSvr'] = this.dropdownSvr.create(<MouseEvent> window.event, this.menu);
20
+        return false;
21
+    }
22
+
23
+}

+ 1 - 1
facade/src/environments/environment.prod.ts

@@ -6,7 +6,7 @@ export const environment = {
6 6
   BASE_URL: `../`,
7 7
   client_id: '1',
8 8
   client_secret: '123',
9
-  app_id: '25',
9
+  app_id: '100',
10 10
   provider: '',
11 11
   module: 'k_module',
12 12
   auth_set_header: true,

+ 1 - 2
facade/src/styles.less

@@ -4,9 +4,8 @@
4 4
 @import '~@delon/chart/index';
5 5
 @import '~@delon/theme/styles/layout/default/index';
6 6
 @import '~@delon/theme/styles/layout/fullscreen/index';
7
-
8 7
 @import "../node_modules/angular-calendar/css/angular-calendar.css";
9
-
8
+@import '../node_modules/material-design-icons/iconfont/material-icons.css';
10 9
 @import './styles/index';
11 10
 @import './styles/theme';
12 11
 // endregion

+ 20 - 10
src/main/java/com/kingkong/bljs/api/RestController.java

@@ -2,12 +2,10 @@ package com.kingkong.bljs.api;
2 2
 
3 3
 
4 4
 import com.kingkong.bljs.service.ModelService;
5
+import com.kingkong.bljs.service.RestService;
5 6
 import org.springframework.beans.factory.annotation.Autowired;
6 7
 import org.springframework.stereotype.Controller;
7
-import org.springframework.web.bind.annotation.GetMapping;
8
-import org.springframework.web.bind.annotation.PathVariable;
9
-import org.springframework.web.bind.annotation.RequestMapping;
10
-import org.springframework.web.bind.annotation.ResponseBody;
8
+import org.springframework.web.bind.annotation.*;
11 9
 
12 10
 import java.util.Map;
13 11
 
@@ -19,19 +17,31 @@ public class RestController extends BaseController {
19 17
 
20 18
 
21 19
     @Autowired
22
-    private ModelService modelService;
20
+    private RestService restService;
23 21
 
24 22
     /**
25
-     * 获得用户列表
26
-     * @param model
23
+     * 获取数据
24
+     * @param code
27 25
      * @return
28 26
      */
29
-    @GetMapping("{model}")
30
-    public Map get(@PathVariable String model) throws Exception{
31
-        return modelService.get(model);
27
+    @GetMapping("{code}")
28
+    public Object get(@PathVariable String code, @RequestBody String body) throws Exception{
29
+        return restService.getData(code,body);
32 30
     }
33 31
 
34 32
 
33
+    /**
34
+     * 更新插入操作
35
+     * @param code  操作标志
36
+     * @param body  请求参数
37
+     * @return
38
+     * @throws Exception
39
+     */
40
+    @PostMapping("{code}")
41
+    public Object post(@PathVariable String code,@RequestBody String body) throws Exception{
42
+        return restService.post(code,body);
43
+    }
44
+
35 45
 }
36 46
 
37 47
 

+ 11 - 6
src/main/java/com/kingkong/bljs/controller/TestController.java

@@ -1,5 +1,6 @@
1 1
 package com.kingkong.bljs.controller;
2 2
 
3
+import com.kingkong.bljs.dao.UserApiMapper;
3 4
 import com.kingkong.bljs.service.ModuleService;
4 5
 import com.kingkong.bljs.service.QueryService;
5 6
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,23 +24,27 @@ public class TestController {
23 24
     @Autowired
24 25
     private ModuleService moduleService;
25 26
 
27
+    @Autowired
28
+    private UserApiMapper userApiMapper;
29
+
26 30
 
27 31
     //@TestAop(value = "222")
28 32
    // private String tt;
29 33
 
30 34
 
35
+
31 36
     @GetMapping("test")
32 37
     public Object test() throws Exception{
33 38
 
34 39
         //BCryptPasswordEncoder encoder  = new BCryptPasswordEncoder();
35 40
         //System.out.println(Collections.nCopies(2, ",?"));
36 41
         //return encoder.encode("123456");
37
-        Pattern pattern = Pattern.compile("^zl_([a-zA-Z0-9_\\u4e00-\\u9fa5]+)_insert$",Pattern.CASE_INSENSITIVE);
38
-        Matcher matcher = pattern.matcher("zl_部门表_insert");
39
-        if(matcher.find()){
40
-            System.out.println(matcher.group(1));
41
-        }
42
-        return "";
42
+//        Pattern pattern = Pattern.compile("^zl_([a-zA-Z0-9_\\u4e00-\\u9fa5]+)_insert$",Pattern.CASE_INSENSITIVE);
43
+//        Matcher matcher = pattern.matcher("zl_部门表_insert");
44
+//        if(matcher.find()){
45
+//            System.out.println(matcher.group(1));
46
+//        }
47
+        return userApiMapper.get("1");
43 48
         //return "";
44 49
         //return queryService.getTableColumns("k_module");
45 50
 

+ 16 - 0
src/main/java/com/kingkong/bljs/dao/UserApiMapper.java

@@ -0,0 +1,16 @@
1
+package com.kingkong.bljs.dao;
2
+
3
+import com.kingkong.bljs.entity.UserApi;
4
+import org.apache.ibatis.annotations.Param;
5
+import org.apache.ibatis.annotations.Select;
6
+
7
+public interface UserApiMapper {
8
+
9
+    @Select("select * from k_api where code=#{code}")
10
+    UserApi get(String code);
11
+
12
+
13
+    @Select("select * from k_api where code=#{code} and method=#{method}")
14
+    UserApi findByCodeAndType(@Param("code") String code,@Param("method") int method);
15
+
16
+}

+ 93 - 0
src/main/java/com/kingkong/bljs/entity/UserApi.java

@@ -0,0 +1,93 @@
1
+package com.kingkong.bljs.entity;
2
+
3
+
4
+
5
+public class UserApi {
6
+    private String id;
7
+    private String code;
8
+    private String name;
9
+    private String note;
10
+    private int method;
11
+    private int type;
12
+    private String content;
13
+    private String gId;
14
+
15
+    public UserApi(){
16
+
17
+    }
18
+
19
+    public UserApi(String id, String code, String name, String note, int method, int type, String content, String gId) {
20
+        this.id = id;
21
+        this.code = code;
22
+        this.name = name;
23
+        this.note = note;
24
+        this.method = method;
25
+        this.type = type;
26
+        this.content = content;
27
+        this.gId = gId;
28
+    }
29
+
30
+    public String getId() {
31
+        return id;
32
+    }
33
+
34
+    public void setId(String id) {
35
+        this.id = id;
36
+    }
37
+
38
+    public String getCode() {
39
+        return code;
40
+    }
41
+
42
+    public void setCode(String code) {
43
+        this.code = code;
44
+    }
45
+
46
+    public String getName() {
47
+        return name;
48
+    }
49
+
50
+    public void setName(String name) {
51
+        this.name = name;
52
+    }
53
+
54
+    public String getNote() {
55
+        return note;
56
+    }
57
+
58
+    public void setNote(String note) {
59
+        this.note = note;
60
+    }
61
+
62
+    public int getMethod() {
63
+        return method;
64
+    }
65
+
66
+    public void setMethod(int method) {
67
+        this.method = method;
68
+    }
69
+
70
+    public int getType() {
71
+        return type;
72
+    }
73
+
74
+    public void setType(int type) {
75
+        this.type = type;
76
+    }
77
+
78
+    public String getContent() {
79
+        return content;
80
+    }
81
+
82
+    public void setContent(String content) {
83
+        this.content = content;
84
+    }
85
+
86
+    public String getgId() {
87
+        return gId;
88
+    }
89
+
90
+    public void setgId(String gId) {
91
+        this.gId = gId;
92
+    }
93
+}

+ 2 - 2
src/main/java/com/kingkong/bljs/service/PrivService.java

@@ -63,11 +63,11 @@ public class PrivService {
63 63
                     return true;
64 64
                 }
65 65
             } else if(4 == type){ //存储过程
66
-                if( item.get("name").toString().equals(name)){
66
+                if( item.get("name").toString().toUpperCase().equals(name.toUpperCase())){
67 67
                     return  true;
68 68
                 }
69 69
             } else if (5 == type){//序列
70
-                if( item.get("name").toString().equals(name)){
70
+                if( item.get("name").toString().toUpperCase().equals(name.toUpperCase())){
71 71
                     return  true;
72 72
                 }
73 73
             }

+ 43 - 0
src/main/java/com/kingkong/bljs/service/RestService.java

@@ -0,0 +1,43 @@
1
+package com.kingkong.bljs.service;
2
+
3
+
4
+import com.kingkong.bljs.dao.UserApiMapper;
5
+import com.kingkong.bljs.entity.UserApi;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+
9
+@Service
10
+public class RestService {
11
+
12
+    @Autowired
13
+    private UserApiMapper userApiMapper;
14
+
15
+    /**
16
+     * 资源查询
17
+     * @param code  资源标志
18
+     * @param request   请求参数
19
+     * @return
20
+     */
21
+    public Object getData(String code,String request) throws Exception{
22
+        UserApi api = userApiMapper.findByCodeAndType(code,1);
23
+        if(null == api)
24
+            throw new Exception("未找到操作 " + code);
25
+
26
+
27
+
28
+
29
+        return null;
30
+    }
31
+
32
+
33
+    /**
34
+     * 更新操作
35
+     * @param code 资源标志
36
+     * @param request   请求参数
37
+     * @return
38
+     * @throws Exception
39
+     */
40
+    public Object post(String code,String request) throws Exception{
41
+        return null;
42
+    }
43
+}

+ 1 - 1
src/main/resources/application.properties

@@ -1 +1 @@
1
-spring.profiles.active=c
1
+spring.profiles.active=h