Browse Source

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

huangbo 4 years ago
parent
commit
f69854df98

+ 1 - 0
.gitignore

@ -12,3 +12,4 @@
12 12
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
13 13
hs_err_pid*
14 14
15
target/

+ 4 - 7
ipu-rest-scaffold/readme.md

@ -166,10 +166,7 @@ repo.maven.apache.org/151.101.196.215  failed: Connection timed out: connect
166 166
</mirror>
167 167

168 168
###提供内容
169
1)提供父pom,用于工程pom继承并简化。
170
2)引入portal工具包,提供登录、菜单配置管理等能力。
171
3)参考数据库操作服务用于业务定制。
172
4)提供启动脚本,解压即用。
173

174
###集成mybatisplus
175

169
1)portal
170
2)数据库操作服务
171
3)简易的pom
172
4)启动脚本

+ 19 - 0
ipu-rest-scaffold/src/main/java/com/ai/ipu/server/control/DbSqlMgmtController.java

@ -36,4 +36,23 @@ public class DbSqlMgmtController {
36 36
        result.put("result", dataResult);
37 37
        return result;
38 38
    }
39

40
    @ResponseBody
41
    @RequestMapping("/insert")
42
    public JMap insert(JMap input) throws Exception {
43
        JMap param = new JsonMap();
44
        param.put("pk", 99);
45
        param.put("string_type", "字符串123");
46
        param.put("int_type", 999);
47
        param.put("decimal_type", 9.99);
48
        param.put("date_type", "2019-09-09");
49
        param.put("datetime_type", "2019-07-09 15:10:24");
50
        param.put("null_type", "");
51
        
52
        int num = dbSqlMgmtService.insert(param);
53
        
54
        JMap result = new JsonMap();
55
        result.put("result", num);
56
        return result;
57
    }
39 58
}

+ 2 - 0
ipu-rest-scaffold/src/main/java/com/ai/ipu/server/service/DbSqlMgmtService.java

@ -6,4 +6,6 @@ import java.util.Map;
6 6
public interface DbSqlMgmtService {
7 7

8 8
    public List<Map<String, Object>> select(Map<String, Object> param) throws Exception;
9
    
10
    public int insert(Map<String, Object> param) throws Exception;
9 11
}

+ 14 - 0
ipu-rest-scaffold/src/main/java/com/ai/ipu/server/service/impl/DbSqlMgmtServiceImpl.java

@ -5,7 +5,9 @@ import java.util.Map;
5 5

6 6
import org.springframework.stereotype.Service;
7 7

8
import com.ai.ipu.basic.util.IpuUtility;
8 9
import com.ai.ipu.server.service.DbSqlMgmtService;
10
import com.ai.ipu.server.util.RestScaffoldConstant;
9 11
import com.ai.ipu.sql.mgmt.ISqlMgmtDao;
10 12
import com.ai.ipu.sql.mgmt.SqlMgmtDaoFactory;
11 13

@ -26,4 +28,16 @@ public class DbSqlMgmtServiceImpl implements DbSqlMgmtService{
26 28
        List<Map<String, Object>> dataResult = dao.executeSelect("ipu.demo.ipu-db-demo", "select", param);
27 29
        return dataResult;
28 30
    }
31

32
    @Override
33
    public int insert(Map<String, Object> param) throws Exception {
34
        ISqlMgmtDao dao = SqlMgmtDaoFactory.createFileSqlMgmtDao(connName);
35
        int num = 0;
36
        try{
37
            num = dao.executeInsert("ipu.demo.ipu-db-demo", "insert", param);
38
        }catch(Exception e){
39
            IpuUtility.errorCode(RestScaffoldConstant.SCAFFOLD_CODE_003);
40
        }
41
        return num;
42
    }
29 43
}

+ 1 - 1
ipu-rest-scaffold/src/main/resources/banner.txt

@ -1,4 +1,4 @@
1 1
======================
2
ipu-rest-scaffold Server is running
2
IPU Rest Server is running
3 3
${spring-boot.formatted-version}
4 4
======================

+ 19 - 1
ipu-rest-scaffold/src/main/resources/sql/ipu/demo/ipu-db-demo.xml

@ -2,7 +2,25 @@
2 2
<sqls>
3 3
	<sql name="select">
4 4
		<![CDATA[
5
	        SELECT * FROM ipu_db_demo WHERE pk=#{pk}
5
		<select id="select" resultType="java.util.Map">
6
	        SELECT * FROM  ipu_db_demo WHERE pk=#{pk}
7
		</select>
8
		]]>
9
	</sql>
10
	
11
	<sql name="insert">
12
		<![CDATA[
13
		<insert id="insert" resultType="java.util.Map">
14
	        INSERT INTO ipu_db_demo VALUES(
15
	        	#{pk},
16
				#{string_type},
17
				#{int_type},
18
				#{decimal_type},
19
				#{date_type},
20
				#{datetime_type},
21
				#{null_type}
22
	        )
23
		</insert>
6 24
		]]>
7 25
	</sql>
8 26
</sqls>