第一步:
applicationContext-main.xml下,删除代码
第二步:
sqlMapConfig.xml下删除代码:
第三步:
mapper下面删除cargoType.xml
代码如下:
insert into cargotype
( cargoType,opertime )
values
( #cargoType:VARCHAR#,now() )
select last_insert_id() as id
update cargotype set
cargoType=#cargoType:VARCHAR#,opertime=now()
where cgtId=#cgtId:VARCHAR# and status = 1
update cargotype set
cargoType = #cargoType:VARCHAR#
where cgtId=#cgtId:VARCHAR# and status = 1
update cargotype set status = 0,opertime = now() where cgtId = #cgtId:VARCHAR#
update cargotype set status = 0,opertime = now() where cgtId in ( #cgtId:VARCHAR# )
第四步:
控制类controllers下删除Cargotypec文件
代码如下:
package wazert.cargo.controllers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import net.sf.serfj.RestController;
import net.sf.serfj.annotations.GET;
import net.sf.serfj.annotations.POST;
import org.apache.log4j.Logger;
import wazert.cargo.services.CargoTypeDao;
import wazert.cargo.util.CommonUtil;
import wazert.wolf.json.Json2ObjectUtil;
import wazert.wolf.serializer.JsonGenerateUtil;
import wazert.wolf.serializer.JsonResponse;
import wazert.wolf.util.SysGlobalUtil;
import wazert.wolf.util.WolfSpringContext;
/**
* @author sxs
* @function 货物类型
* @date 2014-05-21
*/
public class Cargotypec extends RestController {
public static Logger logger = Logger.getLogger(Cargotypec.class);
/************** 系统自动生成-开始 *************/
/**
* @author sxs
* @function 列表页面
* @date 2014-05-21
*/
@GET
public void listPage() {
}
/**
* @author sxs
* @function 增加页面
* @date 2014-05-21
*/
@GET
public void addPage() {
}
/**
* @author sxs
* @function 修改页面
* @date 2014-05-21
*/
@GET
public void editPage() {
}
/**
* @author sxs
* @function 查询页面
* @date 2014-05-21
*/
@GET
public void searchPage() {
}
/**
* @author sxs
* @function 详情页面
* @date 2014-05-21
*/
@GET
public void detailPage() {
}
/**
* @author sxs
* @function 新增全部字段
* @param json
* {cargoType:}
* @return json {msg:ok,id:} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
@POST
public String addAll() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("addAll=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.insertAll(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据单个编号修改全部字段
* @param json
* {cargoType:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
@POST
public String editAllById() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("editAllById=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.updateAllById(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据单个编号修改全部非空字段
* @param json
* {cargoType:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
@POST
public String editAllNotNullById() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("editAllNotNullById=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.updateAllNotNullById(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据单个编号删除单条记录
* @param json
* {cgtId:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
@POST
public String dropOneById() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("dropOneById=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.deleteOneById(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据多个编号删除多条记录
* @param json
* {cgtIds:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
@POST
public String dropMoreByIds() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("dropMoreByIds=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.deleteMoreByIds(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 查询所有记录
* @return json [{cargoType:,opertime:,status:},...]
* @date 2014-05-21
*/
@POST
public String searchAll() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("searchAll=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectAll(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 查询所有记录总条数
* @return json {count:}
* @date 2014-05-21
*/
@POST
public String searchAllCount() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("searchAllCount=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectAllCount(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据单个编号查询单个记录
* @param json
* {cgtId:}
* @return json {cargoType:,opertime:,status:}
* @date 2014-05-21
*/
@POST
public String searchOneById() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("searchOneById=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectOneById(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据多个编号查询多条记录
* @param json
* {cgtIds:}
* @return json [{cargoType:,opertime:,status:},...]
* @date 2014-05-21
*/
@POST
public String searchMoreByIds() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("searchOneById=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectMoreByIds(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 根据指定名称查询单条记录
* @param json
* {cargoType:,opertime:,status:}
* @return json {cargoType:,opertime:,status:}
* @date 2014-05-21
*/
@POST
public String searchOneByName() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("searchOneByName=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectOneByName(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 查询所有记录总条数
* @param json
* {cargoType:,opertime:,status:}
* @return json {count:}
* @date 2014-05-21
*/
@POST
public String searchListCount() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);// 过滤非法字符
logger.debug("searchList=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectListCount(formMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/**
* @author sxs
* @function 查询所有记录总条数
* @param json
* {cargoType:,opertime:,status:}
* @return json {count:}
* @date 2014-05-21
*/
@POST
public String searchList() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map fornMap = this.getParams();
fornMap = SysGlobalUtil.removeFilter(fornMap);
logger.debug("searchList="+ fornMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext.
getBean("cargoTypeDao"); //调用接口(实现类)
msgJson=cargoTypeDao.selectList(fornMap);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/************** 系统自动生成-结束 *************/
/************** 自定义控制-开始 *************/
/**
* @author sxs
* @function 查询所有记录,手机端可选择货物类型(可选项)
* @return json [{cargoType:,cgtId:},{cargoType:,cgtId:}]
* @date 2014-05-21
*/
@POST
public String searchCargoTypeAll() {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
Map formMap = this.getParams();
formMap = SysGlobalUtil.removeFilter(formMap);
logger.debug("searchCargoTypeAll=" + formMap);
CargoTypeDao cargoTypeDao = (CargoTypeDao) WolfSpringContext
.getBean("cargoTypeDao"); // 调用接口(实现类)
msgJson = cargoTypeDao.selectAll(formMap);
// 如果返回的包括sorry和异常则不符合规范,表示有错误或者没有值
if (!msgJson.contains("sorry") && !msgJson.contains("Exception")) {
List cartypeList = Json2ObjectUtil.parseJSON2List(msgJson);// 把json转成list
List cargolist = new ArrayList();
for (Object obj : cartypeList) {
Map cargotypeMap = (Map) obj;
if (cargotypeMap != null) {
Map cargoMap = new HashMap();
// 返回的数据,货物类型和货物id
cargoMap
.put("cargoType", cargotypeMap.get("cargoType"));
cargoMap.put("cgtId", cargotypeMap.get("cgtId"));
cargolist.add(cargoMap);
}
}
msgJson = JsonGenerateUtil.getListJson(cargolist);// 把list数据封装成json返回到手机端
}
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
HttpServletResponse response = this.getResponseHelper().getResponse();
return new JsonResponse().responseJson(response, msgJson);
}
/************** 自定义控制-结束 *************/
}
第五步:
domain下删除文件CargoType
代码如下:
package wazert.cargo.domain;
import wazert.wolf.util.SysGlobalUtil;
/**
* @author sxs
* @function 货物类型
* @date 2014-05-21
*/
public class CargoType {
private String cgtId; // 货物类型编号
private String cargoType; // 货物类型
private String opertime; // 操作时间
private String status; // 状态 0:删除 1:正常
public String getCgtId() {
if (cgtId != null) {
if (new SysGlobalUtil().isInt(cgtId) == false)
cgtId = null;
}
return cgtId;
}
public void setCgtId(String cgtId) {
if (cgtId != null) {
if (new SysGlobalUtil().isInt(cgtId) == false)
cgtId = null;
}
this.cgtId = cgtId;
}
public String getCargoType() {
if (cargoType != null) {
if ("".equals(cargoType))
cargoType = null;
}
return cargoType;
}
public void setCargoType(String cargoType) {
if (cargoType != null) {
if ("".equals(cargoType))
cargoType = null;
}
this.cargoType = cargoType;
}
public String getOpertime() {
if (opertime != null) {
if ("".equals(opertime))
opertime = null;
}
return opertime;
}
public void setOpertime(String opertime) {
if (opertime != null) {
if ("".equals(opertime))
opertime = null;
}
this.opertime = opertime;
}
public String getStatus() {
if (status != null) {
if (new SysGlobalUtil().isInt(status) == false)
status = null;
}
return status;
}
public void setStatus(String status) {
if (status != null) {
if (new SysGlobalUtil().isInt(status) == false)
status = null;
}
this.status = status;
}
public String toString() {
return cgtId + "," + cargoType + "," + opertime + "," + status;
}
}
第六步:
services接口下删除CargoTypeDao
代码如下:
package wazert.cargo.services;
import java.util.Map;
/**
* @author sxs
* @function 货物类型
* @date 2014-05-21
*/
public interface CargoTypeDao {
/************** 系统自动生成-开始 *************/
public String insertAll(Map map); // 新增全部字段(系统生成)
public String updateAllById(Map map); // 根据单个编号修改全部字段(系统生成)
public String updateAllNotNullById(Map map); // 根据单个编号修改全部非空字段(系统生成)
public String deleteOneById(Map map); // 根据单个编号删除单条记录(系统生成)
public String deleteMoreByIds(Map map); // 根据多个编号删除多条记录(系统生成)
public String selectAll(Map map); // 查询所有记录(系统生成)
public String selectAllCount(Map map); // 查询所有记录总条数(系统生成)
public String selectOneById(Map map); // 根据单个编号查询单个记录(系统生成)
public String selectMoreByIds(Map map); // 根据多个编号查询多条记录(系统生成)
public String selectOneByName(Map map); // 根据指定名称查询单条记录(系统生成)
public String selectList(Map map);// 根据搜索条件查询列表,返回列表(系统生成)
public String selectListCount(Map map);// 根据搜索条件查询列表条数,返回总条数(系统生成)
/************** 系统自动生成-结束 *************/
/************** 自定义接口-开始 *************/
/************** 自定义接口-结束 *************/
}
第七步:
services.impl下删除CargoTypeDaoImpl
代码如下:
package wazert.cargo.services.impl;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import wazert.cargo.domain.CargoType;
import wazert.cargo.services.CargoTypeDao;
import wazert.cargo.util.CommonUtil;
import wazert.wolf.serializer.JsonGenerateUtil;
import wazert.wolf.util.ParseFormToBean;
public class CargoTypeDaoImpl extends SqlMapClientDaoSupport implements
CargoTypeDao {
public static Logger logger = Logger
.getLogger(CargoTypeDaoImpl.class);
/************** 系统自动生成-开始 *************/
/**
* @author sxs
* @function 新增全部字段
* @param json
* {cargoType:}
* @return json {msg:ok,id:} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
public String insertAll(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
CargoType cargoType = new CargoType();
ParseFormToBean parseFormToBean = new ParseFormToBean();
cargoType = (CargoType) parseFormToBean.parseToBean(map, cargoType);
String id = (String) this.getSqlMapClientTemplate().insert(
"iBatisInsertAllCargoType", cargoType);
if (id != null && !"".equals(id))
msgJson = JsonGenerateUtil.getMsgIdJson("ok", id);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据单个编号修改全部字段
* @param json
* {cargoType:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
public String updateAllById(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
CargoType cargoType = new CargoType();
ParseFormToBean parseFormToBean = new ParseFormToBean();
cargoType = (CargoType) parseFormToBean.parseToBean(map, cargoType);
int temp = this.getSqlMapClientTemplate().update(
"iBatisUpdateAllCargoTypeById", cargoType);
if (temp > 0)
msgJson = JsonGenerateUtil.getMsgJson("ok");
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据单个编号修改全部非空字段
* @param json
* {cargoType:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
public String updateAllNotNullById(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
CargoType cargoType = new CargoType();
ParseFormToBean parseFormToBean = new ParseFormToBean();
cargoType = (CargoType) parseFormToBean.parseToBean(map, cargoType);
int temp = this.getSqlMapClientTemplate().update(
"iBatisUpdateAllNotNullCargoTypeById", cargoType);
if (temp > 0)
msgJson = JsonGenerateUtil.getMsgJson("ok");
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据单个编号删除单条记录
* @param json
* {cgtId:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
public String deleteOneById(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
int temp = this.getSqlMapClientTemplate().delete(
"iBatisDeleteOneCargoTypeById", map);
if (temp > 0)
msgJson = JsonGenerateUtil.getMsgJson("ok");
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据多个编号删除多条记录
* @param json
* {cgtIds:}
* @return json {msg:ok} or {msg:sorry} or {msg:Exception}
* @date 2014-05-21
*/
public String deleteMoreByIds(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
String cgtIds = String.valueOf(map.get("cgtIds") == null ? "" : map
.get("cgtIds"));
if (!"".equals(cgtIds)) {
int temp = this.getSqlMapClientTemplate().delete(
"iBatisDeleteMoreCargoTypeByIds", map);
if (temp > 0)
msgJson = JsonGenerateUtil.getMsgJson("ok");
}
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 查询所有记录
* @return json [{cargoType:,opertime:,status:},...]
* @date 2014-05-21
*/
public String selectAll(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
List list = this.getSqlMapClientTemplate().queryForList(
"iBatisSelectAllCargoType", map);
if (list != null)
msgJson = JsonGenerateUtil.list2json(list);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 查询所有记录总条数
* @return json {count:}
* @date 2014-05-21
*/
public String selectAllCount(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
String count = this.getSqlMapClientTemplate().queryForObject(
"iBatisSelectAllCountCargoType", map).toString();
if (count != null && !"".equals(count))
msgJson = "{\"count\":\"" + count + "\"}";
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据单个编号查询单个记录
* @param json
* {cgtId:}
* @return json {cargoType:,opertime:,status:}
* @date 2014-05-21
*/
public String selectOneById(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
CargoType cargoType = (CargoType) this.getSqlMapClientTemplate()
.queryForObject("iBatisSelectOneCargoTypeById", map);
if (cargoType != null)
msgJson = JsonGenerateUtil.object2json(cargoType);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据多个编号查询多条记录
* @param json
* {cgtIds:}
* @return json [{cargoType:,opertime:,status:},...]
* @date 2014-05-21
*/
public String selectMoreByIds(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
List list = this.getSqlMapClientTemplate().queryForList(
"iBatisSelectMoreCargoTypeByIds", map);
if (list != null)
msgJson = JsonGenerateUtil.list2json(list);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据指定名称查询单条记录
* @param json
* {cargoType:,opertime:,status:}
* @return json {cargoType:,opertime:,status:}
* @date 2014-05-21
*/
public String selectOneByName(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
CargoType cargoType = (CargoType) this.getSqlMapClientTemplate()
.queryForObject("iBatisSelectOneCargoTypeByName", map);
if (cargoType != null)
msgJson = JsonGenerateUtil.object2json(cargoType);
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 根据搜索条件查询列表,返回列表
* @param json
* {cargoType:,opertime:,status:}
* @return json [{cargoType:,opertime:,status:}]
* @date 2014-05-21
*/
public String selectList(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
List list = this.getSqlMapClientTemplate().queryForList(
"iBatisSelectListCargoType", map);
if (list != null && list.size() > 0) {
String count = this.getSqlMapClientTemplate().queryForObject(
"iBatisSelectListCountCargoType", map).toString();
if (count != null)
msgJson = JsonGenerateUtil.getPageListJson(list, count);
}
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/**
* @author sxs
* @function 查询所有记录总条数
* @param json
* {cargoType:,opertime:,status:}
* @return json {count:}
* @date 2014-05-21
*/
public String selectListCount(Map map) {
String msgJson = JsonGenerateUtil.getMsgJson("sorry");
try {
String count = this.getSqlMapClientTemplate().queryForObject(
"iBatisSelectListCountCargoType", map).toString();
if (count != null && !"".equals(count))
msgJson = "{\"count\":\"" + count + "\"}";
} catch (Exception e) {
e.printStackTrace();
logger.info("msg", e);
CommonUtil.getException(e.toString(), e.getStackTrace(), this
.getClass());// 将异常写入记录模块
msgJson = JsonGenerateUtil.getMsgJson("Exception");
}
return msgJson;
}
/************** 系统自动生成-结束 *************/
/************** 自定义实现-开始 *************/
/************** 自定义实现-结束 *************/
}
以上是后台代码,现在我们看前台信息
1,webRoot下js/themes/
删除cargotypec
删除两个js,list.js和add.js
代码如下:list.js
function f_hgrid_ini() {// 查询会员信息列表
alert("我在list.js下的f_hgrid_ini");
var pagerow = 10; // 参数为每页行数
f_hgrid_create(pagerow);
var txt = '
+ '
+ ' '
+ ' '
+ ' '
+ ' '
+ '
+ '
+ '
+ '
+ '
+ '
+ '
+ '
/* txt += '
+'
+'
+'
+'
+'
+'
+'
+'
+'
+'
+'
+'
+'
+'
for ( var i = 0; i < pagerow; i++) { // 生成不见的空行
txt = txt + '
txt = txt + '
}
$("#hgrid").empty().append(txt);
f_onmouseover();
}
function f_ {
$('.ctr' + i).css("background-color", "#FFCC80");
// $('#tr'+i).css("background-color","#FFCC80");
}
function f_ {
$('#tr' + i).addClass("onmouseout");
}
var lbsdeviceList_depa = {
"data" : []
};
// 展示行数
function f_hgrid_json(param) {// 刷新hGrid数据
alert("我在list.js下的f_hgrid_json");
// param不包括页码和每页行数
param = f_hgrid_getparam(param); // 得到全部参数
$.ajax({
url : "../cargotypecs/searchList",
type : 'post',
dataType : 'json',
data : param, // 参数
timeout:30000,
error:function(){
ymPrompt.errorInfo({"title":"提示","message":"网络故障,请重试!",handler:function(){
$("#loading").remove();//移除图片
$(".page_nav").remove();//移除已有分页div
}});
},
success : function(data) {// 回传函数
$("#loading").hide();
if (data != null && data != "") {
data = f_hgrid_setmsg(data); // 设置总 记录数,页信息等
var txt;
for ( var i = 0; i < data.length; i++) { // 展现返回的表格数据
var opertime = data[i].opertime;
if(opertime != null && opertime !=""){
var b = opertime.indexOf('.');
opertime = opertime.substring(0,b);
}
// 每行数据
txt = '
+'
+'
+'
$('#tr' + i).empty().append(txt);
}
var pagerow = $("#pagerow").val(); // 每页行数
for ( var i = data.length; i < pagerow; i++) {
$('#tr' + i).empty();
}
}
}
});
}
function trim(str) { // 删除左右两端的空
return str.replace(/(^\s*)|(\s*$)/g, "");
}
// 跳转至新增页面
function cargoAdd() {
window.location = '../cargotypecs/addPage';
}
// 全选
function checkAll(t) {
var _a = document.getElementsByTagName('input');
var _l = _a.length;
var a = [];
for ( var i = 0; i < _l; i++) {
if (_a[i].type == 'checkbox') {
a.push(_a[i]);
}
}
var l = a.length;
for ( var j = 0; j < l; j++) {
a[j].checked = t.checked;
if (a[j] != t) {
a[j].onclick = function() {
if (!this.checked) {
t.checked = false;
}
};
}
}
}
// 修改-编辑
function cargoEdit() {
var length = $('input:checked').length;
if (length == 0) {
ymPrompt.alert("请选择您要修改的数据!");
return;
} else if (length > 1) {
ymPrompt.alert("数据修改只能选择一项!");
return;
} else {
var cgId = $('input:checked').val();
window.location = '../cargocs/editPage?cgId=' + cgId;
}
}
// 批量删除
function cargoDel() {
var ids = "";
// 获取选中删除项
$('input[name=id]:checked:checked').each(function(index) {
var length = $('input:checked').length;
if (length == 1) {
ids = $(this).val();
} else {
if (index < length - 1) {
ids += $(this).val().trim().split(",")[0] + ",";
} else {
ids += $(this).val().trim().split(",")[0];
}
}
});
if (ids == "") {
ymPrompt.alert("请选择您要删除的数据!");
return;
} else {
ymPrompt.confirmInfo( {"title" : "提示","message" : "确定要删除数据吗?",handler : function(tp) {
if (tp == "ok") {
var param2 ="cgId=" + ids;
alert(param2);
$.ajax( {
url : "../cargocs/drop?random="+Math.random(),
contentType: "application/x-www-form-urlencoded; charset=utf-8",
type : "post",
dataType : "text",
data : param2, // 参数
success : function(data) {// 回传函数{"msg":"ok"}
data = JSON.parse(data);
if (data.msg == "ok") {
alert("删除数据成功!");
window.location = "../cargocs/listPage?random="+ Math.random();
} else {
ymPrompt.alert("删除数据失败!");
}
},
error:function(){
alert("信息错误");
}
});
f_hgrid_ini();
}
}});
}
}
//查看会员信息详情
function cargoDetail() {
var length = $('input:checked').length;
if (length == 0) {
ymPrompt.alert("请选择您要查看的数据!");
return;
} else if (length > 1) {
ymPrompt.alert("数据查看一次只能选择一项!");
return;
} else {
var cgId = $('input:checked').val();
window.location = '../cargocs/detailPage?cgId=' + cgId;
}
}
add.js就不写了
2,删除webRoot/WEB-INF/views/cargotypec
下的listPage.html
代码如下
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
货物类型管理 > 列表
3,web.xml下删除代码: