Browse Source

Merge branch 'master' of http://10.1.235.20:3000/rest/rest-guide

liutong3 6 years ago
parent
commit
c2df84bca8
22 changed files with 520 additions and 395 deletions
  1. 0 28
      ipu-rest-demo/pom.xml
  2. 30 0
      ipu-rest-demo/sql/ipu_db_demo.sql
  3. 6 0
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/IpuRestDemoStart.java
  4. 44 13
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/common/ExceptionController.java
  5. 59 0
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/common/LocalExceptionController.java
  6. 31 15
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/ContextDataController.java
  7. 23 64
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/DataController.java
  8. 60 0
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/DataOtherController.java
  9. 20 8
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/SessionController.java
  10. 0 52
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbController.java
  11. 40 0
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbSqlController.java
  12. 113 74
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbTableController.java
  13. 16 0
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/dubbo/DubboControl.java
  14. 12 1
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/other/MsgFrameController.java
  15. 22 4
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/ui/UiController.java
  16. 40 0
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/BizSqlDao.java
  17. 3 16
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoTableBizDao.java
  18. 0 40
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoBizDao.java
  19. 0 42
      ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoDao.java
  20. 1 1
      ipu-rest-demo/src/main/resources/exception_messages_zh_CN.properties
  21. 0 18
      ipu-rest-demo/src/main/resources/ipu-spring-mvc.xml
  22. 0 19
      ipu-rest-demo/src/main/resources/ipu-spring-mvc2.xml

+ 0 - 28
ipu-rest-demo/pom.xml

@ -37,34 +37,6 @@
37 37
	</properties>
38 38
39 39
	<dependencies>
40
		<dependency>
41
			<groupId>junit</groupId>
42
			<artifactId>junit</artifactId>
43
			<scope>test</scope>
44
		</dependency>
45
		<dependency>
46
			<groupId>javax.servlet</groupId>
47
			<artifactId>javax.servlet-api</artifactId>
48
			<scope>provided</scope>
49
		</dependency>
50
		<!-- 由于重写了spring的部分类,需要置前引入,提高优先级 -->
51
		<dependency>
52
			<groupId>com.ai.ipu.server</groupId>
53
			<artifactId>ipu-restful</artifactId>
54
		</dependency>
55
		<!-- spring监听,admin-client会引入actuator -->
56
		<dependency>  
57
		    <groupId>de.codecentric</groupId>  
58
		    <artifactId>spring-boot-admin-starter-client</artifactId>
59
		</dependency>
60
		<dependency>
61
			<groupId>com.ai.wade</groupId>
62
			<artifactId>wade-data</artifactId>
63
		</dependency>
64
		<dependency>
65
			<groupId>com.ai.ipu</groupId>
66
			<artifactId>ipu-server-web</artifactId>
67
		</dependency>
68 40
		<!-- dubbo相关依赖 -->
69 41
		<dependency>
70 42
			<groupId>com.alibaba</groupId>

+ 30 - 0
ipu-rest-demo/sql/ipu_db_demo.sql

@ -0,0 +1,30 @@
1
/*
2
Navicat MySQL Data Transfer
3

4
Source Server         : ipu测试-121.42.183.206
5
Source Server Version : 50625
6
Source Host           : 121.42.183.206:3307
7
Source Database       : test
8

9
Target Server Type    : MYSQL
10
Target Server Version : 50625
11
File Encoding         : 65001
12

13
Date: 2019-03-03 00:08:09
14
*/
15

16
SET FOREIGN_KEY_CHECKS=0;
17

18
-- ----------------------------
19
-- Table structure for ipu_db_demo
20
-- ----------------------------
21
DROP TABLE IF EXISTS `ipu_db_demo`;
22
CREATE TABLE `ipu_db_demo` (
23
  `pk` int(255) NOT NULL COMMENT '主键',
24
  `string_type` varchar(255) NOT NULL COMMENT '字符串字段',
25
  `int_type` int(255) NOT NULL COMMENT '整型字段',
26
  `decimal_type` decimal(4,2) NOT NULL COMMENT '小数值字段',
27
  `date_type` date NOT NULL COMMENT '日期字段',
28
  `datetime_type` datetime NOT NULL COMMENT '日期时间字段',
29
  PRIMARY KEY (`pk`)
30
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 6 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/IpuRestDemoStart.java

@ -2,6 +2,7 @@ package com.ai.ipu.server.demo;
2 2

3 3
import org.springframework.context.support.ClassPathXmlApplicationContext;
4 4

5
import com.ai.ipu.basic.util.IpuBaseException;
5 6
import com.ai.ipu.restful.boot.IpuRestApplication;
6 7
import com.ai.ipu.restful.spring.SpringManager;
7 8

@ -13,10 +14,15 @@ import com.ai.ipu.restful.spring.SpringManager;
13 14
 */
14 15
public class IpuRestDemoStart {
15 16
    public final static String DUBBO_CONSUMER_CONFIG = "dubbo-consumer-simple.xml";
17
    public final static String EXCEPTION_MESSAGES_CONFIG = "exception_messages";
16 18
    
17 19
    public static void main(String[] args) {
20
        /*在spring中注册dubbo消费者配置*/
18 21
        SpringManager.registerSpringContext(
19 22
                new ClassPathXmlApplicationContext(new String[] { DUBBO_CONSUMER_CONFIG }));
23
        /*注册dubbo异常信息编码配置*/
24
        IpuBaseException.registerCode(EXCEPTION_MESSAGES_CONFIG);
25
        /*启动SpringBoot服务*/
20 26
        IpuRestApplication.start(args);
21 27
    }
22 28
}

+ 44 - 13
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/common/ExceptionController.java

@ -5,38 +5,69 @@ import org.springframework.web.bind.annotation.RequestMapping;
5 5

6 6
import com.ai.ipu.basic.util.IpuUtility;
7 7
import com.ai.ipu.data.JMap;
8
import com.ai.ipu.data.impl.JsonMap;
8 9

10
/**
11
 * @author huangbo@asiainfo.com
12
 * @team IPU
13
 * @date 2019年1月5日下午18:05:42
14
 * @desc 各类异常处理范例
15
 */
9 16
@Controller
10 17
@RequestMapping("/excep")
11 18
public class ExceptionController {
12 19
    
20
    /**
21
     * @author huangbo@asiainfo.com
22
     * @title: defaultException
23
     * @desc: 抛出默认异常的范例
24
     */
25
    @RequestMapping("/default")
26
    public JMap defaultException(JMap data) throws Exception {
27
        if(true){
28
            IpuUtility.error("抛出默认异常");
29
        }
30
        return data;
31
    }
32
    
33
    /**
34
     * @author huangbo@asiainfo.com
35
     * @title: customException
36
     * @desc: 抛出定制异常的范例
37
     */
13 38
    @SuppressWarnings("unused")
14 39
    @RequestMapping("/custom")
15 40
    public JMap customException(JMap data) throws Exception {
41
        JMap result = new JsonMap();
16 42
        if(true){
17 43
            throw new Exception("抛出定制异常");
18 44
        }
19
        return data;
45
        return result;
20 46
    }
21 47
    
22
    @RequestMapping("/default")
23
    public JMap defaultException(JMap data) throws Exception {
48
    /**
49
     * @author huangbo@asiainfo.com
50
     * @title: codeException
51
     * @desc: 抛出异常编码的范例
52
     */
53
    @RequestMapping("/code")
54
    public JMap codeException(JMap data) throws Exception {
24 55
        if(true){
25
            IpuUtility.error("抛出默认异常");
56
            IpuUtility.errorCode("100");
26 57
        }
27 58
        return data;
28 59
    }
29 60
    
30

31 61
    /**
32 62
     * @author huangbo@asiainfo.com
33
     * @title: uiExceptionHandler
34
     * @desc: 局部异常,对应全局异常
63
     * @title: codeMatcherException
64
     * @desc: 抛出有可变参数的异常编码的范例
35 65
     */
36
    /*@ExceptionHandler
37
    public ModelAndView uiExceptionHandler(Exception ex){
38
        ModelAndView mv = new ModelAndView("/custom");
39
        mv.addObject("exception", ex);
40
        return mv;
41
    }*/
66
    @RequestMapping("/matcher")
67
    public JMap codeMatcherException(JMap data) throws Exception {
68
        if(true){
69
            IpuUtility.errorCode("200", "Request");
70
        }
71
        return data;
72
    }
42 73
}

+ 59 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/common/LocalExceptionController.java

@ -0,0 +1,59 @@
1
package com.ai.ipu.server.demo.control.common;
2

3
import org.apache.commons.lang3.exception.ExceptionUtils;
4
import org.springframework.stereotype.Controller;
5
import org.springframework.web.bind.annotation.ExceptionHandler;
6
import org.springframework.web.bind.annotation.RequestMapping;
7
import org.springframework.web.servlet.ModelAndView;
8

9
import com.ai.ipu.basic.string.StringUtil;
10
import com.ai.ipu.basic.util.IpuBaseException;
11
import com.ai.ipu.basic.util.IpuUtility;
12
import com.ai.ipu.data.JMap;
13
import com.ai.ipu.restful.util.IpuRestConstant;
14

15
/**
16
 * @author huangbo@asiainfo.com
17
 * @team IPU
18
 * @date 2019年3月1日上午12:18:00
19
 * @desc 局部异常的处理范例
20
 */
21
@Controller
22
@RequestMapping("/excep")
23
public class LocalExceptionController {
24
    
25
    /**
26
     * @author huangbo@asiainfo.com
27
     * @title: localException
28
     * @desc: 抛出局部异常的范例
29
     */
30
    @RequestMapping("/local")
31
    public JMap localException(JMap data) throws Exception {
32
        if(true){
33
            IpuUtility.error("抛出局部异常");
34
        }
35
        return data;
36
    }
37
    
38
    /**
39
     * @author huangbo@asiainfo.com
40
     * @title: localExceptionHandler
41
     * @desc: 捕获局部异常,对应全局异常
42
     */
43
    @ExceptionHandler
44
    public ModelAndView localExceptionHandler(Exception e){
45
        ModelAndView mv = new ModelAndView("/custom"); //ModelAndView只能对应Jsp吗?
46
        if(IpuBaseException.class.isAssignableFrom(e.getClass())){
47
            String resultCode = ((IpuBaseException)e).getCode();
48
            resultCode = StringUtil.isEmpty(resultCode) ? IpuRestConstant.ResultCode.ERROR_CODE : resultCode;
49
            mv.addObject("error_msg", e.getMessage());
50
            mv.addObject("error_code", resultCode);
51
            mv.addObject("error_trace", ExceptionUtils.getStackTrace(e));
52
            return mv;
53
        }else{
54
            mv.addObject("error_msg", e.getMessage());
55
            mv.addObject("error_trace", ExceptionUtils.getStackTrace(e));
56
            return mv;
57
        }
58
    }
59
}

+ 31 - 15
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/ContextDataController.java

@ -6,25 +6,29 @@ import org.springframework.stereotype.Controller;
6 6
import org.springframework.web.bind.annotation.RequestMapping;
7 7
import org.springframework.web.bind.annotation.ResponseBody;
8 8

9
import com.ai.ipu.data.JMap;
10
import com.ai.ipu.data.impl.JsonMap;
9 11
import com.ai.ipu.restful.frame.context.IpuContextData;
10
import com.ai.ipu.restful.util.IpuRestConstant;
11 12
import com.ai.ipu.restful.web.ServletManager;
12
import com.ailk.common.data.IData;
13
import com.ailk.common.data.impl.DataMap;
14 13

15 14
/**
16 15
 * @author huangbo@asiainfo.com
17 16
 * @team IPU
18 17
 * @date 2018年11月7日下午11:36:42
19
 * @desc 上下文使用范例
18
 * @desc 上下文Context操作范例
20 19
 */
21 20
@Controller
22 21
@RequestMapping("/context")
23 22
public class ContextDataController {
24 23
    
24
    /**
25
     * @author huangbo@asiainfo.com
26
     * @title: createContext
27
     * @desc: 创建上下文Context的范例
28
     */
25 29
    @ResponseBody
26 30
    @RequestMapping("/create")
27
    public IData createContext(IData param) {
31
    public JMap createContext(JMap param) {
28 32
        // TODO Auto-generated method stub
29 33
        IpuContextData ipuContextData = new IpuContextData();
30 34
        Iterator<String> it = param.keySet().iterator();
@ -33,34 +37,46 @@ public class ContextDataController {
33 37
            key = it.next();
34 38
            ipuContextData.put(key, param.get(key).toString());
35 39
        }
36
        ServletManager.getSession().setAttribute(IpuRestConstant.IPU_CONTEXT, ipuContextData.toString());
37
        IData result = new DataMap();
38
        result.put("msg", "上下文创建成功");
40
        ServletManager.storageContextData(ipuContextData);
41
        JMap result = new JsonMap();
42
        result.put("msg", "创建上下文");
39 43
        return result;
40 44
    }
41 45
    
46
    /**
47
     * @author huangbo@asiainfo.com
48
     * @title: updateContext
49
     * @desc: 修改上下文Context的范例
50
     */
42 51
    @ResponseBody
43 52
    @RequestMapping("/update")
44
    public IData updateContext(IData param) {
53
    public JMap updateContext(JMap param) {
45 54
        IpuContextData ipuContextData = ServletManager.getContextData();
46 55
        Iterator<String> it = param.keySet().iterator();
47 56
        String key;
57
        /*请求结束时,上下文如果有修改,则回写到Session中*/
48 58
        while(it.hasNext()){
49 59
            key = it.next();
50 60
            ipuContextData.put(key, param.get(key).toString());
51 61
        }
52 62
        
53
        IData result = new DataMap();
54
        result.put("msg", "上下文修改成功");
63
        JMap result = new JsonMap();
64
        result.put("msg", "修改上下文");
55 65
        return result;
56 66
    }
57 67
    
68
    /**
69
     * @author huangbo@asiainfo.com
70
     * @title: takeContext
71
     * @desc: 获取上下文Context的范例
72
     */
58 73
    @ResponseBody
59
    @RequestMapping("/get")
60
    public IData getContext(IData params) {
74
    @RequestMapping("/take")
75
    public JMap takeContext(JMap params) {
61 76
        IpuContextData ipuContextData = ServletManager.getContextData();
62
        IData result = new DataMap();
63
        result.put("context", ipuContextData.toString());
77
        JMap result = new JsonMap();
78
        result.put("context", ipuContextData == null ? "" : ipuContextData.toString());
79
        result.put("msg", "获取上下文");
64 80
        return result;
65 81
    }
66 82
}

+ 23 - 64
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/DataController.java

@ -1,84 +1,43 @@
1 1
package com.ai.ipu.server.demo.control.data;
2 2

3
import java.util.Map;
4

5 3
import org.springframework.stereotype.Controller;
6
import org.springframework.web.bind.annotation.RequestBody;
7 4
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.RequestParam;
9 5
import org.springframework.web.bind.annotation.ResponseBody;
10 6

11
import com.ai.ipu.basic.util.IpuBaseException;
12 7
import com.ai.ipu.data.JMap;
13 8
import com.ailk.common.data.IData;
14
import com.ailk.common.data.impl.DataMap;
15 9

10
/**
11
 * @author huangbo@asiainfo.com
12
 * @team IPU
13
 * @date 2018年1月30日上午10:11:03
14
 * @desc 数据请求操作范例
15
 */
16 16
@Controller
17
@RequestMapping("/request")
17
@RequestMapping("/data")
18 18
public class DataController {
19 19
	
20
    /**
21
     * @author huangbo@asiainfo.com
22
     * @title: request
23
     * @desc: JMap类型数据请求范例
24
     */
20 25
    @ResponseBody
21
    @RequestMapping("/jget")
22
    public JMap getRequest(JMap params) {
23
        params.put("msg", "测试get请求传参");
24
        return params;
26
    @RequestMapping("/jmap")
27
    public JMap request(JMap param) {
28
        param.put("msg", "JMap请求传参");
29
        return param;
25 30
    }
26 31
    
27
    @ResponseBody
28
    @RequestMapping("/jpost")
29
    public JMap postRequest(JMap params) {
30
        params.put("msg", "测试post请求传参");
31
        return params;
32
    }
33
    
34
	@ResponseBody
35
	@RequestMapping("/get")
36
    public IData getRequest(IData params) {
37
		params.put("msg", "测试get请求传参");
38
        return params;
39
    }
40
	
41
	@ResponseBody
42
	@RequestMapping("/post")
43
    public IData postRequest(IData params) {
44
		params.put("msg", "测试post请求传参");
45
        return params;
46
    }
47
	
48
    @RequestMapping("/error")
49
    public void error() throws Exception {
50
        throw new Exception("使用默认异常抛出全局data异常");
51
    }
52
	
53
    @RequestMapping("/ipuerror")
54
    public void ipuerror() throws Exception {
55
        throw new IpuBaseException("使用IPU异常抛出全局data异常");
56
    }
57
	
58
	@ResponseBody
59
	@RequestMapping("/map")
60
    public Map<String, String> mapRequest(@RequestBody Map<String, String> params) {
61
		params.put("msg", "测试post请求传参");
62
        return params;
63
    }
64
	
65
	@ResponseBody
66
	@RequestMapping("/string")
67
    public String mapRequest(String key) {
68
        return key;
69
    }
70
	
71 32
	/**
72
	 * 通过注解RequestParam获取指定的key的参数
73
	 * @param data
74
	 * @return
33
	 * @author huangbo@asiainfo.com
34
	 * @title: request
35
	 * @desc: IData类型数据请求范例
75 36
	 */
76 37
	@ResponseBody
77
	@RequestMapping(value="/data")
78
    public String stringRequest(@RequestParam(value="data")String data) {
79
		IData params = new DataMap(data);
80
		params.put("msg", "测试get请求传参");
81
		params.put("data", data);
82
        return params.toString();
38
	@RequestMapping("/idata")
39
    public IData request(IData param) {
40
	    param.put("msg", "IData请求传参");
41
        return param;
83 42
    }
84 43
}

+ 60 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/DataOtherController.java

@ -0,0 +1,60 @@
1
package com.ai.ipu.server.demo.control.data;
2

3
import java.util.Map;
4

5
import org.springframework.stereotype.Controller;
6
import org.springframework.web.bind.annotation.RequestBody;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.RequestParam;
9
import org.springframework.web.bind.annotation.ResponseBody;
10

11
import com.ai.ipu.data.JMap;
12
import com.ai.ipu.data.impl.JsonMap;
13

14
/**
15
 * @author huangbo@asiainfo.com
16
 * @team IPU
17
 * @date 2018年1月31日上午10:11:03
18
 * @desc 数据请求操作范例
19
 */
20
@Controller
21
@RequestMapping("/data")
22
public class DataOtherController {
23
    /**
24
     * @author huangbo@asiainfo.com
25
     * @title: mapRequest
26
     * @desc: Map类型数据请求范例
27
     */
28
    @ResponseBody
29
    @RequestMapping("/map")
30
    public Map<String, String> mapRequest(@RequestBody Map<String, String> params) {
31
        params.put("msg", "测试post请求传参");
32
        return params;
33
    }
34
    
35
    /**
36
     * @author huangbo@asiainfo.com
37
     * @title: stringRequest
38
     * @desc: 字符串类型数据请求范例
39
     */
40
    @ResponseBody
41
    @RequestMapping("/string")
42
    public String stringRequest(String key) {
43
        return key;
44
    }
45
    
46
    /**
47
     * @author huangbo@asiainfo.com
48
     * @title: stringDataRequest
49
     * @desc: 指定字段的字符串类型数据请求范例
50
     * 通过注解RequestParam获取指定的key的参数
51
     */
52
    @ResponseBody
53
    @RequestMapping(value="/data")
54
    public String stringDataRequest(@RequestParam(value="data")String data) {
55
        JMap param = new JsonMap(data);
56
        param.put("msg", "测试get请求传参");
57
        param.put("data", data);
58
        return param.toString();
59
    }
60
}

+ 20 - 8
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/SessionController.java

@ -9,23 +9,29 @@ import org.springframework.stereotype.Controller;
9 9
import org.springframework.web.bind.annotation.RequestMapping;
10 10
import org.springframework.web.bind.annotation.ResponseBody;
11 11

12
import com.ai.ipu.data.JMap;
13
import com.ai.ipu.data.impl.JsonMap;
12 14
import com.ai.ipu.restful.web.ServletManager;
13
import com.ailk.common.data.IData;
14
import com.ailk.common.data.impl.DataMap;
15 15

16 16
/**
17 17
 * @author huangbo@asiainfo.com
18 18
 * @team IPU
19 19
 * @date 2018年1月28日下午11:11:46
20
 * @desc Session操作的存取类,默认支持redis
20
 * @desc 会话Session操作范例
21
 * 支持redis
21 22
 */
22 23
@Controller
23 24
@RequestMapping("/session")
24 25
public class SessionController {
25 26
    
27
    /**
28
     * @author huangbo@asiainfo.com
29
     * @title: setSession
30
     * @desc: 设置会话Session的范例
31
     */
26 32
    @ResponseBody
27 33
    @RequestMapping("/set")
28
    public IData setSession(IData param) {
34
    public JMap setSession(JMap param) {
29 35
        // TODO Auto-generated method stub
30 36
        HttpSession session = ServletManager.getSession();
31 37
        Iterator<String> it = param.keySet().iterator();
@ -34,15 +40,21 @@ public class SessionController {
34 40
            key = it.next();
35 41
            session.setAttribute(key, param.get(key));
36 42
        }
37
        IData result = new DataMap();
38
        result.put("msg", "session保存成功");
43
        JMap result = new JsonMap();
44
        result.put("msg", "设置会话Session");
39 45
        return result;
40 46
    }
41 47
    
48
    /**
49
     * @author huangbo@asiainfo.com
50
     * @title: getSession
51
     * @desc: 获得会话Session的范例
52
     */
42 53
    @ResponseBody
43 54
    @RequestMapping("/get")
44
    public IData getSession(IData params) {
45
        IData session = ServletManager.transSession(ServletManager.getRequest().getSession());
55
    public JMap getSession(JMap params) {
56
        JMap session = ServletManager.transSession(ServletManager.getSession());
57
        session.put("msg", "获得会话Session");
46 58
        return session;
47 59
    }
48 60
    

+ 0 - 52
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbController.java

@ -1,52 +0,0 @@
1
package com.ai.ipu.server.demo.control.db;
2

3
import java.util.List;
4
import java.util.Map;
5

6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9

10
import com.ai.ipu.database.dao.IpuDaoManager;
11
import com.ai.ipu.server.demo.dao.DemoBizDao;
12
import com.ai.ipu.server.demo.dao.DemoDao;
13
import com.ailk.common.data.IData;
14
import com.ailk.common.data.impl.DataMap;
15

16
@Controller
17
@RequestMapping("/db")
18
public class DbController {
19

20
    @ResponseBody
21
    @RequestMapping("/insert")
22
    public IData insert(IData params) {
23
        return null;
24
    }
25
    
26
    @ResponseBody
27
    @RequestMapping("/delete")
28
    public IData delete(IData params) {
29
        return null;
30
    }
31
    
32
    @ResponseBody
33
    @RequestMapping("/update")
34
    public IData update(IData params) throws Exception {
35
        DemoDao dao = IpuDaoManager.takeDao(DemoDao.class, "test");
36
        int dbResult = dao.update();
37
        IData result = new DataMap();
38
        result.put("UPDATE_NUM", dbResult);
39
        return result;
40
    }
41
    
42
    @ResponseBody
43
    @RequestMapping("/select")
44
    public IData select(IData params) throws Exception {
45
        DemoBizDao dao = IpuDaoManager.takeDao(DemoBizDao.class, "test");
46
        List<Map<String, Object>> dbResult = dao.select();
47
        IData result = new DataMap();
48
        /*dbResult需要转化成json字符串*/
49
        result.put("IPU_MEMBERS", dbResult);
50
        return result;
51
    }
52
}

+ 40 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbSqlController.java

@ -0,0 +1,40 @@
1
package com.ai.ipu.server.demo.control.db;
2

3
import java.util.List;
4
import java.util.Map;
5

6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9

10
import com.ai.ipu.data.JMap;
11
import com.ai.ipu.data.impl.JsonMap;
12
import com.ai.ipu.database.dao.IpuDaoManager;
13
import com.ai.ipu.server.demo.dao.BizSqlDao;
14

15
/**
16
 * @author huangbo@asiainfo.com
17
 * @team IPU
18
 * @date 2019年3月2日下午8:35:22
19
 * @desc 基于SQL的操作范例
20
 */
21
@Controller
22
@RequestMapping("/db/sql")
23
public class DbSqlController {
24
    private String connName = "test";
25
    
26
    /**
27
     * @author huangbo@asiainfo.com
28
     * @title: executeSql
29
     * @desc: 执行SQL查询的范例
30
     */
31
    @ResponseBody
32
    @RequestMapping("/execute")
33
    public JMap executeSql(JMap param) throws Exception {
34
        BizSqlDao dao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
35
        List<Map<String, Object>> dataResult = dao.executeSql();
36
        JMap result = new JsonMap();
37
        result.put("result", dataResult);
38
        return result;
39
    }
40
}

+ 113 - 74
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbTableController.java

@ -1,6 +1,5 @@
1 1
package com.ai.ipu.server.demo.control.db;
2 2

3
import java.util.HashMap;
4 3
import java.util.List;
5 4
import java.util.Map;
6 5

@ -9,150 +8,190 @@ import org.springframework.web.bind.annotation.RequestMapping;
9 8
import org.springframework.web.bind.annotation.ResponseBody;
10 9

11 10
import com.ai.ipu.common.date.TimeUtil;
11
import com.ai.ipu.data.JMap;
12
import com.ai.ipu.data.impl.JsonMap;
12 13
import com.ai.ipu.database.dao.IpuDaoManager;
13
import com.ai.ipu.server.demo.dao.DemoTableBizDao;
14
import com.ai.ipu.server.demo.dao.BizSqlDao;
15
import com.ai.ipu.server.demo.dao.CommonTableDao;
14 16
import com.ailk.common.data.IData;
15
import com.ailk.common.data.impl.DataMap;
16 17

17 18
/**
18 19
 * @author huangbo@asiainfo.com
19 20
 * @team IPU
20 21
 * @date 2018年9月13日下午4:14:55
21
 * @desc 单表快捷操作范例
22
 * 建表语句
23
 CREATE TABLE `ipu_db_test` (
24
  `pk` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '键主',
25
  `string_type1` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '字符串(可为空)',
26
  `string_type2` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '字符串(不为空)',
27
  `int_type1` int(11) DEFAULT NULL COMMENT '整型(可为空)',
28
  `int_type2` int(11) NOT NULL COMMENT '整型(不为空)',
29
  `date_type1` datetime DEFAULT NULL COMMENT '日期(不为空)',
30
  `date_type2` datetime NOT NULL COMMENT '日期(不为空)',
31
  `decimal_type1` decimal(10,0) DEFAULT NULL COMMENT '小数(可为空)',
32
  `decimal_type2` decimal(10,0) NOT NULL COMMENT '小数(不为空)',
33
  PRIMARY KEY (`pk`)
34
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
22
 * @desc 基于单表CRUD的操作范例
35 23
 */
36 24
@Controller
37 25
@RequestMapping("/db/table")
38 26
public class DbTableController {
39 27
    private String connName = "test";
40 28
    private String druidConnName = "test_druid";
41
    private String tableName = "ipu_db_test";
29
    private String tableName = "ipu_db_demo";
42 30
    
31
    /**
32
     * @author huangbo@asiainfo.com
33
     * @title: select
34
     * @desc: 基于主键查询数据的范例
35
     */
43 36
    @ResponseBody
44 37
    @RequestMapping("/select")
45
    public IData select(IData params) throws Exception {
46
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
47
        Map<String, Object> data = new HashMap<String, Object>();
38
    public JMap select(JMap param) throws Exception {
39
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
40
        JMap data = new JsonMap();
48 41
        data.put("pk", 0);
49
        
50 42
        Map<String, Object> re = dao.select(tableName, data);
51
        IData result = new DataMap();
52
        result.put("result_number", re);
43
        JMap result = new JsonMap();
44
        result.put("result", re);
53 45
        return result;
54 46
    }
55 47
    
48
    /**
49
     * @author huangbo@asiainfo.com
50
     * @title: selectByCond
51
     * @desc: 基于条件查询数据的范例
52
     */
56 53
    @ResponseBody
57 54
    @RequestMapping("/selectby")
58
    public IData selectByCond(IData params) throws Exception {
59
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
60
        Map<String, Object> condition = new HashMap<String, Object>();
61
        condition.put("int_type1", "111111");
62
        
55
    public JMap selectByCond(IData param) throws Exception {
56
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
57
        JMap condition = new JsonMap();
58
        condition.put("int_type", "0");
63 59
        List<Map<String, Object>> re = dao.selectByCond(tableName, condition);
64
        IData result = new DataMap();
65
        result.put("RESULT", re);
60
        JMap result = new JsonMap();
61
        result.put("result", re);
66 62
        return result;
67 63
    }
68 64
    
65
    /**
66
     * @author huangbo@asiainfo.com
67
     * @title: insert
68
     * @desc: 新增数据的范例
69
     */
69 70
    @ResponseBody
70 71
    @RequestMapping("/insert")
71
    public IData insert(IData params) throws Exception {
72
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
73
        Map<String, Object> data = new HashMap<String, Object>();
74
        data.put("pk", 0);
75
        data.put("string_type1", "字符串1");
76
        data.put("string_type2", "字符串2");
77
        data.put("int_type1", "111111");
78
        data.put("int_type2", "222222");
79
        data.put("date_type1", TimeUtil.getSysTime());
80
        data.put("date_type2", TimeUtil.getSysTime());
81
        data.put("decimal_type1", "9.99");
82
        data.put("decimal_type2", "99.9");
72
    public JMap insert(JMap param) throws Exception {
73
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
74
        int pk = bizDao.takePK();
83 75
        
76
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
77
        JMap data = new JsonMap();
78
        data.put("pk", pk);
79
        data.put("string_type", "字符串"+pk);
80
        data.put("int_type", pk);
81
        data.put("decimal_type", "10."+pk);
82
        data.put("date_type", TimeUtil.getSysDate());
83
        data.put("datetime_type", TimeUtil.getSysTime());
84 84
        int re = dao.insert(tableName, data);
85
        IData result = new DataMap();
85
        
86
        JMap result = new JsonMap();
86 87
        result.put("result_number", re);
88
        result.put("content", dao.select(tableName, data));
87 89
        return result;
88 90
    }
89 91
    
92
    /**
93
     * @author huangbo@asiainfo.com
94
     * @title: update
95
     * @desc: 基于主键修改数据的范例
96
     */
90 97
    @ResponseBody
91 98
    @RequestMapping("/update")
92
    public IData update(IData params) throws Exception {
93
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
94
        Map<String, Object> data = new HashMap<String, Object>();
99
    public JMap update(JMap param) throws Exception {
100
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
101
        JMap data = new JsonMap();
95 102
        data.put("pk", 0);
96
        data.put("int_type2", "111111");
97
        
103
        data.put("int_type", System.currentTimeMillis()%100);
98 104
        int re = dao.update(tableName, data);
99
        IData result = new DataMap();
105
        JMap result = new JsonMap();
100 106
        result.put("result_number", re);
107
        result.put("content", dao.select(tableName, data));
101 108
        return result;
102 109
    }
103 110
    
111
    /**
112
     * @author huangbo@asiainfo.com
113
     * @title: updateByCond
114
     * @desc: 基于条件修改数据的范例
115
     */
104 116
    @ResponseBody
105 117
    @RequestMapping("/updateby")
106
    public IData updateByCond(IData params) throws Exception {
107
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
108
        Map<String, Object> data = new HashMap<String, Object>();
109
        data.put("string_type2", "字符串1");
110
        data.put("int_type2", "111111");
111
        Map<String, Object> condition = new HashMap<String, Object>();
112
        condition.put("int_type1", "111111");
118
    public JMap updateByCond(JMap param) throws Exception {
119
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
120
        JMap data = new JsonMap();
121
        data.put("int_type", System.currentTimeMillis()%100);
122
        JMap condition = new JsonMap();
123
        condition.put("string_type", "字符串0");
113 124
        
114 125
        int re = dao.updateByCond(tableName, data, condition);
115
        IData result = new DataMap();
126
        JMap result = new JsonMap();
116 127
        result.put("result_number", re);
128
        condition.put("pk", 0);
129
        result.put("content", dao.select(tableName, condition));
117 130
        return result;
118 131
    }
119 132
    
133
    /**
134
     * @author huangbo@asiainfo.com
135
     * @title: delete
136
     * @desc: 基于主键删除数据的范例
137
     */
120 138
    @ResponseBody
121 139
    @RequestMapping("/delete")
122
    public IData delete(IData params) throws Exception {
123
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
124
        Map<String, Object> data = new HashMap<String, Object>();
125
        data.put("pk", 0);
140
    public JMap delete(JMap params) throws Exception {
141
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
142
        int pk = bizDao.takePK();
143
        
144
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
145
        JMap data = new JsonMap();
146
        data.put("pk", pk-1);
126 147
        
148
        Map<String, Object> content = dao.select(tableName, data);
127 149
        int re = dao.delete(tableName, data);
128
        IData result = new DataMap();
150
        JMap result = new JsonMap();
129 151
        result.put("result_number", re);
152
        result.put("content", content);
130 153
        return result;
131 154
    }
132 155
    
156
    /**
157
     * @author huangbo@asiainfo.com
158
     * @title: deleteByCond
159
     * @desc: 基于条件删除数据的范例
160
     */
133 161
    @ResponseBody
134 162
    @RequestMapping("/deleteby")
135
    public IData deleteByCond(IData params) throws Exception {
136
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
137
        Map<String, Object> data = new HashMap<String, Object>();
138
        data.put("string_type1", "字符串1");
139
        data.put("int_type1", "111111");
163
    public JMap deleteByCond(JMap params) throws Exception {
164
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
165
        int pk = bizDao.takePK();
166
        
167
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
168
        JMap data = new JsonMap();
169
        data.put("string_type", "字符串"+(pk-1));
170

171
        List<Map<String, Object>> contents = dao.selectByCond(tableName, data);
172
        Map<String, Object> content = (contents!=null&&contents.size()>0)?contents.get(0):null;
140 173
        int re = dao.deleteByCond(tableName, data);
141
        IData result = new DataMap();
174
        JMap result = new JsonMap();
142 175
        result.put("result_number", re);
176
        result.put("content", content);
143 177
        return result;
144 178
    }
145 179
    
180
    /**
181
     * @author huangbo@asiainfo.com
182
     * @title: selectByDruid
183
     * @desc: 基于主键查询数据的范例,使用druid连接池
184
     */
146 185
    @ResponseBody
147 186
    @RequestMapping("druid/select")
148
    public IData selectByDruid(IData params) throws Exception {
149
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, druidConnName);
150
        Map<String, Object> data = new HashMap<String, Object>();
187
    public JMap selectByDruid(JMap params) throws Exception {
188
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, druidConnName);
189
        JMap data = new JsonMap();
151 190
        data.put("pk", 0);
152 191
        
153 192
        Map<String, Object> re = dao.select(tableName, data);
154
        IData result = new DataMap();
155
        result.put("result_number", re);
193
        JMap result = new JsonMap();
194
        result.put("result", re);
156 195
        return result;
157 196
    }
158 197
}

+ 16 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/dubbo/DubboControl.java

@ -10,10 +10,21 @@ import com.ai.ipu.restful.spring.SpringManager;
10 10
import com.ai.ipu.service.demo.IBizService;
11 11
import com.ailk.common.data.IData;
12 12

13
/**
14
 * @author huangbo@asiainfo.com
15
 * @team IPU
16
 * @date 2018年10月24日上午00:13:37
17
 * @desc Dubbo客户端的使用范例
18
 */
13 19
@Controller
14 20
@RequestMapping("/dubbo")
15 21
public class DubboControl {
16 22

23
    /**
24
     * @author huangbo@asiainfo.com
25
     * @title: callBizService
26
     * @desc: Dubbo客户端调用服务范例
27
     */
17 28
    @ResponseBody
18 29
    @RequestMapping("/biz")
19 30
    public IData callBizService(IData params) {
@ -23,6 +34,11 @@ public class DubboControl {
23 34
        return result;
24 35
    }
25 36
    
37
    /**
38
     * @author huangbo@asiainfo.com
39
     * @title: callCommonService
40
     * @desc: Dubbo客户端调用通用服务范例
41
     */
26 42
    @ResponseBody
27 43
    @RequestMapping("/common")
28 44
    public IData callCommonService(IData params) {

+ 12 - 1
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/other/MsgFrameController.java

@ -1,4 +1,4 @@
1
package com.ai.ipu.server.demo.control.other;
1
package com.ai.ipu.server.demo.control.mq;
2 2

3 3
import org.springframework.stereotype.Controller;
4 4
import org.springframework.web.bind.annotation.RequestMapping;
@ -11,10 +11,21 @@ import com.ai.ipu.restful.util.IpuRestConstant;
11 11
import com.ailk.common.data.IData;
12 12
import com.ailk.common.data.impl.DataMap;
13 13

14
/**
15
 * @author huangbo@asiainfo.com
16
 * @team IPU
17
 * @date 2018年4月30日下午3:17:49
18
 * @desc MsgFrame的使用范例
19
 */
14 20
@Controller
15 21
@RequestMapping("/msgframe")
16 22
public class MsgFrameController{
17 23

24
    /**
25
     * @author huangbo@asiainfo.com
26
     * @title: produceMessage
27
     * @desc: MsgFrame消息生产者范例
28
     */
18 29
    @ResponseBody
19 30
    @RequestMapping("/produce")
20 31
    public IData produceMessage(IData params){

+ 22 - 4
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/ui/UiController.java

@ -8,18 +8,18 @@ import javax.servlet.http.HttpServletResponse;
8 8
import org.springframework.stereotype.Controller;
9 9
import org.springframework.web.bind.annotation.RequestMapping;
10 10

11

12 11
/**
13
 * @author huangbo
12
 * @author huangbo@asiainfo.com
13
 * @team IPU
14 14
 * @date 2017年11月26日 下午11:50:04
15
 * @desc 
15
 * @desc 常用页面范例
16 16
 */
17 17
@Controller
18 18
@RequestMapping("/ui")
19 19
public class UiController {
20 20

21 21
	@RequestMapping("/login")
22
    public String login() {
22
    public String pageLogin() {
23 23
        return "../login.html";
24 24
    }
25 25
	
@ -31,4 +31,22 @@ public class UiController {
31 31
		buff.append("/index.html");
32 32
		response.sendRedirect(buff.toString());
33 33
	}
34
	
35
	@RequestMapping("/404")
36
    public void page404(HttpServletRequest request, HttpServletResponse response) throws IOException  {
37
        StringBuilder buff = new StringBuilder();
38
        buff.append("../ipuui/");
39
        buff.append("demo");
40
        buff.append("/index.html");
41
        response.sendRedirect(buff.toString());
42
    }
43
	
44
	@RequestMapping("/error")
45
    public void pageError(HttpServletRequest request, HttpServletResponse response) throws IOException  {
46
        StringBuilder buff = new StringBuilder();
47
        buff.append("../ipuui/");
48
        buff.append("demo");
49
        buff.append("/index.html");
50
        response.sendRedirect(buff.toString());
51
    }
34 52
}

+ 40 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/BizSqlDao.java

@ -0,0 +1,40 @@
1
package com.ai.ipu.server.demo.dao;
2

3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6

7
import com.ai.ipu.database.dao.impl.AbstractBizDao;
8

9
/**
10
 * @author huangbo@asiainfo.com
11
 * @team IPU
12
 * @date 2018年1月26日下午5:27:35
13
 * @desc 基于SQL的操作范例
14
 * 业务dao不暴露和业务无关的方法.
15
 */
16
public class BizSqlDao extends AbstractBizDao{
17

18
    public BizSqlDao(String connName) throws IOException {
19
        super(connName);
20
    }
21

22
    public List<Map<String, Object>> executeSql() throws Exception {
23
        String sql = "SELECT * FROM ipu_db_demo";
24
        List<Map<String, Object>> dataResult = getBasicDao().executeSelect(sql);
25
        return dataResult;
26
    }
27
    
28
    public int takePK() throws Exception {
29
        String sql = "SELECT * FROM ipu_db_demo order by datetime_type desc";
30
        Map<String, Object> dataResult = getBasicDao().executeSelectFirst(sql);
31
        int pk;
32
        if(dataResult==null||dataResult.isEmpty()){
33
            pk = 0;
34
        }else{
35
            pk = Integer.parseInt(dataResult.get("pk").toString());
36
            pk++;
37
        }
38
        return pk;
39
    }
40
}

+ 3 - 16
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoTableBizDao.java

@ -10,24 +10,11 @@ import com.ai.ipu.database.dao.impl.AbstractBizDao;
10 10
 * @author huangbo@asiainfo.com
11 11
 * @team IPU
12 12
 * @date 2018年9月6日下午10:05:42
13
 * @desc 单表增删改查测试
14
 * 建表语句
15
 CREATE TABLE `ipu_db_test` (
16
  `pk` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '键主',
17
  `string_type1` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '字符串(可为空)',
18
  `string_type2` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '字符串(不为空)',
19
  `int_type1` int(11) DEFAULT NULL COMMENT '整型(可为空)',
20
  `int_type2` int(11) NOT NULL COMMENT '整型(不为空)',
21
  `date_type1` datetime DEFAULT NULL COMMENT '日期(不为空)',
22
  `date_type2` datetime NOT NULL COMMENT '日期(不为空)',
23
  `decimal_type1` decimal(10,0) DEFAULT NULL COMMENT '小数(可为空)',
24
  `decimal_type2` decimal(10,0) NOT NULL COMMENT '小数(不为空)',
25
  PRIMARY KEY (`pk`)
26
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13
 * @desc 通用基于单表CRUD的操作范例
27 14
 */
28
public class DemoTableBizDao extends AbstractBizDao{
15
public class CommonTableDao extends AbstractBizDao{
29 16

30
    public DemoTableBizDao(String connName) throws IOException {
17
    public CommonTableDao(String connName) throws IOException {
31 18
        super(connName);
32 19
    }
33 20


+ 0 - 40
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoBizDao.java

@ -1,40 +0,0 @@
1
package com.ai.ipu.server.demo.dao;
2

3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6

7
import com.ai.ipu.database.dao.impl.AbstractBizDao;
8

9
/**
10
 * @author huangbo@asiainfo.com
11
 * @team IPU
12
 * @date 2018年1月26日下午5:27:35
13
 * @desc 内置一个BasicDao,让业务dao不暴露和业务无关的方法.
14
 */
15
public class DemoBizDao extends AbstractBizDao{
16

17
    public DemoBizDao(String connName) throws IOException {
18
        super(connName);
19
    }
20

21
    public int insert() {
22
        return -1;
23
    }
24

25
    public int delete() {
26
        return -1;
27
    }
28

29
    public int update() throws Exception {
30
        String sql = "update TAB_IPU_MEMBER set PASSWORD='000002'";
31
        int result = dao.executeUpdate(sql, null);
32
        return result;
33
    }
34

35
    public List<Map<String, Object>> select() throws Exception {
36
        String sql = "SELECT * FROM tab_ipu_member";
37
        List<Map<String, Object>> dbResult = getBasicDao().executeSelect(sql);
38
        return dbResult;
39
    }
40
}

+ 0 - 42
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoDao.java

@ -1,42 +0,0 @@
1
package com.ai.ipu.server.demo.dao;
2

3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6

7
import com.ai.ipu.database.conn.SqlSessionManager;
8
import com.ai.ipu.database.dao.impl.BasicDao;
9
import com.ai.ipu.database.dao.impl.SqlDao;
10

11
/**
12
 * @author huangbo@asiainfo.com
13
 * @team IPU
14
 * @date 2018年1月26日下午5:27:43
15
 * @desc 继承BasicDao,让每个业务dao具备全量方法.
16
 */
17
public class DemoDao extends BasicDao {
18

19
    public DemoDao(String connName) throws IOException {
20
        super(connName);
21
    }
22

23
    public int insert() {
24
        return -1;
25
    }
26

27
    public int delete() {
28
        return -1;
29
    }
30

31
    public int update() throws Exception {
32
        String sql = "update TAB_IPU_MEMBER set PASSWORD='000002'";
33
        int result = executeUpdate(sql, null);
34
        return result;
35
    }
36

37
    public List<Map<String, Object>> select() throws Exception {
38
        String sql = "SELECT * FROM tab_ipu_member";
39
        List<Map<String, Object>> dbResult = executeSelect(sql);
40
        return dbResult;
41
    }
42
}

+ 1 - 1
ipu-rest-demo/src/main/resources/exception_messages_zh_CN.properties

@ -1,2 +1,2 @@
1 1
100=条件参数不能为空
2
200=[%v]不是主键,条件参数需要全部为主键
2
200=[%v]参数异常

+ 0 - 18
ipu-rest-demo/src/main/resources/ipu-spring-mvc.xml

@ -11,22 +11,4 @@
11 11
		http://www.springframework.org/schema/mvc/spring-mvc.xsd">
12 12
	<!-- 自定义的control扫描目录 -->
13 13
    <context:component-scan base-package="com.ai.ipu.server.demo" />
14
    
15
    <!-- 定义文件上传解析器 -->
16
	<!-- <bean id="multipartResolver"
17
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
18
		设定默认编码
19
		<property name="defaultEncoding" value="UTF-8"></property>
20
		设定文件上传的最大值为5MB,5*1024*1024
21
		<property name="maxUploadSize" value="5242880"></property>
22
		设定文件上传时写入内存的最大值,如果小于这个参数不会生成临时文件,默认为10240
23
		<property name="maxInMemorySize" value="40960"></property>
24
		上传文件的临时路径
25
		<property name="uploadTempDir" value="fileUpload/temp"></property>
26
		延迟文件解析
27
		<property name="resolveLazily" value="true" />
28
	</bean> -->
29
    
30
    <!-- 不处理静态资源 -->
31
    <mvc:default-servlet-handler/>
32 14
</beans> 

+ 0 - 19
ipu-rest-demo/src/main/resources/ipu-spring-mvc2.xml

@ -1,19 +0,0 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
5
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
6
           
7
    <!-- 处理器映射器 将bean的name作为url进行查找 -->
8
	<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
9
	<bean name="/name" class="com.ai.ipu.server.demo.control.BeanNameUrlController" />
10
	
11
	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
12
		<property name="mappings">
13
			<props>
14
				<prop key="/url">urlController</prop>
15
			</props>
16
		</property>
17
	</bean>
18
	<bean id="urlController" class="com.ai.ipu.server.demo.control.UrlController" />
19
</beans>