集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery此处内容已经被作者隐藏,请输入验证码查看内容
验证码:
请关注本站微信公众号,回复“”,获取验证码。在微信里搜索“”或者“”或者微信扫描右侧二维码都可以关注本站微信公众号。

网页地址 http://blog.csdn.net/lpy3654321/article/details/31841573

         项目设想,在项目开发中,我们的开发者大多数时间都在反复开发 相同的keyword,相同的语法. 但就在这种情况下还会常常发生语法的错误,并且每一个开发者的代码风格不同. 其它人员阅读困难.新人的学习成本也会添加.

         这些问题会浪费非常多时间,也会影响到开发者的心情,和程序质量. 由这些问题我想的解决方法是 <代码生成工具> . 代码生成能够解决上述问题,加强约定. 对于普通CRUD的开发效率能够提升50%以上,错误率差点儿为0 , 是项目系统的开发利器.

代码生成 代码生成工具

自己写的开发平台ssmy_m 与代码生成 ,struts2 mybatis spring maven jquery jqgrid jqueryui

有问题请留言,或QQ110146324

最以下有生成出来的代码

SVN上的代码基础功能已经都有了.美工没弄,有须要的自己改吧.

在/ssmy_m/src/main/webapp/common/include_com.jsp里引用.否则代码生成会有影响

DEMO:

 SSMy主页  http://liupengyuan.xicp.cn
 ssmy开发框架SSMy  http://liupengyuan.xicp.cn/ssmy_m/
 ssmy框架的代码生成工具  http://liupengyuan.xicp.cn/generate_m/
 generate_m生成的代码演示样例  http://download.csdn.net/detail/lpy3654321/8438605

  • 开发平台

svn: https://m2.svnspot.com/lpy3654321.ssmy_m/

帐号:guest112233

password:guest112233

也能够到 http://code.svnspot.com 注冊

开发平台页面 :右键新窗体打开图片能够放大

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery

最以下有生成出来的代码集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery




  • 代码生成

svn: https://m2.svnspot.com/lpy3654321.ssmy_generate_m/

帐号:guest112233

password:guest112233

也能够到 http://code.svnspot.com 注冊

通过过数据库表生成BEAN  action servce dao xml js jsp 

改动dbConfigs.xml文件,可配置生成的数据库(启动改动也能够,不须要重新启动)

http://127.0.0.1:8080/generate_m

下载zip后,解压,复制SRC 然后直接粘贴到myeclipse 项目里

<?xml version="1.0" encoding="UTF-8"?>
<!-- 用于生成数据库的配置文件 -->
<dbConfigs>

	<dbConfig id="localMysql"><!-- 配置名称 -->
		<url>jdbc:mysql://localhost:3306/ssmy</url><!-- url -->
		<username>root</username><!-- </username> -->
		<password>root</password><!-- password -->
		<driverClass>com.mysql.jdbc.Driver</driverClass><!-- driverClass -->
	</dbConfig>
	
	<dbConfig id="localOracle">
		<url>jdbc:oracle:thin:@localhost:1521:orcl</url>
		<username>ssmy</username>
		<password>ssmy</password>
		<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
	</dbConfig>
	
	<dbConfig id="dsd_zjk">
		<url>jdbc:oracle:thin:@192.168.3.34:1521:orcl</url>
		<username>dsd_zjk</username>
		<password>dsd_zjk</password>
		<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
	</dbConfig>
	
</dbConfigs>

代码生成页面:右键新窗体打开图片能够放大

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery


“项目基本WEB层命名空间”  和  “模块WEB层命名空间”   这两个input会决定Struts2的命名空间和JS的引用路径

<struts>
	<package name="com.liupengyuan.framework.pageView.action.PageViewAction" extends="struts-default" namespace="/framework/pageView">

		<action name="pageView_*"
				class="pageViewAction"
				method="{1}">
		</action>
		
		<action name="pageView">
			<result>/framework/pageView/pageView.jsp</result>
		</action>

	</package>
</struts>

  • 代码文件夹:

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery


  • Zip包文件夹:

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery


  • HTML JS 代码
pageView.jsp:

<%@ page language="java" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>记录网络訪问量</title>
    <%@ include file="/common/include_com.jsp"%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="${pageContext.request.contextPath}/jsp/moduleWeb/pageView/js/pageView.js"></script>
    <!--<script src="js/pageView.js"></script>-->
	
  </head>
<body>

	<div class="ui-layout-north">
		<div class="navbar"><font size="2" > 当前操作:记录网络訪问量</font></div>
	</div>
	
	<div class="ui-layout-center">
<!--	<div class="title_level1">查询</div> -->
		<div class="formarea">
			<form id="pageViewSearchForm">
			<fieldset>
			<legend style="margin-left: 10px;">查询</legend>

				<table>
					<tr>
						<td style="width:150px;" align="right" ><label for="requestIp">用户IP:</label></td>
						<td>
							<div class="input">
								<input type="text" name="requestIp"  size="40"  />
							</div>
						</td>
						<td style="width:150px;" align="right" ><label for="session">记录会话ID:</label></td>
						<td>
							<div class="input">
								<input type="text" name="session"  size="40"  />
							</div>
						</td>
					</tr>
					<tr>
						<td style="width:150px;" align="right" ><label for="module">訪问的模块:</label></td>
						<td>
							<div class="input">
								<input type="text" name="module"  size="40"  />
							</div>
						</td>
						<td style="width:150px;" align="right" ><label for="visitTime">訪问时间:</label></td>
						<td>
							<div class="input">
								<input type="text" name="visitTime" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" size="40"  />
							</div>
						</td>
					</tr>
					<tr>
						<td style="width:150px;" align="right" ><label for="visitCount">訪问数量:</label></td>
						<td>
							<div class="input">
								<input type="text" name="visitCount"  size="40"  />
							</div>
						</td>
					</tr>
				</table>
			</fieldset>
			</form>
			<div class="buttons">
				<button id="searchB">查询</button>
				<button id="resetB">清空</button>
			</div>
		</div>		
		<div class="toolbar">
			<button id="addB">添加</button>
			<button id="editB">改动</button>
			<button id="deleteB">删除</button>
		</div>
		<table id="pageViewTable"></table>
	</div>
	<div id="pageViewAddOrEditForm">
		<div class="formarea">
			<form id="pageViewForm" type="ajax">

				<input type="hidden" id="id" name="id"/>
				<table>
					<tr>
						<td style="width:70px;" align="right" ><label for="requestIp">用户IP:</label></td>
						<td>
							<div class="input">
								<input type="text" id="requestIp" name="requestIp"  class="validate[maxSize[50] ] "  size="40" />
							</div>
						</td>
					</tr>
					<tr>
						<td style="width:70px;" align="right" ><label for="session">记录会话ID:</label></td>
						<td>
							<div class="input">
								<input type="text" id="session" name="session"  class="validate[maxSize[100] ] "  size="40" />
							</div>
						</td>
					</tr>
					<tr>
						<td style="width:70px;" align="right" ><label for="module">訪问的模块:</label></td>
						<td>
							<div class="input">
								<input type="text" id="module" name="module"  class="validate[maxSize[100] ] "  size="40" />
							</div>
						</td>
					</tr>
					<tr>
						<td style="width:70px;" align="right" ><label for="visitTime">訪问时间:</label></td>
						<td>
							<div class="input">
								<input type="text" id="visitTime" name="visitTime"  class="Wdate " onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" size="40" />
							</div>
						</td>
					</tr>
					<tr>
						<td style="width:70px;" align="right" ><label for="visitCount">訪问数量:</label></td>
						<td>
							<div class="input">
								<input type="text" id="visitCount" name="visitCount"  class="validate[maxSize[10] ] "  size="40" />
							</div>
						</td>
					</tr>
				</table>

			</form>
		</div>
	</div>
</body>
</html>


pageView.js:

$(function() {
	jQuery("#pageViewTable").initGrid({
		url : templateRoot+"/jsp/moduleWeb/pageView/pageView_pagelist.do",
		height:	480,
//colNames:[ "id" ,  "用户IP" ,  "记录会话ID" ,  "訪问的模块" ,  "訪问时间" ,  "訪问数量"  ],	//假设colNames存在 则忽略colModel内的colName.
		colModel : [
{ colName : "id",		name : "id",		hidden : true,	id : true,	key:true,	index : "id",		width : 120,		align:"cente" } ,
{ colName : "用户IP",	name : "requestIp",	hidden : false,	id : false,	key:false,	index : "request_ip",width : 120,		align:"cente" } ,
{ colName : "记录会话ID",name : "session",	hidden : false,	id : false,	key:false,	index : "session",	width : 120,		align:"cente" } ,
{ colName : "訪问的模块",name : "module",	hidden : false,	id : false,	key:false,	index : "module",	width : 120,		align:"cente" } ,
{ colName : "訪问时间",	name : "visitTime",	hidden : false,	id : false,	key:false,	index : "visit_time",	width : 120,	align:"cente" } ,
{ colName : "訪问数量",	name : "visitCount",hidden : false,	id : false,	key:false,	index : "visit_count",	width : 120,	align:"cente" } 
		]
	});
	
	$("#pageViewAddOrEditForm").initDialog({
		width : 580,
		height: 220,
		buttons : { // 为对话框加入按钮
			"保存" : function() {
				pageViewSave();
			},
			"取消" : function() {
				$("#pageViewAddOrEditForm").dialog("close");
			}
		}
	});
	
	$("#addB").click(function() {
		addDialog();
	});
	$("#editB").click(function() {
		updateDialog();
	});
	$("#deleteB").click(function() {
		deleteByids();
	});
	$("#searchB").click(function() {
		search();
	});
	$("#resetB").click(function() {
		$("#pageViewSearchForm").clearForm();
	});

    function addDialog() {
		$("#pageViewForm").clearForm();
		$("#pageViewAddOrEditForm")
			.dialog("option", "title", "加入记录网络訪问量窗体")
			.dialog("open");
	}
	
	function updateDialog() {
		var pageViewGrid = $("#pageViewTable"); 
		if (!pageViewGrid.ifGridSelectedOne()) {
			alert("请选择一条记录!");
			return false;
		}
		$("#pageViewForm").clearForm();
		$("#pageViewAddOrEditForm")
			.dialog("option", "title", "改动记录网络訪问量窗体")
			.dialog("open");
//		var rowData = pageViewGrid.getSelectedRows()[0];
//		$("#pageViewForm").loadValues(rowData);
	 	var ids = pageViewGrid.getSelectedIds();
		$("#pageViewForm").loadForm(templateRoot + "/jsp/moduleWeb/pageView/pageView_load.do",{id : ids[0]});
	}

	function deleteByids() {
		var pageViewGrid = $("#pageViewTable");
		if(!pageViewGrid.ifGridSelected()){
			alert('请选择要删除的记录!');
			return false;
		}
		var ids = pageViewGrid.getSelectedIds();
		if(confirm("确定要删除 "+ ids.length+" 条数据吗?")){
		 	var ids = pageViewGrid.getSelectedIds();
			$.ajax({
				url : templateRoot + "/jsp/moduleWeb/pageView/pageView_delete.do",
				data : {"ids" : ids},
				type : "post",	dataType : "json",	cache : false,	traditional :true,
				success : function(responseText, statusText, xhr, $form) {
					alert(responseText.message || "保存成功!");
			    	if(responseText.success){
						$("#pageViewTable").reloadGrid();
						$("#gridDialog").dialog("close");
			    	}
			    }
			});
		 };
	}

	function pageViewSave() {
		$("#pageViewForm").submitForm({
			url : templateRoot + "/jsp/moduleWeb/pageView/pageView_save.do",
			success:function(responseText, statusText, xhr, $form){
				alert(responseText.message || "保存成功!");
				if(responseText.success){
					$("#pageViewTable").reloadGrid();
					$("#pageViewAddOrEditForm").dialog("close");
				}
			},
			failure:function(data, options){
				alert(responseText.message || "保存失败!");
			}
		});
	}

	function search(){
		var params = $("#pageViewSearchForm").formToObject();
		$("#pageViewTable").searchGrid(params);  
	}

	function searchByParam(params){
	    $("#pageViewTable").searchGrid(params);  
	}
});

  • Java代码

action:PageViewAction.java

package com.liupengyuan.test.modulePage.pageView.action;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.liupengyuan.framework.util.JSONOuter;
import com.liupengyuan.framework.web.query.IGenericPage;
import com.liupengyuan.framework.web.struts2.BaseAction;
import com.liupengyuan.test.modulePage.pageView.model.PageView;
import com.liupengyuan.test.modulePage.pageView.service.PageViewService;

/**
 * @ClassName PageViewAction
 * @Description 记录网络訪问量Action
 * @struts2配置文件名称 struts-test-modulePage-pageView.xml
 * @spring3配置文件名称 spring-test-modulePage-pageView.xml
 * @mybatis3配置文件名称 mybatis-test-modulePage-pageView.xml
 * @表名 sys_page_view
 * @author generate
 * @date - 2015-02-10 15:33:10
 * @version V1.0 
 */
 
@SuppressWarnings("serial")
@Controller("pageViewAction")
@Scope("prototype")
public class PageViewAction extends BaseAction<PageView> {
	@Autowired
	private PageViewService pageViewService;

	private PageView pageView;

	private String[] ids;

	/**
	 * 新增或者改动记录
	 */
	public void save() {
		pageViewService.saveOrUpdate(pageView);
		JSONOuter.writeBeanMsg(getPrintWriter(), pageView,"数据保存成功");
	}

	/**
	 * 载入数据对象
	 */
	public void load() {
		PageView pageViewObj = pageViewService.getById( pageView.getId()  );
		JSONOuter.writeBeanMsg(getPrintWriter(), pageViewObj);
	}

	/**
	 * 分页查询
	 */
	public void pagelist() {
		IGenericPage<PageView> iPage = pageViewService.findPageBy(
				pageView,
				this.getPage(),
				this.getRows(),
				this.getSidx(),
				this.getSord());
		JSONOuter.writePage(getPrintWriter(), iPage);
	}

	/**
	 * 数据列表
	 */
	public void list() {
		List<PageView> list = pageViewService.findListBy(
				pageView, this.getSidx(), this.getSord());
		JSONOuter.writeList(getPrintWriter(), list);
	}

	/**
	 * 批量删除记录
	 */
	public void delete() {
	String msg = "";
		if(ids!=null && ids.length>0){
			int s = pageViewService.deleteByIds(ids);
			msg = "成功删除 " + s + " 条记录!!!";
		}else{
			msg = "删除失败,请选择要删除的记录!!!";
		}
		JSONOuter.writeSuccessMsg(getPrintWriter(), msg);
	}

	/**
	 * 模型驱动。自己主动装配页面属性
	 */
	public PageView getModel() {
		pageView = new PageView();
		return pageView;
	}

	public void setIds(String[] ids) {
		this.ids = ids;
	}
}

service接口:PageViewService.java

package com.liupengyuan.test.modulePage.pageView.service;

import java.util.List;

import com.liupengyuan.test.modulePage.pageView.model.PageView;
import com.liupengyuan.framework.web.query.IGenericPage;

/**
 * @ClassName PageViewService
 * @Description 记录网络訪问量服务接口
 * @struts2 配置文件名称 struts-test-modulePage-pageView.xml
 * @spring3 配置文件名称 spring-test-modulePage-pageView.xml
 * @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
 * @表名 sys_page_view
 * @author generate
 * @date - 2015-02-10 15:33:10
 * @version V1.0 
 */
public interface PageViewService {
	/**
	 * 依据通过主键ID获取一个记录网络訪问量实例
	 * @param id 记录网络訪问量ID
	 * @return 记录网络訪问量实例
	 */
	 
	public PageView getById(java.io.Serializable id);

	/**
	 * 批量删除
	 * @param ids 要删除的记录网络訪问量ID集合
	 * @return 删除成功的记录生活
	 */
	public Integer deleteByIds(java.io.Serializable[] ids);
	public Integer deleteById(java.io.Serializable ids);

	/**
	 * 保持一个新增的记录网络訪问量实例
	 * @param pageView 记录网络訪问量
	 */
	public void save(PageView pageView);

	/**
	 * 保存一个改动的记录网络訪问量实例
	 * @param pageView 记录网络訪问量
	 */
	public void update(PageView pageView);

	/**
	 * 保存一个新增或改动的记录网络訪问量实例
	 * @param pageView 记录网络訪问量
	 */
	public void saveOrUpdate(PageView pageView);

	/**
	 * 分页查询
	 * @param param 查询參数
	 * @param currentPage 当前页码
	 * @param rows 每页记录行数
	 * @param sort 排序字段
	 * @param dir 排序方式、降序(desc)或升序(asc)
	 * @return 记录网络訪问量实例集合
	 */
	public IGenericPage<PageView> findPageBy(
			PageView param,
			int currentPage,
			int rows,
			String sort,
			String dir);

	/**
	 * 主要是配合分页查询返回总记录数
	 * @param param 主要查询參数封装在param中
	 * @return 记录数
	 */
	public Integer getCountByParam(PageView param);

	/**
	 * 不分页查询
	 * @param param 主要查询參数封装在param中
	 * @param sort 排序字段
	 * @param dir 排序方式、降序(desc)或升序(asc)
	 * @return 记录网络訪问量实例集合
	 */
	public List<PageView> findListBy(PageView param, String sort, String dir);

}

service实现类:PageViewServiceImpl.java

package com.liupengyuan.test.modulePage.pageView.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.liupengyuan.framework.web.query.IGenericPage;

import com.liupengyuan.test.modulePage.pageView.dao.PageViewDao;
import com.liupengyuan.test.modulePage.pageView.model.PageView;
import com.liupengyuan.test.modulePage.pageView.service.PageViewService;


/**
 * @ClassName PageViewServiceImpl
 * @Description 记录网络訪问量服务实现类
 * @struts2 配置文件名称 struts-test-modulePage-pageView.xml
 * @spring3 配置文件名称 spring-test-modulePage-pageView.xml
 * @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
 * @表名 sys_page_view
 * @author generate
 * @date - 2015-02-10 15:33:10
 * @version V1.0 
 */
 
@Service("pageViewService")
public class PageViewServiceImpl implements PageViewService {
	@Autowired
	private PageViewDao pageViewDao;

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#getById(java.io.Serializable)
	 */
	public PageView getById(java.io.Serializable id) {
		return pageViewDao.getById(id);
	}

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#deleteByIds(java.io.Serializable[])
	 */
	public Integer deleteByIds(java.io.Serializable[] ids) {
		return pageViewDao.deleteByIds(ids);

	}
	
	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#deleteById(java.io.Serializable)
	 */
	public Integer deleteById(java.io.Serializable id) {
		return pageViewDao.deleteById(id);
	}

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#save(com.liupengyuan.test.modulePage.pageView.model.PageView)
	 */
	public void save(PageView ob) {
		pageViewDao.save(ob);
	}

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#update(com.liupengyuan.test.modulePage.pageView.model.PageView)
	 */
	public void update(PageView ob) {
		pageViewDao.update(ob);
	}

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#saveOrUpdate(com.liupengyuan.test.modulePage.pageView.model.PageView)
	 */
	public void saveOrUpdate(PageView ob) {
		if (ob != null) {
			// 假设ID不为空说明是改动的实例,为更新操作
			if (null != ob.getId() && StringUtils.isNotEmpty(String.valueOf(ob.getId()))) {
				pageViewDao.update(ob);
			} else {
				pageViewDao.save(ob);
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#findPageBy(com.liupengyuan.test.modulePage.pageView.model.PageView, int, int, java.lang.String, java.lang.String)
	 */
	public IGenericPage<PageView> findPageBy(
			PageView param,
			int currentPage,
			int rows,
			String sort,
			String dir) {
		return pageViewDao.findPageBy(
				wrapParams(param), currentPage, rows, sort, dir);
	}

	/*
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#getCountByParam(com.liupengyuan.test.modulePage.pageView.model.PageView)
	 */
	public Integer getCountByParam(PageView param) {
		return pageViewDao.getCountBy(wrapParams(param));
	}

	/**
	 * (non-Javadoc)
	 * @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#findListBy(com.liupengyuan.test.modulePage.pageView.PageView, java.lang.String, java.lang.String)
	 */
	public List<PageView> findListBy(
			PageView param,
			String sort,
			String dir) {
		return pageViewDao.findListBy(
				wrapParams(param), sort, dir);
	}

	/**
	 * 为模糊查询前后加装%%
	 */
	private PageView wrapParams(PageView param) {
		if(param != null){
			if(StringUtils.isNotEmpty(param.getRequestIp())){
				param.setRequestIp("%"+param.getRequestIp()+"%");
			}
			if(StringUtils.isNotEmpty(param.getSession())){
				param.setSession("%"+param.getSession()+"%");
			}
			if(StringUtils.isNotEmpty(param.getModule())){
				param.setModule("%"+param.getModule()+"%");
			}
		}
		return param;
	}
}

DAO接口:
PageViewDao.java

package com.liupengyuan.test.modulePage.pageView.dao;

import com.liupengyuan.framework.dao.IBaseGenericDAO;
import com.liupengyuan.test.modulePage.pageView.model.PageView;

/**
 * @ClassName PageViewDao
 * @Description 记录网络訪问量DAO接口
 * @struts2 配置文件名称 struts-test-modulePage-pageView.xml
 * @spring3 配置文件名称 spring-test-modulePage-pageView.xml
 * @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
 * @表名 sys_page_view
 * @author generate
 * @date - 2015-02-10 15:33:10
 * @version V1.0 
 */
public interface PageViewDao extends IBaseGenericDAO<PageView> {

}

DAO实现类:PageViewDaoImpl.java

package com.liupengyuan.test.modulePage.pageView.dao.impl;

import org.springframework.stereotype.Repository;
import com.liupengyuan.framework.dao.MybatisBaseGenericDAOImpl;
import com.liupengyuan.framework.util.GeneratorKey;
import com.liupengyuan.test.modulePage.pageView.dao.PageViewDao;
import com.liupengyuan.test.modulePage.pageView.model.PageView;


/**
 * @ClassName PageViewDaoImpl
 * @Description 记录网络訪问量DAO实现类 
 * @struts2 配置文件名称 struts-test-modulePage-pageView.xml
 * @spring3 配置文件名称 spring-test-modulePage-pageView.xml
 * @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
 * @表名 sys_page_view
 * @author generate
 * @date - 2015-02-10 15:33:10
 * @version V1.0 
 */
@Repository("pageViewDao")
public class PageViewDaoImpl
extends MybatisBaseGenericDAOImpl<PageView>
implements PageViewDao {
	/**
	 * 生成UUID主键值。
	 * @param ob 记录网络訪问量
	 */
	public void generateId(PageView ob) {
		//id
		if(null == ob.getId() || ob.getId().length() == 0){
			ob.setId(GeneratorKey.genaraId());
		}
	}
}

model:PageView.java

package com.liupengyuan.test.modulePage.pageView.model;

/**
 * @ClassName PageView
 * @Description 记录网络訪问量 实体(领域)对象
 * @struts2 配置文件名称 struts-test-modulePage-pageView.xml
 * @spring3 配置文件名称 spring-test-modulePage-pageView.xml
 * @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
 * @表名 sys_page_view
 * @author generate
 * @date - 2015-02-10 15:33:10
 * @version V1.0 
 */
public class PageView implements java.io.Serializable {

	/** id */
	private java.lang.String id;

	/**
	 * 获取id
	 * @return id
	 */
	public java.lang.String getId() {
		return this.id;
	}
	/**
	 * 设置id
	 */
	public void setId(java.lang.String id){
		this.id = id;
	}
	
	/** 用户IP */
	private java.lang.String requestIp;

	/**
	 * 获取用户IP
	 * @return 用户IP
	 */
	public java.lang.String getRequestIp() {
		return this.requestIp;
	}
	/**
	 * 设置用户IP
	 */
	public void setRequestIp(java.lang.String requestIp){
		this.requestIp = requestIp;
	}
	
	/** 记录会话ID */
	private java.lang.String session;

	/**
	 * 获取记录会话ID
	 * @return 记录会话ID
	 */
	public java.lang.String getSession() {
		return this.session;
	}
	/**
	 * 设置记录会话ID
	 */
	public void setSession(java.lang.String session){
		this.session = session;
	}
	
	/** 訪问的模块 */
	private java.lang.String module;

	/**
	 * 获取訪问的模块
	 * @return 訪问的模块
	 */
	public java.lang.String getModule() {
		return this.module;
	}
	/**
	 * 设置訪问的模块
	 */
	public void setModule(java.lang.String module){
		this.module = module;
	}
	
	/** 訪问时间 */
	private java.util.Date visitTime;

	/**
	 * 获取訪问时间
	 * @return 訪问时间
	 */
	public java.util.Date getVisitTime() {
		return this.visitTime;
	}
	/**
	 * 设置訪问时间
	 */
	public void setVisitTime(java.util.Date visitTime){
		this.visitTime = visitTime;
	}
	
	/** 訪问数量 */
	private java.lang.Integer visitCount;

	/**
	 * 获取訪问数量
	 * @return 訪问数量
	 */
	public java.lang.Integer getVisitCount() {
		return this.visitCount;
	}
	/**
	 * 设置訪问数量
	 */
	public void setVisitCount(java.lang.Integer visitCount){
		this.visitCount = visitCount;
	}
}

  • XML 配置文件

mybatis文件:mybatis-test-modulePage-pageView.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liupengyuan.test.modulePage.pageView.model.PageView">
	<resultMap id="pageViewResultMap" type="com.liupengyuan.test.modulePage.pageView.model.PageView">
		<!-- id -->
		<result column="id" property="id" jdbcType="VARCHAR" />
		<!-- 用户IP -->
		<result column="request_ip" property="requestIp" jdbcType="VARCHAR" />
		<!-- 记录会话ID -->
		<result column="session" property="session" jdbcType="VARCHAR" />
		<!-- 訪问的模块 -->
		<result column="module" property="module" jdbcType="VARCHAR" />
		<!-- 訪问时间 -->
		<result column="visit_time" property="visitTime" jdbcType="TIMESTAMP" />
		<!-- 訪问数量 -->
		<result column="visit_count" property="visitCount" jdbcType="INTEGER" />
	</resultMap>
	<!-- 表名 -->
	<sql id="tableNameSql">
		sys_page_view 
	</sql>

	<!-- 用于select查询、insert的公用抽取的列 -->
	<sql id="commonSelectColumnsPrefix">
        	id ,
        	request_ip ,
        	session ,
        	module ,
        	visit_time ,
        	visit_count 
	</sql>

	<!-- 按主键查找条件语句 -->
	<sql id="conditionOnlyId">
		id = #{id} 
	</sql>
	
	<sql id="mainSql">
		SELECT
			<include refid="commonSelectColumnsPrefix"/>
		FROM
			<include refid="tableNameSql"/> p
	</sql>

	<sql id="varSql">
		<where>
			<if test="requestIp!=null and requestIp!=''">and p.request_ip like #{requestIp} </if>
			<if test="session!=null and session!=''">and p.session like #{session} </if>
			<if test="module!=null and module!=''">and p.module like #{module} </if>
		</where>
	</sql>

	<select id="findPageBy" parameterType="java.util.Map" resultMap="pageViewResultMap">
 		<include refid="mainSql"/>
 		<include refid="varSql"/>
		<if test="SORT != null and SORT != ''">
 			order by ${SORT}
 			<if test="DIR != null and DIR != ''">
 				 ${DIR}
 			</if>
 		</if>
	</select>

	<select id="getById" parameterType="String" resultMap="pageViewResultMap">
		<include refid="mainSql"/>
		where <include refid="conditionOnlyId"/>
	</select>

	<select id="getCountBy" parameterType="java.util.Map" resultType="INTEGER">
		SELECT
			COUNT(*) AS C
		FROM
			<include refid="tableNameSql"/> p
		<include refid="varSql"/>
	</select>

	<select id="findListBy" parameterType="java.util.Map" resultMap="pageViewResultMap">
		<include refid="mainSql"/>
		<include refid="varSql"/>
		<if test="SORT != null and SORT != ''">
 			order by ${SORT}
 			<if test="DIR != null and DIR != ''">
 				 ${DIR}
 			</if>
 		</if>
	</select>

	<insert id="save" parameterType="com.liupengyuan.test.modulePage.pageView.model.PageView">
		insert into
			<include refid="tableNameSql"/>
		(
			<include refid="commonSelectColumnsPrefix"/>
		)
		values
		(
			#{id, jdbcType=VARCHAR} ,
			#{requestIp, jdbcType=VARCHAR} ,
			#{session, jdbcType=VARCHAR} ,
			#{module, jdbcType=VARCHAR} ,
			#{visitTime, jdbcType=TIMESTAMP} ,
			#{visitCount, jdbcType=INTEGER} 
		)
	</insert>
	<update id="update" parameterType="com.liupengyuan.test.modulePage.pageView.model.PageView">
		update
			<include refid="tableNameSql"/>
		set
			request_ip = #{requestIp, jdbcType=VARCHAR} ,
			session = #{session, jdbcType=VARCHAR} ,
			module = #{module, jdbcType=VARCHAR} ,
			visit_time = #{visitTime, jdbcType=TIMESTAMP} ,
			visit_count = #{visitCount, jdbcType=INTEGER} 
		where <include refid="conditionOnlyId"/>
	</update>

	<delete id="deleteByIds" parameterType="Object[]">
		delete from <include refid="tableNameSql"/> 
		where id in <foreach index="index" item="item" collection="array" separator="," open="(" close=")" >#{item}</foreach>
	</delete>

	<delete id="deleteById" parameterType="Object">
		delete from <include refid="tableNameSql"/> where <include refid="conditionOnlyId"/>
	</delete>

</mapper>

spring配置文件:spring-test-modulePage-pageView.xml

<?xml version="1.0" encoding="UTF-8"?

><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:component-scan base-package="com.liupengyuan.test.modulePage.pageView.*" /></beans>

Struts2配置文件:
struts-test-modulePage-pageView.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
	<package name="com.liupengyuan.test.modulePage.pageView.action.PageViewAction" extends="struts-default" namespace="/jsp/moduleWeb/pageView">

		<action name="pageView_*"
				class="pageViewAction"
				method="{1}">
		</action>
		<action name="pageView">
			<result>/jsp/moduleWeb/pageView/pageView.jsp</result>
		</action>

	</package>
</struts>

结束…





版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/117865.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号