Browse Source

Merge branch 'master' of Elijah/demo-web-request into master

master
richie 5 years ago committed by Gogs
parent
commit
29cb032ec7
  1. 3
      plugin.xml
  2. 6
      src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java
  3. 4
      src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java
  4. 39
      src/main/java/com/fr/plugin/demo/web/request/handler/AdminHttpHandler.java
  5. 40
      src/main/java/com/fr/plugin/demo/web/request/handler/ModuleHttpHandler.java

3
plugin.xml

@ -2,12 +2,13 @@
<id>com.fr.plugin.demo.web.request</id>
<name><![CDATA[web请求示例]]></name>
<active>yes</active>
<version>1.0</version>
<version>2.0</version>
<env-version>10.0</env-version>
<jartime>2018-11-23</jartime>
<vendor>author</vendor>
<description><![CDATA[web请求示例插件。]]></description>
<change-notes><![CDATA[
[2019-11-13]适配新接口 。<br/>
[2018-11-06]完善示例插件。<br/>
[2018-11-05]初始化插件。<br/>
]]></change-notes>

6
src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java

@ -2,6 +2,8 @@ package com.fr.plugin.demo.web.request;
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.plugin.demo.web.request.handler.AdminHttpHandler;
import com.fr.plugin.demo.web.request.handler.ModuleHttpHandler;
import com.fr.plugin.demo.web.request.handler.PrivateHttpHandler;
import com.fr.plugin.demo.web.request.handler.PublicHttpHandler;
@ -11,7 +13,9 @@ public class DemoRequestHandlerBridge extends AbstractHttpHandlerProvider {
return new BaseHttpHandler[]{
new PublicHttpHandler(),
new PrivateHttpHandler()
new PrivateHttpHandler(),
new AdminHttpHandler(),
new ModuleHttpHandler()
};
}
}

4
src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java

@ -9,7 +9,9 @@ public class DemoURLAliasBridge extends AbstractURLAliasProvider {
public URLAlias[] registerAlias() {
return new URLAlias[] {
URLAliasFactory.createPluginAlias("/demo/simple/text", "/demo/text", true),
URLAliasFactory.createPluginAlias("/demo/simple/abc", "/demo/abc", false)
URLAliasFactory.createPluginAlias("/demo/simple/abc", "/demo/abc", false),
URLAliasFactory.createPluginAlias("/demo/simple/admin", "/demo/admin", false),
URLAliasFactory.createPluginAlias("/demo/simple/module", "/demo/module", false)
};
}
}

39
src/main/java/com/fr/plugin/demo/web/request/handler/AdminHttpHandler.java

@ -0,0 +1,39 @@
package com.fr.plugin.demo.web.request.handler;
import com.fanruan.api.web.FlushKit;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author Elijah
* @version 10.0.4
* Created by Elijah on 2019/11/15
*/
public class AdminHttpHandler extends BaseHttpHandler {
@Override
public RequestMethod getMethod() {
return RequestMethod.GET;
}
@Override
public String getPath() {
return "/demo/admin";
}
@Override
public boolean isPublic() {
return false;
}
public boolean needAdmin() {
return true;
}
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
FlushKit.printAsString(httpServletResponse, "这是个只有超管能访问的接口");
}
}

40
src/main/java/com/fr/plugin/demo/web/request/handler/ModuleHttpHandler.java

@ -0,0 +1,40 @@
package com.fr.plugin.demo.web.request.handler;
import com.fanruan.api.decision.AuthorityKit;
import com.fanruan.api.web.FlushKit;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author Elijah
* @version 10.0.4
* Created by Elijah on 2019/11/15
*/
public class ModuleHttpHandler extends BaseHttpHandler {
@Override
public RequestMethod getMethod() {
return RequestMethod.GET;
}
@Override
public String getPath() {
return "/demo/module";
}
@Override
public boolean isPublic() {
return false;
}
public String[] modules() {
return new String[] {AuthorityKit.Management.USER};
}
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception {
FlushKit.printAsString(response, "这是个有用户管理权限的次管才能访问的接口");
}
}
Loading…
Cancel
Save