Controller:

/**软件管理*/
@Controller
@RequestMapping("/deploySoftware")
public class DeploySoftwareController extends BaseController {@Autowiredprivate DeploySoftwareService deploySoftwareService;/**跳转到软件信息页面 */@RequestMapping("/list")public String softwareInfoList() {return "/deploySoftware/deploySoftwareInfoList";}/**分页显示软件信息*/@RequestMapping("/getSoftwareInfoList")@ResponseBodypublic Pagination getSoftwareInfoList(DataGridModel model,String softName) {int pageNo = model.getPage();int pageSize = model.getRows();return deploySoftwareService.getSoftwareInfoList(softName,pageNo, pageSize);}/** 跳转到软件信息修改界面*/@RequestMapping("/toEditSoftwareInfo/{id}")public String toEditSoftwareInfo(@PathVariable("id")Integer id,Model model) {DeploySoftwareInfo deploySoftwareInfo = deploySoftwareService.getSoftwareInfoById(id);model.addAttribute("deploySoftwareInfo", deploySoftwareInfo);return "/deploySoftware/editSoftwareInfo";}/**修改|新增软件信息*/@RequestMapping(value = "/editSoftwareInfo",method = {RequestMethod.POST,RequestMethod.GET})@ResponseBodypublic String editSoftwareInfo(DeploySoftwareInfo deploySoftwareInfo,HttpServletRequest request) {Message message = new Message();Integer id = deploySoftwareInfo.getId();try {if (id != null) {//修改DeploySoftwareInfo updateDeploySoftwareInfo = new DeploySoftwareInfo();updateDeploySoftwareInfo.setId(id);updateDeploySoftwareInfo.setSoftName(StringUtils.trim(deploySoftwareInfo.getSoftName()));updateDeploySoftwareInfo.setInstallPath(StringUtils.trim(deploySoftwareInfo.getInstallPath()));updateDeploySoftwareInfo.setSoftDesc(deploySoftwareInfo.getSoftDesc());message = deploySoftwareService.updateSoftwareInfo(updateDeploySoftwareInfo);}else {//新增DeploySoftwareInfo addDeploySoftwareInfo = new DeploySoftwareInfo();addDeploySoftwareInfo.setSoftName(StringUtils.trim(deploySoftwareInfo.getSoftName()));addDeploySoftwareInfo.setInstallPath(StringUtils.trim(deploySoftwareInfo.getInstallPath()));addDeploySoftwareInfo.setSoftDesc(deploySoftwareInfo.getSoftDesc());message = deploySoftwareService.addSoftwareInfo(addDeploySoftwareInfo);}return message.getContent();} catch (Exception e) {e.printStackTrace();return "Error";}}/** 通过id删除软件信息*/@RequestMapping(value = "delDeploySoftwareInfo/{ids}",method = {RequestMethod.POST,RequestMethod.GET})@ResponseBodypublic String delDeploySoftwareInfo(@PathVariable("ids")List ids) {try {deploySoftwareService.delDeploySoftwareInfo(ids);return "success";} catch (Exception e) {e.printStackTrace();return "error";}}
}

Service:

/*** 软件管理service* date: 2015-8-19 下午3:52:45*/
@Service
@Transactional
public class DeploySoftwareServiceImpl implements DeploySoftwareService {@Autowiredprivate DeploySoftwareInfoMapper deploySoftwareInfoMapper;@Overridepublic Pagination getSoftwareInfoList(String softName,int pageNo, int pageSize) {String likeSoftName = null;if (softName != null) {likeSoftName = "%"+softName+"%";}PageBounds pb = new PageBounds(pageNo, pageSize, null, true);PageList<DeploySoftwareInfo> list = deploySoftwareInfoMapper.getSoftwareInfoList(likeSoftName,pb);return new Pagination(pageNo, pageSize, list.getPaginator().getTotalCount(), list);}@Overridepublic DeploySoftwareInfo getSoftwareInfoById(Integer id) {return deploySoftwareInfoMapper.getSoftwareInfoById(id);}@Overridepublic Message addSoftwareInfo(DeploySoftwareInfo deploySoftwareInfo) {Message msg = new Message();String softName = deploySoftwareInfo.getSoftName();boolean hasExists = deploySoftwareInfoMapper.hasExists(softName) > 0;if (hasExists) {msg.setType(Type.error);msg.setContent("softName Repeat");return msg;}else {deploySoftwareInfoMapper.addSoftwareInfo(deploySoftwareInfo);msg.setType(Type.success);msg.setContent("success");return msg;}}@Overridepublic Message updateSoftwareInfo(DeploySoftwareInfo deploySoftwareInfo) {Message msg = new Message();String softName = deploySoftwareInfo.getSoftName();DeploySoftwareInfo dInfoTemp = deploySoftwareInfoMapper.getSoftwareInfoById(deploySoftwareInfo.getId());if (softName.equals(dInfoTemp.getSoftName())) {//不修改程序名deploySoftwareInfoMapper.updateSoftwareInfo(deploySoftwareInfo);msg.setType(Type.success);msg.setContent("success");return msg;}else {//修改程序名boolean hasExists = deploySoftwareInfoMapper.hasExists(softName) > 0;if (hasExists) {msg.setType(Type.error);msg.setContent("softName Repeat");return msg;}else {deploySoftwareInfoMapper.updateSoftwareInfo(deploySoftwareInfo);msg.setType(Type.success);msg.setContent("success");return msg;}}}@Overridepublic void delDeploySoftwareInfo(List ids) {deploySoftwareInfoMapper.delDeploySoftwareInfo(ids);}
}

Mapper:

/*** 软件信息相关数据查询接口* 2015年2月12日*/
@Repository("deploySoftwareInfoMapper")
public interface DeploySoftwareInfoMapper {/** 分页查询软件信息 */PageList<DeploySoftwareInfo> getSoftwareInfoList(@Param("likeSoftName")String likeSoftName,PageBounds pb);/**根据id查询软件信息*/DeploySoftwareInfo getSoftwareInfoById(@Param("id")Integer id);/**增加软件信息*/int addSoftwareInfo(DeploySoftwareInfo deploySoftwareInfo);/** 修改软件信息*/boolean updateSoftwareInfo(DeploySoftwareInfo deploySoftwareInfo);/** 查找有无相同程序名*/int hasExists(@Param("softName")String softName);/** 根据id删除程序*/void delDeploySoftwareInfo(List ids);
}

XML:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper   PUBLIC "-//mybatis.org//DTD Mapper 3.1//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 软件信息数据查询相关  -->
<mapper namespace="com.dnion.platform.dao.mybatis.DeploySoftwareInfoMapper"><resultMap type="DeploySoftwareInfo" id="DeploySoftwareInfoResult"><id column="id" jdbcType="INTEGER" property="id"/><result column="soft_name" jdbcType="VARCHAR" property="softName"/><result column="install_path" jdbcType="VARCHAR" property="installPath"/><result column="soft_desc" jdbcType="VARCHAR" property="softDesc"/><!-- 关联软件详情集合 --><collection property="deploySoftwareDetailList" ofType="deploySoftwareDetail"column="id"><id column="id" jdbcType="INTEGER" property="id" /><result column="sw_id" jdbcType="INTEGER" property="swId" /><result column="version_code" jdbcType="VARCHAR" property="versionCode" /><result column="release_date" jdbcType="VARCHAR" property="releaseDate" /><result column="package_name" jdbcType="VARCHAR" property="packageName" /><result column="package_size" jdbcType="INTEGER" property="packageSize" /><result column="package_md5" jdbcType="VARCHAR" property="packageMD5" /><result column="major_files" jdbcType="VARCHAR" property="majorFiles" /><result column="release_note" jdbcType="VARCHAR" property="releaseNote" /></collection></resultMap><select id="getSoftwareInfoList" resultMap="DeploySoftwareInfoResult">SELECT *FROM deploy_software_info WHERE 1=1<if test="likeSoftName != null">AND soft_name like #{likeSoftName}</if></select><select id="getSoftwareInfoById" resultMap="DeploySoftwareInfoResult">SELECT * FROM deploy_software_infoWHERE id = #{id}</select><insert id="addSoftwareInfo" parameterType="DeploySoftwareInfo" useGeneratedKeys="true" keyProperty="id">INSERT INTO deploy_software_info (soft_name,install_path,soft_desc)VALUES (#{softName},#{installPath},#{softDesc})</insert><update id="updateSoftwareInfo" parameterType="DeploySoftwareInfo">UPDATE deploy_software_info SET soft_name = #{softName},install_path = #{installPath},soft_desc = #{softDesc}WHERE id = #{id}</update><select id="hasExists" resultType="INTEGER">SELECT count(1) FROM deploy_software_infoWHERE soft_name = #{softName}</select><delete id="delDeploySoftwareInfo" >DELETE FROM deploy_software_infoWHERE id IN<foreach collection="list" open="(" separator="," close=")" item="item">#{item}</foreach></delete>
</mapper>

Easyui+Spring+Mybatis完整示例(后台)相关推荐

  1. Easyui+Spring+Mybatis完整示例(前台)

    典型的Easyui+Spring+Mybatis例子,方便自己的记忆. JSP: <%@ page language="java" contentType="tex ...

  2. Spring Integration完整示例

    本文是我们名为" Spring Integration for EAI "的学院课程的一部分. 在本课程中,向您介绍了企业应用程序集成模式以及Spring Integration如 ...

  3. Eclipse+Maven+Struts2+Spring+Mybatis完整搭建

    一.前言 公司框架是SSH,hibernate用的越来越少,做了几年后,也懒得用了,springjdbc玩到现在,maven,mybatis没用到一直都没去接触,感慨现在技术真是发展越来越快,有点落伍 ...

  4. Spring集成MyBatis完整示例

    https://www.cnblogs.com/dongying/p/4142476.html https://www.cnblogs.com/best/p/5648740.html w3cschoo ...

  5. mysql+xml+注释,springboot整合mybatis完整示例, mapper注解方式和xml配置文件方式实现(我们要优雅地编程)...

    一.注解方式 pom org.mybatis.spring.boot mybatis-spring-boot-starter 2.0.0 mysql mysql-connector-java org. ...

  6. Spring MVC 完整示例

    在本例中,我们将使用Spring MVC框架构建一个入门级web应用程序.Spring MVC 是Spring框架最重要的的模块之一.它以强大的Spring IoC容器为基础,并充分利用容器的特性来简 ...

  7. Spring + iBATIS完整示例

    来源:http://blog.csdn.net/randyjiawenjie/article/details/7529314 最近研究了一下spring + iBATIS.发现看别人的例子是一回事,自 ...

  8. Java SSM springmvc spring mybatis 集代码生成器 后台框架源码

    A代码编辑器,在线模版编辑,仿开发工具编辑器,pdf在线预览,文件转换编码 B 集成代码生成器 (单表.主表.明细表.树形表,快速开发利器)+快速表单构建器 freemaker模版技术 ,0个代码不用 ...

  9. EasyUI(2):PHP+EasyUI的增、删、改操作的完整示例

    想完成一个EasyUI+PHP的完整示例,主要针对一个数据表记录的增加.删除和修改,方便以后写类似的程序. 经过一天多的努力,差不多算完成了,只是后台数据操作部分了. 初始界面: 添加记录: 正确提交 ...

最新文章

  1. lsof 查看一个进程打开哪些fd及对应的文件或套接字操作
  2. 老赖凭本事骗钱,你有本事不被骗吗?
  3. 第三章 染色动力学理论单元测试
  4. java学习(90):Character方法大小写转换
  5. Java:使用 Java 开发的一个异常处理框架
  6. Clojure 学习入门(16)- 正则表达式
  7. git 生成多个patch_git生成Patch和打Patch
  8. 佳博热敏打印机修改ip工具_佳博打印机修改ip教程本教程适用于80系列打印机及3150,9035打印.doc...
  9. 通过经纬度调用百度sdk api实现查询详细地址 Java
  10. 0基础怎么自学软件测试?
  11. discuz 获取会员头像
  12. 华为防火墙(NGFW)的双机热备
  13. linux分区安装win7,安装linuxmint与win7双系统的经验
  14. AndroidSDK开发6我用kotlin协程写了一个简单sdk
  15. 多目标优化(一)简单的 NSGA-Ⅱ
  16. (六) 更新glibc版本
  17. TensorFlow图片分类示例
  18. 升级 Ubuntu Linux 内核的几种不同方法 | Linux 中国
  19. java drawstring 截断_java中怎要用线程不断重写drawstring 方法
  20. MSP430vsSTM32,你会选择哪个进行项目开发?

热门文章

  1. 如何用法向量求点到平面距离_支持向量机(SVM)
  2. 极光推送指定用户推送_干货|SpringBoot集成极光推送完整实现代码(建议收藏)...
  3. qgis在地图上画导航线_在Laravel中的航线
  4. python数据分析与可视化-Python数据分析与数据可视化
  5. 实验一 线性表的顺序存储与实现_数据结构篇之单链表的创建以及实现
  6. python变量 数据类型 列表 元组 字典
  7. 计算机英语论文摘要,求英语高手翻译论文摘要,非常感谢!
  8. android layout_width 属性,android:layout_weight属性详解
  9. cisc 和 risc_RISC和CISC | 电脑组织
  10. Java ClassLoader findLibrary()方法与示例