| Package: machii_info_sample.model.user |
| I am the service layer for User |
| Method Summary | |
|---|---|
| public any | init() |
| remote numeric |
createUser(string username, string email, string password, string password2, string firstName, string lastName, string company, numeric isAdmin, string dsn, string dbtype)
wraps CRUD method |
| remote numeric |
deleteUser(numeric userID, string dsn, string dbtype)
wraps CRUD method |
| remote userTO |
getUserDataByID(numeric userID, string dsn, string dbtype)
get user TO by userID |
| remote array |
getUsers(string dsn, [string username=""], [string email=""])
returns query of users |
| public Array |
toArray(query inputQuery)
Use to convert a query to an array of structs |
| remote numeric |
updateUser(numeric userID, string username, string email, string password, string password2, string firstName, string lastName, string company, numeric isAdmin, string dsn, string dbtype)
wraps CRUD method |
| Method Detail |
|---|
| createUser |
|---|
remote numeric createUser( string username, string email, string password, string password2, string firstName, string lastName, string company, numeric isAdmin, string dsn, string dbtype )
wraps CRUD method
Parameters:
| string username |
| string email |
| string password |
| string password2 |
| string firstName |
| string lastName |
| string company |
| numeric isAdmin |
| string dsn |
| string dbtype |
Code:
<cffunction name="createUser" access="remote" returntype="numeric" output="false" hint="wraps CRUD method">
<cfargument name="username" type="string" required="true" />
<cfargument name="email" type="string" required="true" />
<cfargument name="password" type="string" required="true" />
<cfargument name="password2" type="string" required="true" />
<cfargument name="firstName" type="string" required="true" />
<cfargument name="lastName" type="string" required="true" />
<cfargument name="company" type="string" required="true" />
<cfargument name="isAdmin" type="numeric" required="true" />
<cfargument name="dsn" type="string" required="true" />
<cfargument name="dbtype" type="string" required="true" />
<cfscript>
var userDAO = CreateObject("component", "machii_info_sample.model.dao.DAOFactory").init(trim(arguments.dsn), "machii_info").getDAOFactory(trim(arguments.dbType)).getUserDAO();
var userTO = CreateObject("component", "machii_info_sample.model.user.userTO").init(argumentcollection=arguments);
userDAO.create(userTO);
return 0;
</cfscript>
</cffunction>
| deleteUser |
|---|
remote numeric deleteUser( numeric userID, string dsn, string dbtype )
wraps CRUD method
Parameters:
| numeric userID |
| string dsn |
| string dbtype |
Code:
<cffunction name="deleteUser" access="remote" returntype="numeric" output="false" hint="wraps CRUD method">
<cfargument name="userID" type="numeric" required="true" />
<cfargument name="dsn" type="string" required="true" />
<cfargument name="dbtype" type="string" required="true" />
<cfscript>
var userDAO = CreateObject("component", "machii_info_sample.model.dao.DAOFactory").init(trim(arguments.dsn), "machii_info").getDAOFactory(trim(arguments.dbType)).getUserDAO();
userDAO.delete(arguments.userID);
return 0;
</cfscript>
</cffunction>
| getUserDataByID |
|---|
remote userTO getUserDataByID( numeric userID, string dsn, string dbtype )
get user TO by userID
Parameters:
| numeric userID |
| string dsn |
| string dbtype |
Code:
<cffunction name="getUserDataByID" access="remote" returntype="machii_info_sample.model.user.userTO" output="false" hint="get user TO by userID">
<cfargument name="userID" type="numeric" required="true" />
<cfargument name="dsn" type="string" required="true" />
<cfargument name="dbtype" type="string" required="true" />
<cfscript>
var userDAO = CreateObject("component", "machii_info_sample.model.dao.DAOFactory").init(trim(arguments.dsn), "machii_info").getDAOFactory(trim(arguments.dbType)).getUserDAO();
var userTO = userDAO.read(arguments.userID); // get TO of user data
return userTO;
</cfscript>
</cffunction>
| getUsers |
|---|
remote array getUsers( string dsn, [string username=""], [string email=""] )
returns query of users
Parameters:
| string dsn |
| [string username=""] |
| [string email=""] |
Code:
<cffunction name="getUsers" access="remote" returntype="array" output="false" hint="returns query of users">
<cfargument name="dsn" type="string" required="true" />
<cfargument name="username" type="string" required="false" default="" />
<cfargument name="email" type="string" required="false" default="" />
<cfscript>
var userGateway = createObject("component","machii_info_sample.model.user.userGateway").init(trim(arguments.dsn));
return this.toArray(userGateway.getUsers(arguments.username,arguments.email));
</cfscript>
</cffunction>
| init |
|---|
public any init( )
Parameters:
Code:
<cffunction name="init" access="public" > <cfreturn this /> </cffunction>
| toArray |
|---|
public Array toArray( query inputQuery )
Use to convert a query to an array of structs
Parameters:
| query inputQuery |
Code:
<cffunction name="toArray" access="public" displayName="toArray" hint="Use to convert a query to an array of structs" returnType="Array">
<cfargument name="inputQuery" type="query" required="yes" hint="Query to convert" />
<cfscript>
var aReturnData = arrayNew(1);
var tmpObject = "";
var columnList = lcase(inputQuery.columnList);
var columnName = "";
var i = 0;
var j = 0;
//loop over the query
for(i=1; i LTE inputQuery.recordCount; i=i+1 ){
tmpObject = structNew();
// loop over the columns
for(j=1; j LTE listLen(columnList); j=j+1 ){
columnName = listGetAt(columnList, j);
tmpObject[columnName] = inputQuery[columnName][i];
}
arrayAppend(aReturnData, tmpObject);
}
return aReturnData;
</cfscript>
</cffunction>
| updateUser |
|---|
remote numeric updateUser( numeric userID, string username, string email, string password, string password2, string firstName, string lastName, string company, numeric isAdmin, string dsn, string dbtype )
wraps CRUD method
Parameters:
| numeric userID |
| string username |
| string email |
| string password |
| string password2 |
| string firstName |
| string lastName |
| string company |
| numeric isAdmin |
| string dsn |
| string dbtype |
Code:
<cffunction name="updateUser" access="remote" returntype="numeric" output="false" hint="wraps CRUD method">
<cfargument name="userID" type="numeric" required="true" />
<cfargument name="username" type="string" required="true" />
<cfargument name="email" type="string" required="true" />
<cfargument name="password" type="string" required="true" />
<cfargument name="password2" type="string" required="true" />
<cfargument name="firstName" type="string" required="true" />
<cfargument name="lastName" type="string" required="true" />
<cfargument name="company" type="string" required="true" />
<cfargument name="isAdmin" type="numeric" required="true" />
<cfargument name="dsn" type="string" required="true" />
<cfargument name="dbtype" type="string" required="true" />
<cfscript>
var userDAO = CreateObject("component", "machii_info_sample.model.dao.DAOFactory").init(trim(arguments.dsn), "machii_info").getDAOFactory(trim(arguments.dbType)).getUserDAO();
var userTO = CreateObject("component", "machii_info_sample.model.user.userTO").init(argumentcollection=arguments);
userDAO.update(userTO);
return 0;
</cfscript>
</cffunction>