十六、mcg-helper业务系统单表业务模块自动化生成serviceImpl实现类

           本节教程带来serviceImpl实现类生成,我们来看看流程图中所运用到的控件

十六、mcg-helper业务系统单表业务模块自动化生成serviceImpl实现类_第1张图片

            红色方框标记之前教程已讲解过的控件,绿色方框标记本节要讲解的控件,可以看见运用到一个data控件、3个JS脚本控件、一个文本控件,其中绿色方框标记的JS脚本控件,既有多个父级,也有多个子级,直观便捷复用多个控件运行值也是mcg-helper设计的一个亮点,在实际场景中这种需求也不是可少的。下面我们着重讲一下绿色方框标记的JS脚本控件和文本控件,其他控件在之前教程中已经讲过了。

                    1、绿色方框标记的JS脚本控件

                    点击生成,先看看流程中该控件的实际参数

{
	"daoScript":{
		"modelPackageName":"com.mcghelper.model",
		"daoFileName":"McgHelperUserDao.java",
		"daoPackageName":"com.mcghelper.dao",
		"modelClassName":"McgHelperUser",
		"daoClassName":"McgHelperUserDao",
		"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"
		}
	}
}
              从两个父级中,“处理dao的JS脚本控件”和“处理service的JS脚本控件”获取运行值作为参数,再进行数据处理,为生成serviceImpl实现类提供所需的参数,走读一下源代码:

     十六、mcg-helper业务系统单表业务模块自动化生成serviceImpl实现类_第2张图片

               该JS脚本控件在处理数据实现源代码上,没有什么逻辑,基本上都是拼接字符串为主,实际运行值如下:

{
	"implScript":{
		"implClassName":"McgHelperUserServiceImpl",
		"serviceClassName":"McgHelperUserService",
		"modelClassName":"McgHelperUser",
		"daoClassName":"McgHelperUserDao",
		"servicePackageName":"com.mcghelper.service",
		"modelPackageName":"com.mcghelper.dao",
		"implPackageName":"com.mcghelper.service.impl",
		"implFileName":"McgHelperUserServiceImpl.java",
		"importParam":{
			"0":"com.mcghelper.model.McgHelperUser",
			"1":"com.mcghelper.dao.McgHelperUserDao",
			"2":"com.mcghelper.service.McgHelperUserService"
		},
		"daoPackageName":"com.mcghelper.dao",
		"controllerFileName":"McgHelperUserController.java",
		"controllerPackageName":"com.mcghelper.controller",
		"primary":{
			"type":"Integer",
			"classField":"userId"
		}
	}
}
                2、文本控件,结合上面JS控件的运行值,将其转换为serviceImpl的代码,走读一下文本控件的源代码

十六、mcg-helper业务系统单表业务模块自动化生成serviceImpl实现类_第3张图片

                结合JS脚本控件,通过freemaker模板语言把参数值进行替换,这部分也相对较简单,就不啰嗦了,文本控件生成结果如下:

package com.mcghelper.service.impl;
import com.mcghelper.model.McgHelperUser;
import com.mcghelper.dao.McgHelperUserDao;
import com.mcghelper.service.McgHelperUserService;

@Service
public class McgHelperUserServiceImpl implements McgHelperUserService {
    @Autowired
    private McgHelperUserDao mcgHelperUserDao;
    @Override
    public List selectByMcgHelperUser(McgHelperUser record) {
        List result = mcgHelperUserDao.selectByMcgHelperUser(record);
        return result;
    }
    @Override
    public int insertSelective(McgHelperUser record) {
         return mcgHelperUserDao.insertSelective(record);
    }
    @Override
    public int deleteByPrimaryKey(Integer userId) {
        return mcgHelperUserDao.deleteByPrimaryKey(userId);
    }
    @Override
    public int updateByPrimaryKeySelective(McgHelperUser record) {
        return mcgHelperUserDao.updateByPrimaryKeySelective(record);
    }
}

            本节生成serviceImpl实现类教程到此结束。

        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

你可能感兴趣的:(mcg-helper)