Cordys 后端增删改查 例子

增加:

第一种方法:【利用参数】

 public static String GetDepartmentIDByInsert(String DepartName, int ParentID)
    {
    	String sqlInsert="insert into department (DepartName,ParentID) values('"+DepartName+"',"+ParentID+" )";

    	DMLStatement dml = new DMLStatement(sqlInsert);
    	
    	
    	String sqlQuery="select  LAST_INSERT_ID() as id from dual ";
    	
    	QueryObject query = new QueryObject(sqlQuery); 
    	query.setResultClass(AnonymousBusObject.class);
    	
    	dml.executeDML();
    	AnonymousBusObject boit = (AnonymousBusObject)query.getObject();
    	String resultValue = boit.getStringProperty("id");
        return resultValue;
    }
    </span>


第二种方法:【利用利用对象,在定义接口时候,可以把整个对象作为一个参数】


WebService接口

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP:Body>
    <SaveOrganization xmlns="http://com.unicom.bopm/organization" preserveSpace="no" qAccess="0" qValues="">
      <organization>
        <SM_ORGANIZATION>
          <ORG_ID>PARAMETER</ORG_ID>
          <ORG_NAME>PARAMETER</ORG_NAME>
          <PARENT_ID>PARAMETER</PARENT_ID>
          <ORG_CODE>PARAMETER</ORG_CODE>
          <TENANT_DN>PARAMETER</TENANT_DN>
          <ORG_LEVEL>PARAMETER</ORG_LEVEL>
          <IS_COMPANY>PARAMETER</IS_COMPANY>
          <IS_COUNTY>PARAMETER</IS_COUNTY>
          <IS_VIRTUAL_ORG>PARAMETER</IS_VIRTUAL_ORG>
          <IS_TENANT_ROOT>PARAMETER</IS_TENANT_ROOT>
          <SORT_NO>PARAMETER</SORT_NO>
          <STATUS_SIGN>PARAMETER</STATUS_SIGN>
          <CREATE_PERSON>PARAMETER</CREATE_PERSON>
          <CREATE_TIME>PARAMETER</CREATE_TIME>
          <DESC_MEMO>PARAMETER</DESC_MEMO>
        </SM_ORGANIZATION>
      </organization>
    </SaveOrganization>
  </SOAP:Body>
</SOAP:Envelope>



后台接口

    public static String saveOrganization(com.unicom.bopm.organization.SM_ORGANIZATION organization)
    {
        return OrganizationManager.saveOrganization(organization);
    }
    


删除


第一种方法:

    public static void DeleteByID(int ID)
    {
        String stringText = "delete from department where ID =:ID";
        DMLStatement dml = new DMLStatement(stringText);
        dml.addParameter("ID", "department.ID", ID);
        dml.executeDML();
    }

第二种方法:


   		SM_MENU currentMenuObj=null;
    		String currentMenuQT="SELECT * FROM SM_MENU M WHERE M.MENU_ID=:MENU_ID";
    		QueryObject currentMenuQ = new QueryObject(currentMenuQT);
    		currentMenuQ.addParameter("MENU_ID","SM_MENU.MENU_ID", QueryObject.PARAM_STRING, menu_id);
    		currentMenuQ.setResultClass(SM_MENU.class);
    		currentMenuObj=(SM_MENU) currentMenuQ.getObject();
    		currentMenuObj.setSTATUS_SIGN(status_sign);
    		currentMenuObj.delete();




修改

第一种方法

    public static void UpdateByName(String Name,int ID)
    {
    	String sqlUpdate="update department set DepartName='"+Name+"' where ID="+ID;
        DMLStatement dml = new DMLStatement(sqlUpdate);
        dml.executeDML();
    }

第二种方法:


    		BusObjectIterator<SM_MENU> childMenusObj = null;
    		String childMenusQT="SELECT * FROM SM_MENU M WHERE M.PARENT_ID=:MENU_ID";
    		QueryObject childMenusQ = new QueryObject(childMenusQT);
    		childMenusQ.addParameter("MENU_ID","SM_MENU.MENU_ID", QueryObject.PARAM_STRING, menu_id);
    		childMenusQ.setResultClass(SM_MENU.class);
    		childMenusObj=childMenusQ.getObjects();
    		while(childMenusObj.hasMoreElements())
    		{
    			SM_MENU obj=(SM_MENU)childMenusObj.nextElement();
    			obj.setSTATUS_SIGN(status_sign);
    			obj.update();
    		}


查询

    public static BusObjectIterator<com.commonpackage.department> GetDepartmentByParentID(int ParentID)
    {
        String queryText = "select * from department where ParentID= :ID";
        QueryObject query = new QueryObject(queryText);
        query.addParameter("ID", "department.ParentID", QueryObject.PARAM_INT ,ParentID);
        query.setResultClass(department.class);
        return query.getObjects();
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值