码迷,mamicode.com
首页 > 其他好文 > 详细

石化盈科系统架构代码复用模板之四:修改数据模板

时间:2015-06-20 23:27:22      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:

效果图如下所示:

技术分享

包的结构图如下(面向接口编程):

技术分享

view层代码如下所示:

createInstance.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/easyui/easyui.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>中国石化云管控平台</title>
        <script type=‘text/javascript‘
            src="${pageContext.request.contextPath}/js/commonUtil.js"></script>
        <script type="text/javascript">
        var myForm;            //Form
        var myunitDialog;
        var se1,se2;
        //--DOM加载完毕--
        $(function(){
            myForm=$(#ecs_add_form); 
            initForm();        //加载Form
            if(""!=${ecs.imageid}&&null!=${ecs.imageid}&&${ecs.imageid}.indexOf(.vhd)<0){
                setImageType(2);
                $("#imageType2").attr("checked","checked");
            }else{
                setImageType(1);
                $("#imageType1").attr("checked","checked");
            }
        });
        //function submitForm(){
        function initForm(){
            $("#ecs_add_form").form({  
                url:webContext +/ecs/ecs_createInstance.action,  
                onSubmit: function () {
                    var isValid = $(this).form(validate);
                    if($(#ecs_add_form #imageid).val()==""){
                        alert("请选择镜像!");
                        return false;
                    }
                    return isValid;  
                },
                success: function (data) {
                    data = jQuery.parseJSON(data);
                    $.messager.progress(close);
                    if(data.success){
                        Alert(提示,保存成功!);
                        $(#ecs_window).dialog("close");
                        dataGridTable.datagrid("reload");
                    }else{
                        Alert(‘提示‘,‘保存失败:<br>‘+data.msg);  
                    }
                }            
            });
        }
        var count =0;
        function addDatadisk(){
            if($("div[id^=‘datas_‘]").size()>=4){
                alert("只能增加4块数据盘!");
                return ;
            }
            count++;
            var div=‘<div id="datas_‘+count+‘" >云磁盘:<input type="text"  name="datas" class="easyui-numberbox" data-options="min:5,max:2000,precision:0"  style="width: 80px"> GB <a href="#" class="easyui-linkbutton" onclick="deleteData(\‘datas_‘+count+‘\‘)" data-options=\‘plain:true,iconCls:"icon-cancel"\‘>删除</a></div>‘;
            $("#datas").append(div);
            $.parser.parse($(‘#datas‘)); //重新渲染页面控件
        }
        function deleteData(id){
            count--;
            $("#"+id).remove();
        }
        function setPas(value){
            if(value==2){
                $("#setPTr").hide();
                $("#resetPTr").hide();
                $(‘#password‘).val("");
                $(‘#repassword‘).val("");
                $(‘#password‘).validatebox({ required: false });
                $(‘#repassword‘).validatebox({ required: false });
            }else{
                $("#setPTr").show();
                $("#resetPTr").show();
                $(‘#password‘).validatebox({ required: true });
                $(‘#repassword‘).validatebox({ required: true });
            }
        }
        function setImageType(value){
            if(value==2){
                $("#checkImage2").show();
                $("#checkImage1").hide();
                $(‘#imageidcombobox‘).combobox({ required: false });
            }else{
                $("#checkImage1").show();
                $("#checkImage2").hide();
                $(‘#imageidcombobox‘).combobox({ required: true });
            }
        }
        if(‘${ecs.id}‘!=‘‘&&(‘${ecs.password}‘==null||‘${ecs.password}‘==‘‘)){
            $("#setPTr").hide();
            $("#resetPTr").hide();
            $(‘#password‘).validatebox({ required: false });
            $(‘#repassword‘).validatebox({ required: false });
        }
        
         
    //选择单个用户
     function chooseOneCreator(){
                 $(‘#creatorFrame‘)[0].src=webContext+‘/result/system/role/userSearchOneAdd.jsp‘;
                 $(‘#sinopec_window_creator‘).dialog("open");
             }
     $.extend($.fn.validatebox.defaults.rules, {
            /*必须和某个字段相等*/
            equalTo: { validator: function (value, param) { return $(param[0]).val() == value; }, message: ‘两次输入密码不匹配‘ },
             englishOrNum : {
                validator : function(value) {
                    return /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,30}$/.test(value);
                },
                message : ‘密码必须为8-30个字符,同时包含大小写字母和数字,不支持特殊符号‘
            }

        });
    //清空
     function resetOneCreator(){
                 $(‘#responsible_id‘).val("");
                 $(‘#responsible_name‘).val("");
             }
    function checkImage(){
        var url=webContext +‘/result/pcitcAliyun/ecs/imageList.jsp‘;
        $("#ecs_add_form").after("<div id=‘checkImage‘ style=‘padding:10px;width:470px;top: 100px;left: 400px‘></div>");
        $("#checkImage").dialog({
            href: encodeURI(url),
            title: "选择镜像",
            modal: false,
//                minimizable:true,
            collapsible: true,
            height: document.body.clientHeight * 0.8,
            width: document.body.clientWidth * 0.8,
            top: 50,
            left: 200,
            cache: false,
            resizable: false,
            onClose: function () {
                $("#checkImage").dialog("destroy");
            },
            buttons: [
                {
                    text:‘确定‘,
                    iconCls:‘icon-save‘,
                    handler:function(){
                        var selected=$(‘#imageList_list‘).datagrid(‘getSelections‘);
                        if(selected.length==0){
                            Alert(‘你没有选择任何镜像!‘);
                            return false;
                        }else{
                            $(‘#ecs_add_form #imageid‘).val(selected[0].imageid);
                            $(‘#ecs_add_form #imagename‘).val(selected[0].imagename);
                            $(‘#ecs_add_form #imagedescription‘).html(selected[0].imagename);
                            $("#checkImage").dialog(‘close‘);
                        }
                        
                    }
                },
                {
                    text: ‘取消‘,
                    iconCls: ‘icon-cancel‘,
                    handler: function () {
                        $("#checkImage").dialog(‘close‘);
                    }
                }
            ]
        });
    }
    </script>
    </head>
    <body>
    <div style="height: 100%;overflow: auto;margin: 0px;padding: 0px;">
        <form id="ecs_add_form" class="easyui-form" method="post">
        <input type="hidden" name="ecs.id" id="id" value="${ecs.id}"  />
        <input type="hidden" name="ecs.instanceid" id="instanceid" value="${ecs.instanceid}"  />
        <input type="hidden" name="ecs.systemdiskcategory" id="systemdiskcategory" value="cloud"/>
        <input type="hidden" name="ecs.regionname" id="regionname" value="${ecs.regionname}"  />
        <input type="hidden" name="ecs.zonename" id="zonename" value="${ecs.zonename}" />
        <input type="hidden" name="ecs.instancetypename" id="instancetypename"  value="${ecs.instancetypename}"/>
        <input type="hidden" name="ecs.imageid" id="imageid"  value="${ecs.imageid}"/>
        <input type="hidden" name="ecs.imagename" id="imagename"  value="${ecs.imagename}"/>
                <span style="color:blue; ">基本信息:</span><hr/>
                <table class=‘sinopec_search_panel‘ border="0" width="100%" style="padding: 10px">
                <tr>
                <td width="100px" align="right" ><nobr>系统名称:</nobr></td>
                <td width="300px">
                   <input class="easyui-textbox"  style="width: 200px" type="text" name="ecs.systemname" data-options="required:true" value="${ecs.systemname}"></input>
                </td>
                </tr>
                <tr>
                <td align="right" > <label class="control-label">地域:</label></td>  
                                <td>
                                    <input id="regionid" name="ecs.regionid" class="easyui-combobox" style="width: 200px"
                                       value="${ecs.regionid}" required="required"
                                       data-options="
                                        valueField: ‘code_value‘,   
                                        textField: ‘code_name‘,  
                                        editable:false, 
                                        url:webContext+‘/system/sysCodeAction!getCodeNameValueByCodeType.action?code_name_id=Aliyun_Regions‘,
                                        onSelect: function(rec){   
                                            if(rec.code_value){
                                                 $(‘#regionname‘).val(rec.code_name);
                                            }
                                        }"/> 
                                </td> 
                <td align="right" ><nobr>可用区:</nobr></td>  
                                <td>
                                    <input id="zoneid" name="ecs.zoneid" class="easyui-combobox" style="width: 200px"
                                       value="${ecs.zoneid}" required="required"
                                       data-options="
                                        valueField: ‘code_value‘,   
                                        textField: ‘code_name‘, 
                                        editable:false,  
                                        url:webContext+‘/system/sysCodeAction!getCodeNameValueByCodeType.action?code_name_id=Aliyun_Zones‘,
                                        onSelect: function(rec){   
                                            if(rec.code_value){
                                                $(‘#zonename‘).val(rec.code_name);
                                            }
                                        }"/> 
                                </td> 
                </tr>
                <tr>
                <td align="right" ><nobr>配置:</nobr></td>  
                                <td>
                                    <input id="instancetype" name="ecs.instancetype" class="easyui-combobox" style="width: 200px"
                                       value="${ecs.instancetype}" required="required"
                                       data-options="
                                        valueField: ‘code_value‘,   
                                        textField: ‘code_name‘,   
                                        editable:false,
                                        url:webContext+‘/system/sysCodeAction!getCodeNameValueByCodeType.action?code_name_id=Aliyun_InstanceType‘,
                                        onSelect: function(rec){   
                                                if(rec.code_value){
                                                     $(‘#instancetypename‘).val(rec.code_name);
                                                }
                                        }"/> 
                                </td> 
                <!-- <td align="right" ><nobr>公网带宽:&nbsp;&nbsp;</nobr></td>
                <td  >
                    <input value="${ecs.internetmaxbandwidthout}" name="ecs.internetmaxbandwidthout" class="easyui-numberspinner" value=‘0‘ style="width:80px;" data-options="increment:1,min:0,max:200,editable:true"></input> Mbps
                    
                </td> -->
                </tr>
                </table>
                <div style="color:blue; ">网络:</div><hr/>
                <table class=‘sinopec_search_panel‘ border="0" width="100%" style="padding: 10px">
                <tr>
                <td width="100px"  align="right"><nobr>虚拟交换机:</nobr></td>
                <td width="300px">
                   <input id="vswitchid" name="ecs.vswitchid" class="easyui-combobox" style="width: 300px"
                                       value="${ecs.vswitchid}" required="required"
                                       data-options="
                                        valueField: ‘key‘,   
                                        textField: ‘value‘, 
                                        editable:false,  
                                        url:webContext+‘/vpc/vswitch_getAllSWitchLst.action‘,
                                        onSelect: function(rec){   
                                            if(rec.key){
                                                 var url = ‘${pageContext.request.contextPath}/vpc/securitygroup_getAllGroupLst.action?vswitchid=‘+rec.key;   
                                                 $(‘#securitygroupid‘).combobox(‘clear‘);
                                                 $(‘#securitygroupid‘).combobox(‘reload‘, url);
                                            }
                                        }"/>
                </td>
                <td align="right"><nobr>安全组:</nobr></td>
                <td >
                   <input id="securitygroupid" name="ecs.securitygroupid" class="easyui-combobox" style="width: 300px"
                                       value="${ecs.securitygroupid}" required="required"
                                       data-options="
                                        valueField: ‘key‘,   
                                        textField: ‘value‘,   
                                        editable:false,
                                        url:webContext+‘/vpc/securitygroup_getAllGroupLst.action‘,
                                        onSelect: function(rec){  
                                            if($(‘#vswitchid‘).combobox(‘getValue‘)==null||$(‘#vswitchid‘).combobox(‘getValue‘)==‘‘){
                                                alert(‘请先选择虚拟交换机‘);
                                            } 
                                            /**if(rec.key){
                                                 var url = ‘${pageContext.request.contextPath}/vpc/vswitch_getAllSWitchLst.action?securitygroupid=‘+rec.key;   
                                                 $(‘#vswitchid‘).combobox(‘clear‘);
                                                 $(‘#vswitchid‘).combobox(‘reload‘, url);
                                            }*/
                                        }"/>
                </td>
                </tr>
                </table>
                <span style="color:blue; ">镜像:</span><hr/>
                <table class=‘sinopec_search_panel‘ border="0" width="100%" style="padding: 10px">
                <tr>
                <td width="100px" align="right">镜像类型:</td>
                    <td >
                        <input type="radio" onclick="setImageType(1)" id="imageType1" name="imageType" value="1" checked>公共镜像
                          <input type="radio" onclick="setImageType(2)" id="imageType2" name="imageType" value="2" >自定义镜像
                    </td> 
                </tr>
                <tr id="checkImage1">
                <td width="100px" align="right">选择系统:</td>
                                <td >
                                    <input id="imageidcombobox" class="easyui-combobox" style="width: 200px"
                                       value="${ecs.imageid}" required="required"
                                       data-options="
                                        valueField: ‘code_value‘,   
                                        textField: ‘code_name‘,  
                                        editable:false, 
                                        url:webContext+‘/system/sysCodeAction!getCodeNameValueByCodeType.action?code_name_id=Aliyun_ImageId_Window‘,
                                        onSelect: function(rec){   
                                                if(rec.code_value){
                                                     $(‘#imageid‘).val(rec.code_value);
                                                     $(‘#imagename‘).val(rec.code_name);
                                                }
                                        }"/>
                                </td> 
                </tr>
                <tr id="checkImage2">
                <td width="100px" align="right">镜像名称:</td>
                <td ><div id="imagedescription">${ecs.imagename}</div><a  href="javascript:void(0)" class="easyui-linkbutton" onclick="checkImage()" data-options="iconCls:‘icon-edit‘">选择镜像</a>
                </td>
                </tr>
                
                </table>
                <div style="color:blue; ">储存:</div><hr/>
                <table class=‘sinopec_search_panel‘ border="0" width="100%" style="padding: 10px">
                <tr>
                <td  align="right" ><nobr>数据盘:</nobr></td>
                <td id="datas"> 
                    <a href="javascript:void(0)" onclick="addDatadisk()">+增加一块</a> 您一共可增加4块,每块可配置5~2000GB,不支持卸载
                    <s:iterator id="datadisk" value="#request.dataList" status="c">
                        <s:if test="disktype==1">
                            <div id="datas_datadisk_<s:property value=‘#c.count‘/>" >云磁盘:<input type="text" name="datas"  class="easyui-numberbox" data-options="min:5,max:2000,precision:0" value="<s:property value=‘size‘/>"  style="width: 80px"> GB <a href="#" class="easyui-linkbutton" onclick="deleteData(‘datas_datadisk_<s:property value="#c.count"/>‘)" data-options=‘plain:true,iconCls:"icon-cancel"‘>删除</a></div>
                        </s:if>
                    </s:iterator>
                </td>
                </tr>
                </table>
                <div style="color:blue; ">密码:</div><hr/>
                <table class=‘sinopec_search_panel‘ border="0" width="100%" style="padding: 10px">
                <tr>
                <td width="100px" align="right">设置密码:</td>
                    <td >
                        <input type="radio" onclick="setPas(1)" id="sex" name="sex" value="1" checked>立即设置
                          <input type="radio" onclick="setPas(2)" id="sex" name="sex" value="2" <s:if test="ecs.password==‘‘">checked</s:if> >创建后设置
                    </td> 
                </tr>
                <tr id="setPTr">
                <td align="right" ><nobr>登录密码:</nobr></td>
                <td ><input type="text"  style="width: 150px" type="password" 
                   name="ecs.password" id="password" validType="englishOrNum" class="easyui-validatebox" 
                   value="${ecs.password}" required="required">
                   密码必须为8-30个字符,同时包含大小写字母和数字,不支持特殊符号</td>
                </tr>
                <tr id="resetPTr">
                <td align="right" ><nobr>确认密码:</nobr></td>
                <td ><input type="text" style="width: 150px" type="password"
                   id="repassword" value="${ecs.password}" class="easyui-validatebox" required="required"  validType="equalTo[‘#password‘]" invalidMessage="两次输入密码不匹配"></td>
                </tr>
                <tr>
                <td width="100px" align="right" ><nobr>实例名称:</nobr></td>
                <td ><input type="text"
                   class="easyui-validatebox" style="width: 200px"
                   name="ecs.instancename" id="instancename" required="required" 
                   value="${ecs.instancename}" title="[2,128]英文或中文字符,必须以大小字母或中文开头,可包含数字,“.”,“_”或“-”。 如果没有指定该参数,默认值为实例的InstanceId 不能以http:// 和https:// 开头。"></td>
                </tr>
                </table>
                
                <div style="color:blue; ">其他信息:</div><hr/>
                <table class=‘sinopec_search_panel‘ border="0" width="100%" style="padding: 10px">
                <tr>
                <td width="100px" align="right" ><nobr>责任人:</nobr></td> 
                    <td><nobr>
                    <s:if test="#request.applyInfo==null">
                        <input type="text" name="ecs.responsible_name" id="responsible_name" readonly title="请点击选择按钮" class="easyui-validatebox" size="8" value="${sessionScope.username_ecs}" />
                    </s:if>
                    <s:else>
                    <input type="text" name="ecs.responsible_name" id="responsible_name" readonly title="请点击选择按钮" class="easyui-validatebox" size="8" value="${ecs.responsible_name}" />
                    </s:else>
                        <input type="hidden" name="ecs.responsible_id" id="responsible_id"  class="easyui-validatebox" size="8" value="${ecs.responsible_id}" />
                        <input type="button" class="btn" onclick="chooseOneCreator();" value="选择" /></nobr>
                        <input type="button" class="btn" onclick="resetOneCreator();" value="清空" /></nobr>
                    </td>
                </tr>
                <tr>
                <td width="100px" align="right" ><nobr>备注:</nobr></td>
                <td ><textarea id="description" name="ecs.description" cols="20" rows="5" style="width: 200px"
                      data-prompt-position="topRight:-70" title="[2, 256] 个字符,不能以 http:// 和 https:// 开头">${ecs.description}</textarea></td>
                </tr>
                <s:if test="#request.applyInfo==null">
                <tr>
                <td width="100px" align="right" ><nobr>申请数量:</nobr></td>
                <td >
                <input  name="instanceCount"  class="easyui-numberspinner" value=‘1‘ style="width:80px;" data-options="increment:1,min:1,editable:true"></input> 
                </td>
                </tr>
                </s:if>
                <!-- <tr>
                <td> </td>
                <td>
                <a id="submitB" href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" data-options="iconCls:‘icon-save‘">确认</a>
                </td>
                </tr> -->
            </table>
        </form>
        </div>
    </body>
</html>

entity层代码如下所示:

AliEcsInstance.java

package com.aliyun.pcitcAliyun.ecs.model;

import java.text.ParseException;
import java.util.Date;

import com.aliyun.util.DateUtil;
import com.sinopec.common.model.Page;
public class AliEcsInstance extends Page{

      private int id;
      private String instanceid;
      private String instancename; 
      private String description;
      private String regionid; 
      private String regionname; 
      private String zoneid; 
      private String zonename; 
      private String imageid; 
      private String imagename; 
      private String instancetype; 
      private String instancetypename; 
      private String securitygroupid; 
      private String securityGroupIds;
      private String internetchargetype; 
      private String internetmaxbandwidthin; 
      private String internetmaxbandwidthout; 
      private String hostname; 
      private String password; 
      private String systemdiskcategory; 
      private String systemdiskdiskname; 
      private String systemdiskdescription; 
      private String vswitchid; 
      private String systemcode; 
      private String systemname; 
      private String remark; 
      private String creator_id; 
      private String creator_name; 
      private String creator_dep; 
      private String creator_depname; 
      private Date create_time; 
      private String state; 
      private String status;
      private Date submit_time;
      private String privateipaddress_ip;
      private String natipaddress;
      private String eip;
      private String responsible_id;
      private String responsible_name;
      private String startupCount;
    
    //不跟数据库对应字段
    private Date start_time;
    private Date end_time;
    private String vpcid;
    private String loadbalancerid;
    private String vswitchname;
    private String vncUrl;
    /**
     * 阿里创建时间
     */
    private String creationTime;
    
    
    /**
     * 阿里云资源是否在本地数据库中存在
     * 0:不存在;1:存在;
     */
    Integer existInDB; 
    
    public String getVpcid() {
        return vpcid;
    }
    public void setVpcid(String vpcid) {
        this.vpcid = vpcid;
    }
    
    public String getStartupCount() {
        return startupCount;
    }
    public void setStartupCount(String startupCount) {
        this.startupCount = startupCount;
    }
    public String getVswitchname() {
        return vswitchname;
    }
    public void setVswitchname(String vswitchname) {
        this.vswitchname = vswitchname;
    }
    public Date getStart_time() {
        return start_time;
    }
    public void setStart_time(Date start_time) {
        this.start_time = start_time;
    }
    public Date getEnd_time() {
        return end_time;
    }
    public void setEnd_time(Date end_time) {
        this.end_time = end_time;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getInstanceid() {
        return instanceid;
    }
    public void setInstanceid(String instanceid) {
        this.instanceid = instanceid;
    }
    public String getInstancename() {
        return instancename;
    }
    public void setInstancename(String instancename) {
        this.instancename = instancename;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getRegionid() {
        return regionid;
    }
    public void setRegionid(String regionid) {
        this.regionid = regionid;
    }
    public String getRegionname() {
        return regionname;
    }
    public String getResponsible_id() {
        return responsible_id;
    }
    public void setResponsible_id(String responsible_id) {
        this.responsible_id = responsible_id;
    }
    public String getResponsible_name() {
        return responsible_name;
    }
    public void setResponsible_name(String responsible_name) {
        this.responsible_name = responsible_name;
    }
    public void setRegionname(String regionname) {
        this.regionname = regionname;
    }
    public String getZoneid() {
        return zoneid;
    }
    public void setZoneid(String zoneid) {
        this.zoneid = zoneid;
    }
    public String getZonename() {
        return zonename;
    }
    public void setZonename(String zonename) {
        this.zonename = zonename;
    }
    public String getImageid() {
        return imageid;
    }
    public void setImageid(String imageid) {
        this.imageid = imageid;
    }
    public String getImagename() {
        return imagename;
    }
    public void setImagename(String imagename) {
        this.imagename = imagename;
    }
    public String getInstancetype() {
        return instancetype;
    }
    public void setInstancetype(String instancetype) {
        this.instancetype = instancetype;
    }
    public String getInstancetypename() {
        return instancetypename;
    }
    public void setInstancetypename(String instancetypename) {
        this.instancetypename = instancetypename;
    }
    public String getSecuritygroupid() {
        return securitygroupid;
    }
    public void setSecuritygroupid(String securitygroupid) {
        this.securitygroupid = securitygroupid;
    }
    public String getInternetchargetype() {
        return internetchargetype;
    }
    public void setInternetchargetype(String internetchargetype) {
        this.internetchargetype = internetchargetype;
    }
    public String getInternetmaxbandwidthin() {
        return internetmaxbandwidthin;
    }
    public void setInternetmaxbandwidthin(String internetmaxbandwidthin) {
        this.internetmaxbandwidthin = internetmaxbandwidthin;
    }
    public String getInternetmaxbandwidthout() {
        return internetmaxbandwidthout;
    }
    public void setInternetmaxbandwidthout(String internetmaxbandwidthout) {
        this.internetmaxbandwidthout = internetmaxbandwidthout;
    }
    public String getHostname() {
        return hostname;
    }
    public void setHostname(String hostname) {
        this.hostname = hostname;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSystemdiskcategory() {
        return systemdiskcategory;
    }
    public void setSystemdiskcategory(String systemdiskcategory) {
        this.systemdiskcategory = systemdiskcategory;
    }
    public String getSystemdiskdiskname() {
        return systemdiskdiskname;
    }
    public void setSystemdiskdiskname(String systemdiskdiskname) {
        this.systemdiskdiskname = systemdiskdiskname;
    }
    public String getSystemdiskdescription() {
        return systemdiskdescription;
    }
    public void setSystemdiskdescription(String systemdiskdescription) {
        this.systemdiskdescription = systemdiskdescription;
    }
    public String getVswitchid() {
        return vswitchid;
    }
    public void setVswitchid(String vswitchid) {
        this.vswitchid = vswitchid;
    }
    public String getSystemcode() {
        return systemcode;
    }
    public void setSystemcode(String systemcode) {
        this.systemcode = systemcode;
    }
    public String getSystemname() {
        return systemname;
    }
    public void setSystemname(String systemname) {
        this.systemname = systemname;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getCreator_id() {
        return creator_id;
    }
    public void setCreator_id(String creator_id) {
        this.creator_id = creator_id;
    }
    public String getCreator_name() {
        return creator_name;
    }
    public void setCreator_name(String creator_name) {
        this.creator_name = creator_name;
    }
    public String getCreator_dep() {
        return creator_dep;
    }
    public void setCreator_dep(String creator_dep) {
        this.creator_dep = creator_dep;
    }
    public String getCreator_depname() {
        return creator_depname;
    }
    public void setCreator_depname(String creator_depname) {
        this.creator_depname = creator_depname;
    }
    public Date getCreate_time() {
        return create_time;
    }
    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public Date getSubmit_time() {
        return submit_time;
    }
    public void setSubmit_time(Date submit_time) {
        this.submit_time = submit_time;
    }
    public String getPrivateipaddress_ip() {
        return privateipaddress_ip;
    }
    public void setPrivateipaddress_ip(String privateipaddress_ip) {
        this.privateipaddress_ip = privateipaddress_ip;
    }
    public String getNatipaddress() {
        return natipaddress;
    }
    public void setNatipaddress(String natipaddress) {
        this.natipaddress = natipaddress;
    }
    public String getEip() {
        return eip;
    }
    public void setEip(String eip) {
        this.eip = eip;
    }
    public Integer getExistInDB() {
        return existInDB;
    }
    public void setExistInDB(Integer existInDB) {
        this.existInDB = existInDB;
    }
    public String getSecurityGroupIds() {
        return securityGroupIds;
    }
    public void setSecurityGroupIds(String securityGroupIds) {
        this.securityGroupIds = securityGroupIds;
    }
    public String getCreationTime() {
        String str = "";
        if(creationTime != null) {
            String tempDateStr = creationTime.replace("T", " ").replace("Z", "");
            try {
                str = DateUtil.getDateTime(DateUtil.getBeiJingTime(DateUtil.string2Date(tempDateStr)));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return str;
    }
    public void setCreationTime(String creationTime) {
        this.creationTime = creationTime;
    }
    public String getLoadbalancerid() {
        return loadbalancerid;
    }
    public void setLoadbalancerid(String loadbalancerid) {
        this.loadbalancerid = loadbalancerid;
    }
    public String getVncUrl() {
        return vncUrl;
    }
    public void setVncUrl(String vncUrl) {
        this.vncUrl = vncUrl;
    } 
    
    
}

action层代码如下所示:

EcsAction.java

//获取要修改的数据
public String editInstance() {
        HttpServletRequest request = ServletActionContext.getRequest();
        String id = request.getParameter("id");
        ecs = ecsManager.getInstanceByid(id);
        diskList = ecsManager.searchInstanceDatadisk(new Integer(id));
        request.setAttribute("dataList", diskList);
        // 用于判断前台是否 需要显示申请数量的标志属性
        request.setAttribute("applyInfo", "no");
        return SUCCESS;
    }

JsonPage.java

技术分享
package com.sinopec.common.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import net.sf.json.JSON;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig;


/**
 * 封装结果集的对象,用于转换为jQuery Easy UI的json对象
 * @param <T>
 * create at 2012-9-12 下午01:47:47
 * @author wanghe
 */
public class JsonPage<T> {
    private JsonConfig config = new JsonConfig();
    
    /**
     * 记录总数
     */
    private int total;
    
    /**
     * 结果集
     */
    private List<T> rows = new ArrayList<T>();

    
    public JsonPage(){
        super();
        config.registerJsonValueProcessor(Date.class,new DateJsonValueProcessor("yyyy-MM-dd"));
        config.setExcludes(new String[]{"config"});
    }
    public JsonPage(String formate){
        this();
        config.registerJsonValueProcessor(Date.class,new DateJsonValueProcessor(formate));
    }
    
    public JsonPage(List<T> rows,int total){
        this();
        this.total = total;
        this.rows = rows;
    }
    
    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getRows() {
        return rows;
    }
    
    public void setRows(List<T> rows) {
        this.rows = rows;
    }
    
    public JsonConfig getConfig() {
        return config;
    }

    public void setConfig(JsonConfig config) {
        this.config = config;
    }

    public JSON toJson(){
        return JSONSerializer.toJSON(this, config);
    }
    
    public JSONObject toJsonObject(){
        return JSONObject.fromObject(this, config);
    }
}
技术分享

QueryAction.java

技术分享
package com.sinopec.common.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSON;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.sinopec.common.model.DateJsonValueProcessor;
import com.sinopec.common.prossBar.manager.ProcessBarManager;
import com.sinopec.common.prossBar.model.ProceBarPercent;
import com.sinopec.common.util.StringUtil;


public abstract class QueryAction extends ActionSupport

{
    protected ProcessBarManager processBarManagerImp;
    private static final long serialVersionUID = -6604170344271862481L;
    /**
     * 返回的结果
     */
    private JSON result;
    
    private JsonConfig config = new JsonConfig();
    
    /**
     * 简单返回结果用,在不设置result时使用
     */
    public JSONObject simpleJSON = new JSONObject();
    
    /**
     * 页数
     */
    private int pageNo;
    
    /**
     * 记录数
     */
    private int pageSize;
    
    /**
     * 排序字段
     */
    private String sort;
    
    /**
     * 排序方式(desc?asc)
     */
    private String order;
    
    public int getPage() {
        return pageNo;
    }
    
    /**
     * 分页起始结果数
     * 
     * @return
     * int
     * create at 2012-9-14 上午11:09:25
     * @author wanghe
     */
    public int getStart() {
        return (pageNo-1)*pageSize;
    }
    
    /**
     * 分页最大结果数
     * 
     * @return
     * int
     * create at 2012-9-14 上午11:09:35
     * @author wanghe
     */
    public int getEnd() {
        return pageNo*pageSize;
    }
    
    public void setPage(int page) {
        this.pageNo = page;
    }
    
    public int getRows() {
        return pageSize;
    }

    public void setRows(int rows) {
        this.pageSize = rows;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }
    
    public JSON getResult() {
        return result==null?simpleJSON:result;
    }

    /**
     * 设置返回的JSON对象
     * @param result
     * void
     * create at 2012-10-19 上午11:28:46
     * @author wanghe
     */
    public void setResult(JSON result) {
        this.result = result;
    }
    
    public void setResult(Object result,String formate) {
        config.registerJsonValueProcessor(Date.class,new DateJsonValueProcessor(formate));
        this.result = JSONObject.fromObject(result, config);
    }
    
    
    /**
     * 设置要返回的对象,此方法会将传递进来的对象解析成JSON格式
     * @param model
     * void
     * create at 2012-10-19 上午11:28:55
     * @author wanghe
     */
    public void setModel(Object model) {
        this.result = JSONObject.fromObject(model);
    }
    
    /**
     * 传入一个ID字符串(以,号连接的),解析后,返回ID集合
     * @param array
     * @return
     * List<String>
     * create at 2012-10-11 下午05:16:09
     * @author wanghe
     */
    public List<String> toList(String array){
        ArrayList<String> list = new ArrayList<String>();
        if(array!=null){
            for (String string : array.split(",")) {
                list.add(string);
            }
        }
        return list;
    }
    protected List<String> toList(String[]idarray){
        List<String> idList=new ArrayList<String>();
        if(idarray!=null)
        for(String id:idarray){
            idList.add(id);
        }
        return idList;
        
    }
    /**
     * 将以,或者空格分隔的字符串解析成字符数组
     * @param str 以,或者空格分隔的字符串
     * @return 字符数组
     * @author hanxg
     * @date 2014-2-13
     */
    protected List<String> split(String str){
        if(StringUtil.isEmpty(str)) return null;
        String[] arr = StringUtil.format(str).split("[\\s,]+", 0);
        List<String> list = new ArrayList<String>();
        for(String s:arr){
            if(!StringUtil.format(s).equals(""))
                list.add(s);
        }
        return list;
    }
    /**
     * 开始导入校验
     * @return
     */
    public String processCheck(){
        HttpServletRequest request = ServletActionContext.getRequest();
        String guid=request.getParameter("guid");
        Object obj=request.getSession().getAttribute(guid); 
          if(obj!=null){                   
                 simpleJSON.put("processState",true);              
          }else{
               
                  ProceBarPercent proceBarPercent=new ProceBarPercent(); 
                  request.getSession().setAttribute(guid,proceBarPercent);
                simpleJSON.put("processState",true);
             
          }
        return SUCCESS;
    }
    /**
     * 获取进程进度的方法 默认的方法   阶段性处理
     * @return
     */
    public String getDefPersent(){          
        HttpServletRequest request = ServletActionContext.getRequest();
        String guid=request.getParameter("guid");
        ProceBarPercent proceBarPercent=(ProceBarPercent)request.getSession().getAttribute(guid);
        while(proceBarPercent.getNextPercent()==0){          
              try {
                  Thread.sleep(1000);
                } catch (InterruptedException e) { 
                    e.printStackTrace();
                }
        } 
        simpleJSON.put("currentPercent",proceBarPercent.getDefPersent().getCurrentPercent()); 
        simpleJSON.put("isHasValidatePass",proceBarPercent.isHasValidatePass()); 
        proceBarPercent.setNextPercent(0); 
        return SUCCESS;
    }
    /**
     * 获取进程进度的方法 校验  条条进行
     * @return
     */
    public String getValidatePersent(){                
        HttpServletRequest request = ServletActionContext.getRequest();
        String guid=request.getParameter("guid");
        ProceBarPercent proceBarPercent=(ProceBarPercent)request.getSession().getAttribute(guid);
        while(proceBarPercent.getNextPercent()==0){          
              try {
                  Thread.sleep(500);
                } catch (InterruptedException e) { 
                    e.printStackTrace();
                }
        } 
        simpleJSON.put("currentPercent",proceBarPercent.getValidatePersent().getCurrentPercent()); 
        simpleJSON.put("isHasValidatePass",proceBarPercent.isHasValidatePass()); 
        proceBarPercent.setNextPercent(0);
        return SUCCESS;
    }
    /**
     * 获取进程进度的方法 导入
     * @return 
     */
    public String getImportPersent(){
        HttpServletRequest request = ServletActionContext.getRequest();
        String guid=request.getParameter("guid");
        ProceBarPercent proceBarPercent=(ProceBarPercent)request.getSession().getAttribute(guid);
        this.setResult(JSONObject.fromObject(proceBarPercent.getValidatePersent())); 
        return SUCCESS;
    }

    public ProcessBarManager getProcessBarManager() {
        return processBarManagerImp;
    }

    public void setProcessBarManager(ProcessBarManager processBarManagerImp) {
        this.processBarManagerImp = processBarManagerImp;
    }
    
    
}
技术分享

manager层代码如下所示:

EcsManager.java

List<AliDisk> searchInstanceDatadisk(int instanceId);

void updateInstance(AliEcsInstance ecs, String[] datas);

manager impl层代码如下所示:

EcsManagerImp.java

@Override
    public List<AliDisk> searchInstanceDatadisk(int instanceId) {
        AliDisk datadisk = new AliDisk();
        datadisk.setEcs_instance_id(instanceId);
        datadisk.setPageNo(1);
        datadisk.setPageSize(20);
        return ecsDao.findDatadiskByDyConditon(datadisk);
    }

@Override
    public void updateInstance(AliEcsInstance ecs, String[] datas) {
        ecsDao.updateInstance(ecs);
        ecsDao.deleteDatadisks(ecs.getId());
        List<AliDisk> list = new ArrayList<AliDisk>();
        // 系统盘
        AliDisk ed = new AliDisk();
        ed.setEcs_instance_id(ecs.getId());
        ed.setDisktype("0");
        ed.setSerialnumber("0");
        ed.setType("system");
        ed.setDiskname("Disk_0");
        ed.setSize(40);
        ed.setPortable("false");
        ed.setZoneid(ecs.getZoneid());
        ed.setRegionid(ecs.getRegionid());
        ed.setCreator_id(ecs.getCreator_id());
        ed.setCreator_name(ecs.getCreator_name());
        ed.setCreator_dep(ecs.getCreator_dep());
        ed.setCreator_depname(ecs.getCreator_depname());
        ed.setCreate_time(new Date());
        list.add(ed);
        // 数据盘
        if (datas != null && datas.length > 0) {
            for (int i = 0; i < datas.length; i++) {
                AliDisk e = new AliDisk();
                e.setEcs_instance_id(ecs.getId());
                e.setSize(new Integer(datas[i]));
                e.setSerialnumber("" + (i + 1));
                e.setDiskname("Disk_" + (i + 1));
                e.setPortable("true");
                e.setType("data");
                e.setDisktype("1");
                e.setZoneid(ecs.getZoneid());
                e.setRegionid(ecs.getRegionid());
                e.setCreator_id(ecs.getCreator_id());
                e.setCreator_name(ecs.getCreator_name());
                e.setCreator_dep(ecs.getCreator_dep());
                e.setCreator_depname(ecs.getCreator_depname());
                e.setCreate_time(new Date());
                list.add(e);
            }
        }
        ecsDao.insertDatadiskList(list);
        // 安全组关系表
        if (ecs.getSecuritygroupid() != null) {
            AliEcsSecuritygroup sg = ecsDao
                    .getAliEcsSecuritygroupByecsinstanceid(ecs.getId());
            sg.setSecuritygroupid(ecs.getSecuritygroupid());
            ecsDao.updateAliEcsSecuritygroup(sg);
        }
    }

dao层代码如下所示:

EcsDao.java

List<AliDisk> findDatadiskByDyConditon(AliDisk datadisk);

void updateInstance(AliEcsInstance ecs);

void deleteDatadisks(int instanceId);

void insertDatadiskList(List<AliDisk> datas);

AliEcsSecuritygroup getAliEcsSecuritygroupByecsinstanceid(int id);

void updateAliEcsSecuritygroup(AliEcsSecuritygroup sg);

dao impl层代码如下所示:

EcsDaoImp.java

@Override
    public int searchDatadiskTotal(AliDisk datadisk) {
        return (Integer) this.getSqlMapClientTemplate().queryForObject(
                "findDiskTotal", datadisk);
    }


@Override
    public void updateInstance(AliEcsInstance ecs) {
        this.getSqlMapClientTemplate().update("updateAliEcsInstance", ecs);
    }


@Override
    public void deleteDatadisks(int instanceId) {
        this.getSqlMapClientTemplate().delete("deleteAliDiskByEcsinstanceId",
                instanceId);

    }


@Override
    public void insertDatadiskList(final List<AliDisk> datas) {
        this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
            @Override
            public Object doInSqlMapClient(SqlMapExecutor executor)
                    throws SQLException {
                executor.startBatch();
                for (int i = 0; i < datas.size(); i++) {
                    executor.insert("insertAliDisk", datas.get(i));
                }
                return executor.executeBatch();
            }

        });
    }

@Override
    public AliEcsSecuritygroup getAliEcsSecuritygroupByecsinstanceid(int id) {
        return (AliEcsSecuritygroup) this.getSqlMapClientTemplate()
                .queryForObject("getAliEcsSecuritygroupByecsinstanceid", id);
    }

@Override
    public void updateAliEcsSecuritygroup(AliEcsSecuritygroup sg) {
        this.getSqlMapClientTemplate().update("updateAliEcsSecuritygroup", sg);
    }

ibatis代码如下所示:

page.xml

技术分享
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap namespace="page">
<!--     
  <sql id="pageStart">
      <isNotNull property="start">
      select * from (
                        select sun.* ,Rownum r  from ( 
       </isNotNull>
  </sql>
  
   <sql id="pageEnd">
   <isNotNull property="start">
   ) sun where Rownum <![CDATA[<= ]]> #end#
                    ) super where  super.r> #start#
   </isNotNull> 
  </sql>
-->
<sql id="pageStart">    
  </sql>
  
   <sql id="pageEnd">
   <isNotNull property="start">
    limit #start#,#pageSize#
   </isNotNull> 
  </sql>
</sqlMap>
技术分享
 olumn="REMAK"/>
        <result property="creator_id" column="CREATOR_ID"/>
        <result property="creator_name" column="CREATOR_NAME"/>
        <result property="creator_dep" column="CREATOR_DEP"/>
        <result property="creator_depname" column="CREATOR_DEPNAME"/>
        <result property="create_time" column="CREATE_TIME"/>
        <result property="state" column="STATE"/>
        <result property="status" column="STATUS"/>
        <result property="submit_time" column="SUBMIT_TIME"/>
        <result property="privateipaddress_ip" column="PRIVATEIPADDRESS_IP"/>
        <result property="natipaddress" column="NATIPADDRESS"/>
        <result property="eip" column="EIP"/>
        <result property="responsible_name" column="responsible_name"/>
        <result property="responsible_id" column="responsible_id"/>
        <result property="startupCount" column="startupCount"/>
    </resultMap>
    <resultMap id="oneresult" extends="result" class="AliEcsInstance" >
        <result property="vswitchname" column="vswitchname"/>
    </resultMap>
    
    <insert id="insertAliEcsInstance"  parameterClass="AliEcsInstance">
        insert into ali_ecs_instance (INSTANCEID,INSTANCENAME,DESCRIPTION,REGIONID,REGIONNAME,ZONEID,ZONENAME,IMAGEID,IMAGENAME,INSTANCETYPE,INSTANCETYPENAME,SECURITYGROUPID,INTERNETCHARGETYPE,INTERNETMAXBANDWIDTHIN,INTERNETMAXBANDWIDTHOUT,HOSTNAME,PASSWORD,SYSTEMDISKCATEGORY,SYSTEMDISKDISKNAME,SYSTEMDISKDESCRIPTION,VSWITCHID,SYSTEMCODE,SYSTEMNAME,REMARK,CREATOR_ID,CREATOR_NAME,CREATOR_DEP,CREATOR_DEPNAME,CREATE_TIME,STATE,STATUS,SUBMIT_TIME,responsible_id,responsible_name,startupCount) values(#instanceid#,#instancename#,#description#,#regionid#,#regionname#,#zoneid#,#zonename#,#imageid#,#imagename#,#instancetype#,#instancetypename#,#securitygroupid#,#internetchargetype#,#internetmaxbandwidthin#,#internetmaxbandwidthout#,#hostname#,#password#,#systemdiskcategory#,#systemdiskdiskname#,#systemdiskdescription#,#vswitchid#,#systemcode#,#systemname#,#remark#,#creator_id#,#creator_name#,#creator_dep#,#creator_depname#,now(),#state#,#status#,#submit_time#,#responsible_id#,#responsible_name#,#startupCount#)
        <selectKey resultClass="int" keyProperty="id" >  
              SELECT @@IDENTITY AS id  
        </selectKey> 
    </insert>
    </select>
</sqlMa

AliEcsInstance.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="AliEcsInstance">
    <typeAlias alias="AliEcsInstance" type="com.aliyun.pcitcAliyun.ecs.model.AliEcsInstance"/>
    <resultMap id="result" class="AliEcsInstance">
        <result property="id" column="ID"/>
        <result property="instanceid" column="INSTANCEID"/>
        <result property="instancename" column="INSTANCENAME"/>
        <result property="description" column="DESCRIPTION"/>
        <result property="regionid" column="REGIONID"/>
        <result property="regionname" column="REGIONNAME"/>
        <result property="zoneid" column="ZONEID"/>
        <result property="zonename" column="ZONENAME"/>
        <result property="imageid" column="IMAGEID"/>
        <result property="imagename" column="IMAGENAME"/>
        <result property="instancetype" column="INSTANCETYPE"/>
        <result property="instancetypename" column="INSTANCETYPENAME"/>
        <result property="securitygroupid" column="SECURITYGROUPID"/>
        <result property="internetchargetype" column="INTERNETCHARGETYPE"/>
        <result property="internetmaxbandwidthin" column="INTERNETMAXBANDWIDTHIN"/>
        <result property="internetmaxbandwidthout" column="INTERNETMAXBANDWIDTHOUT"/>
        <result property="hostname" column="HOSTNAME"/>
        <result property="password" column="PASSWORD"/>
        <result property="systemdiskcategory" column="SYSTEMDISKCATEGORY"/>
        <result property="systemdiskdiskname" column="SYSTEMDISKDISKNAME"/>
        <result property="systemdiskdescription" column="SYSTEMDISKDESCRIPTION"/>
        <result property="vswitchid" column="VSWITCHID"/>
        <result property="systemcode" column="SYSTEMCODE"/>
        <result property="systemname" column="SYSTEMNAME"/>
        <result property="remark" column="REMARK"/>
        <result property="creator_id" column="CREATOR_ID"/>
        <result property="creator_name" column="CREATOR_NAME"/>
        <result property="creator_dep" column="CREATOR_DEP"/>
        <result property="creator_depname" column="CREATOR_DEPNAME"/>
        <result property="create_time" column="CREATE_TIME"/>
        <result property="state" column="STATE"/>
        <result property="status" column="STATUS"/>
        <result property="submit_time" column="SUBMIT_TIME"/>
        <result property="privateipaddress_ip" column="PRIVATEIPADDRESS_IP"/>
        <result property="natipaddress" column="NATIPADDRESS"/>
        <result property="eip" column="EIP"/>
        <result property="responsible_name" column="responsible_name"/>
        <result property="responsible_id" column="responsible_id"/>
        <result property="startupCount" column="startupCount"/>
    </resultMap>
    <resultMap id="oneresult" extends="result" class="AliEcsInstance" >
        <result property="vswitchname" column="vswitchname"/>
    </resultMap>
    <update id="updateAliEcsInstance" parameterClass="AliEcsInstance">
        update ali_ecs_instance set INSTANCEID=#instanceid#,INSTANCENAME=#instancename#,DESCRIPTION=#description#,REGIONID=#regionid#,REGIONNAME=#regionname#,ZONEID=#zoneid#,ZONENAME=#zonename#,IMAGEID=#imageid#,IMAGENAME=#imagename#,INSTANCETYPE=#instancetype#,INSTANCETYPENAME=#instancetypename#,SECURITYGROUPID=#securitygroupid#,INTERNETCHARGETYPE=#internetchargetype#,INTERNETMAXBANDWIDTHIN=#internetmaxbandwidthin#,INTERNETMAXBANDWIDTHOUT=#internetmaxbandwidthout#,HOSTNAME=#hostname#,PASSWORD=#password#,SYSTEMDISKCATEGORY=#systemdiskcategory#,SYSTEMDISKDISKNAME=#systemdiskdiskname#,SYSTEMDISKDESCRIPTION=#systemdiskdescription#,VSWITCHID=#vswitchid#,SYSTEMCODE=#systemcode#,SYSTEMNAME=#systemname#,REMARK=#remark#,CREATOR_ID=#creator_id#,CREATOR_NAME=#creator_name#,CREATOR_DEP=#creator_dep#,CREATOR_DEPNAME=#creator_depname#,CREATE_TIME=#create_time#,STATE=#state#,STATUS=#status# ,SUBMIT_TIME=now(),NATIPADDRESS=#natipaddress#,PRIVATEIPADDRESS_IP=#privateipaddress_ip#,EIP=#eip#,responsible_id=#responsible_id#,responsible_name=#responsible_name#,startupCount=#startupCount#  where ID=#id#
    </update>
</sqlMap>

AliDisk.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="AliDisk">
    <typeAlias alias="AliDisk" type="com.aliyun.pcitcAliyun.ecs.model.AliDisk"/>
    <resultMap id="result" class="AliDisk">
        <result property="id" column="ID"/>
        <result property="ecs_instance_id" column="ECS_INSTANCE_ID"/> 
        <result property="regionid" column="REGIONID"/>
        <result property="zoneid" column="ZONEID"/>
        <result property="diskname" column="DISKNAME"/>
        <result property="description" column="DESCRIPTION"/>
        <result property="size" column="SIZE"/>
        <result property="snapshotid" column="SNAPSHOTID"/>
        <result property="clienttoken" column="CLIENTTOKEN"/>
        <result property="diskid" column="DISKID"/>
        <result property="instanceId" column="INSTANCEID"/>
        <result property="device" column="DEVICE"/>
        <result property="deletewithinstance" column="DELETEWITHINSTANCE"/>
        <result property="deleteautosnapshot" column="DELETEAUTOSNAPSHOT"/>
        <result property="enableautosnapshot" column="ENABLEAUTOSNAPSHOT"/>
        <result property="imageid" column="IMAGEID"/>
        <result property="type" column="TYPE"/>
        <result property="category" column="CATEGORY"/>
        <result property="status" column="STATUS"/>
        <result property="creationtime" column="CREATIONTIME"/>
        <result property="attachedtime" column="ATTACHEDTIME"/>
        <result property="detachedtime" column="DETACHEDTIME"/>
        <result property="creator_id" column="CREATOR_ID"/>
        <result property="creator_name" column="CREATOR_NAME"/>
        <result property="creator_dep" column="CREATOR_DEP"/>
        <result property="creator_depname" column="CREATOR_DEPNAME"/>
        <result property="create_time" column="CREATE_TIME"/> 
        <result property="serialnumber" column="SERIALNUMBER"/>
        <result property="disktype" column="DISKTYPE"/>
        <result property="sourcesnapshotid" column="SOURCESNAPSHOTID"/>
        <result property="productcode" column="PRODUCTCODE"/>
        <result property="portable" column="PORTABLE"/>
        <result property="operationlocks" column="OPERATIONLOCKS"/>
    </resultMap>

    <resultMap id="listresult" extends="result" class="AliDisk" >
        <result property="statusEcs" column="statusEcs"/>
        <result property="startupCountEcs" column="startupCountEcs"/>
    </resultMap>
    <resultMap id="listresult2" extends="listresult" class="AliDisk" >
        <result property="instanceidEcs" column="instanceidEcs"/>
        <result property="instancenameEcs" column="instancenameEcs"/>
        <result property="imagenameEcs" column="imagenameEcs"/>
        <result property="create_timeEcs" column="create_timeEcs"/>
    </resultMap>
    
<select id="findDiskTotal" parameterClass="AliDisk" resultClass="int"> 
        select count(*) from ali_disk where ECS_INSTANCE_ID=#ecs_instance_id# and (status !=‘Deleted‘ or status is null)
    </select>

<delete id="deleteAliDiskByEcsinstanceId" parameterClass="int">
        delete from ali_disk  where ECS_INSTANCE_ID=#value#
    </delete>

<insert id="insertAliDisk" parameterClass="AliDisk">
        insert into ali_disk (ECS_INSTANCE_ID,REGIONID,ZONEID,DISKNAME,DESCRIPTION,SIZE,SNAPSHOTID,CLIENTTOKEN,DISKID,INSTANCEID,DEVICE,DELETEWITHINSTANCE,DELETEAUTOSNAPSHOT,ENABLEAUTOSNAPSHOT,IMAGEID,TYPE,CATEGORY,STATUS,CREATIONTIME,ATTACHEDTIME,DETACHEDTIME,CREATOR_ID,CREATOR_NAME,CREATOR_DEP,CREATOR_DEPNAME,CREATE_TIME,SERIALNUMBER,DISKTYPE,SOURCESNAPSHOTID,PRODUCTCODE,PORTABLE,OPERATIONLOCKS) values(#ecs_instance_id#,#regionid#,#zoneid#,#diskname#,#description#,#size#,#snapshotid#,#clienttoken#,#diskid#,#instanceId#,#device#,#deletewithinstance#,#deleteautosnapshot#,#enableautosnapshot#,#imageid#,#type#,#category#,#status#,#creationtime#,#attachedtime#,#detachedtime#,#creator_id#,#creator_name#,#creator_dep#,#creator_depname#,#create_time#,#serialnumber#,#disktype#,#sourcesnapshotid#,#productcode#,#portable#,#operationlocks#)
        <selectKey resultClass="int" keyProperty="id" >  
              SELECT @@IDENTITY AS id  
        </selectKey> 
    </insert>
</sqlMap>
 column="CREATOR_DEP"/>
        <result property="creator_depname" column="CREATOR_DEPNAME"/>
        <result property="create_time" column="CREATE_TIME"/> 
        <result property="serialnumber" column="SERIALNUMBER"/>
        <result property="disktype" column="DISKTYPE"/>
        <result property="sourcesnapshotid" column="SOURCESNAPSHOTID"/>
        <result property="productcode" column="PRODUCTCODE"/>
        <result property="portable" column="PORTABLE"/>
        <result property="operationlocks" column="OPERATIONLOCKS"/>
    </resultMap>

    <resultMap id="listresult" extends="result" class="AliDisk" >
        <result property="statusEcs" column="statusEcs"/>
        <result property="startupCountEcs" column="startupCountEcs"/>
    </resultMap>
    <resultMap id="listresult2" extends="listresult" class="AliDisk" >
        <result property="instanceidEcs" column="instanceidEcs"/>
        <result property="instancenameEcs" column="instancenameEcs"/>
        <result property="imagenameEcs" column="imagenameEcs"/>
        <result property="create_timeEcs" column="create_timeEcs"/>
    </resultMap>
    
<insert id="insertAliDisk" parameterClass="AliDisk">
        insert into ali_disk (ECS_INSTANCE_ID,REGIONID,ZONEID,DISKNAME,DESCRIPTION,SIZE,SNAPSHOTID,CLIENTTOKEN,DISKID,INSTANCEID,DEVICE,DELETEWITHINSTANCE,DELETEAUTOSNAPSHOT,ENABLEAUTOSNAPSHOT,IMAGEID,TYPE,CATEGORY,STATUS,CREATIONTIME,ATTACHEDTIME,DETACHEDTIME,CREATOR_ID,CREATOR_NAME,CREATOR_DEP,CREATOR_DEPNAME,CREATE_TIME,SERIALNUMBER,DISKTYPE,SOURCESNAPSHOTID,PRODUCTCODE,PORTABLE,OPERATIONLOCKS) values(#ecs_instance_id#,#regionid#,#zoneid#,#diskname#,#description#,#size#,#snapshotid#,#clienttoken#,#diskid#,#instanceId#,#device#,#deletewithinstance#,#deleteautosnapshot#,#enableautosnapshot#,#imageid#,#type#,#category#,#status#,#creationtime#,#attachedtime#,#detachedtime#,#creator_id#,#creator_name#,#creator_dep#,#creator_depname#,#create_time#,#serialnumber#,#disktype#,#sourcesnapshotid#,#productcode#,#portable#,#operationlocks#)
        <selectKey resultClass="int" keyProperty="id" >  
              SELECT @@IDENTITY AS id  
        </selectKey> 
    </insert>

</sqlMap>

AliEcsSecuritygroup.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="AliEcsSecuritygroup">
    <typeAlias alias="AliEcsSecuritygroup" type="com.aliyun.pcitcAliyun.ecs.model.AliEcsSecuritygroup"/>
    <resultMap id="result" class="AliEcsSecuritygroup">
        <result property="id" column="ID"/>
        <result property="instanceid" column="INSTANCEID"/>
        <result property="create_time" column="CREATE_TIME"/>
        <result property="securitygroupid" column="SECURITYGROUPID"/>
        <result property="creator_id" column="CREATOR_ID"/>
        <result property="creator_name" column="CREATOR_NAME"/>
        <result property="creator_dep" column="CREATOR_DEP"/>
        <result property="creator_depname" column="CREATOR_DEPNAME"/>
        <result property="ecs_instance_id" column="ecs_instance_id"/>
    </resultMap>

    <select id="getAliEcsSecuritygroupByecsinstanceid" parameterClass="int" resultMap="result">
        select * from ali_ecs_securitygroup where ecs_instance_id=#value#
    </select>

    <update id="updateAliEcsSecuritygroup" parameterClass="AliEcsSecuritygroup">
        update ali_ecs_securitygroup set INSTANCEID=#instanceid#,CREATE_TIME=#create_time#,SECURITYGROUPID=#securitygroupid#,CREATOR_ID=#creator_id#,CREATOR_NAME=#creator_name#,CREATOR_DEP=#creator_dep#,CREATOR_DEPNAME=#creator_depname#,ecs_instance_id=#ecs_instance_id#  where ID=#id#
    </update>
</sqlMap>

石化盈科系统架构代码复用模板之四:修改数据模板

标签:

原文地址:http://www.cnblogs.com/longshiyVip/p/4591189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!