本节教程带来如何生成service接口文件,会与上节dao接口生成很像,因为都是接口,几乎都是定义增、删、改、查的基本方法,我们直接来看一下运用到了哪些控件:
红色方框标记之前教程已讲解过的控件,绿色方框标记本节要讲解的控件,其实我们可以察觉到在《业务系统单表模块生成》这个示例中,JS脚本控件和文本控件是用得最多的,一个处理加工数据,一个生成需要的格式代码文件。
1、JS脚本控件
在控件台中截取该JS脚本控件获取到父级的参数如下:
{
"userData":{
"record":[
{
"tableFieldType":"INT",
"include":"java.lang.Integer",
"tableField":"user_id",
"autoincrement":true,
"dataType":"Integer",
"precision":0,
"length":10,
"show":false,
"comment":"自增主键",
"mandatory":true,
"classField":"userId",
"primary":true
},
{
"tableFieldType":"VARCHAR",
"include":"java.lang.String",
"tableField":"user_name",
"autoincrement":false,
"dataType":"String",
"precision":0,
"length":50,
"show":false,
"comment":"用户名称",
"mandatory":false,
"classField":"userName",
"primary":false
},
{
"tableFieldType":"VARCHAR",
"include":"java.lang.String",
"tableField":"user_pwd",
"autoincrement":false,
"dataType":"String",
"precision":0,
"length":255,
"show":false,
"comment":"用户密码",
"mandatory":false,
"classField":"userPwd",
"primary":false
}
],
"property":{
"dataDesc":"用户管理",
"name":"读取用户表信息",
"className":"McgHelperUser",
"packageName":"com.mcghelper.model",
"key":"userData",
"tableName":"mcg_helper_user"
}
}
}
切换到“源代码”选项卡,看看是如何把上面的参数进行处理的
最终运行值如下:
{
"serviceScript":{
"modelPackageName":"com.mcghelper.model", //model类的包名
"serviceFileName":"McgHelperUserService.java", //service的文件名
"serviceClassName":"McgHelperUserService", //service的接口名
"modelClassName":"McgHelperUser", // model类名
"servicePackageName":"com.mcghelper.service", //service接口的包名
"primary":{
"type":"Integer", //表主键对应的程序类型
"classField":"userId" //表主键对应的程序变量名
}
}
}
控制台输出的该文件控件的参数如下:
{
"serviceScript":{
"modelPackageName":"com.mcghelper.model",
"serviceFileName":"McgHelperUserService.java",
"serviceClassName":"McgHelperUserService",
"modelClassName":"McgHelperUser",
"servicePackageName":"com.mcghelper.service",
"primary":{
"type":"Integer",
"classField":"userId"
}
}
}
切换到“源代码”选项卡,看看是如何将上面的参数,通过替换和拼接,生成接口文件所需要的格式和代码
在控制台中最终生成如下结果:
package com.mcghelper.service;
public class McgHelperUserService {
List selectByMcgHelperUser(McgHelperUser record);
int insertSelective(McgHelperUser record);
int deleteByPrimaryKey(Integer userId);
int updateByPrimaryKeySelective(McgHelperUser record);
}
mcg-helper的使用指南:http://blog.csdn.net/loginandpwd/article/details/76944900
mcg-helper研发小助手发布v1.0.0-beta版本:http://blog.csdn.net/loginandpwd/article/details/77447363
mcg-helper研发小助手软件介绍:http://blog.csdn.net/loginandpwd/article/details/77751566
生成model类:http://blog.csdn.net/loginandpwd/article/details/77448277
生成xml映射文件:http://blog.csdn.net/loginandpwd/article/details/77452902
生成dao接口:http://blog.csdn.net/loginandpwd/article/details/77452927
生成service接口:http://blog.csdn.net/loginandpwd/article/details/77452946
生成serviceImpl实现类:http://blog.csdn.net/loginandpwd/article/details/77452979
生成controller控制类:http://blog.csdn.net/loginandpwd/article/details/77452993
生成html页面:http://blog.csdn.net/loginandpwd/article/details/77453013
生成js文件:http://blog.csdn.net/loginandpwd/article/details/77453024