Boot-crm管理系统开发教程(三)
(ps:前两章我们已经把管理员登录和查看用户的功能实现了,那么今天我们将要实现:添加用户,删除用户,和修改用户功能)
由于Cusomer的POJO类型已经写好了,所以这次我们之前从CustomerController下手!!!
添加用户功能
①在CutsomerController类中编写customerCreate方法,并在方法名上头写上请求映射路径(@RequestMapping("/customer/create.action")) ,和@ResponseBody。
②在customerCreate方法中先获取用户session,然后将当前用户id存储在客户对象中,然后调用customer.setCust_create_id()方法将当前用户id存储在客户对象中,接着为了得到mysql里面的时间戳,我们用了Timestamp对象获取一个yyyy/MM/dd
HH:mm:ss
的时间格式,然后将这个Timestamp对象装载到customer.setCust_createtime()方法中,最后再判断Service层中受影响的行数来判断是否创建用户成功,这样我们CustomerController中的创建客户就写完了,还记得第二章教程中的流程图吗?现在我们就得去Service层中编写接口,并实现接口类。
③在CustomerService接口中创建createCustomer方法(注意此处的返回值类型是int类型),然后去CustomerServiceImpl实现类中实现该接口方法。
④在CustomerDao接口中也同样编写createCustomer方法,然后在CustomerDao.xml中编写添加客户的sql语句,代码如下:
<!-- 添加客户 -->
<insert id="createCustomer" parameterType="customer">
insert into customer(
cust_name,
cust_user_id,
cust_create_id,
cust_source,
cust_industry,
cust_level,
cust_linkman,
cust_phone,
cust_mobile,
cust_zipcode,
cust_address,
cust_createtime
)
values(#{cust_name},
#{cust_user_id},
#{cust_create_id},
#{cust_source},
#{cust_industry},
#{cust_level},
#{cust_linkman},
#{cust_phone},
#{cust_mobile},
#{cust_zipcode},
#{cust_address},
#{cust_createtime}
)
</insert>
⑤写到这里,我们的添加用户的功能就写完了。回顾一下我们是怎么写的:"首先我们是从CustomerController下手的!在该方法中我们创建了createCustomer方法,然后再到Service层中编写createCustomer该接口方法,然后让CustomerServiceImpl实现类去实现它,最后在回到CustomerDao中创建同样的方法,然后重点是在CustomerDao.xml中的sql语句"。
更新用户功能,删除用户功能
/*
* 更新客户
*/
@RequestMapping("/customer/update.action")
@ResponseBody
public String customerUpdate(Customer customer)
{
int rows=customerService.updateCustomer(customer);
if(rows>0)
{
return "OK";
}else {
return "FAIL";
}
}
/*
* 删除客户
*/
@RequestMapping("/customer/delete.action")
@ResponseBody
public String customerDelete(Integer id)
{
int rows=customerService.deleteCustomer(id);
if(rows>0)
{
return "OK";
}else {
return "FAIL";
}
}
XML:
<!-- 更新客户 -->
<update id="updateCustomer" parameterType="customer">
update customer
<set>
<if test="cust_name!=null">
cust_name=#{cust_name},
</if>
<if test="cust_user_id!=null">
cust_user_id=#{cust_user_id},
</if>
<if test="cust_create_id!=null">
cust_create_id=#{cust_create_id},
</if>
<if test="cust_source!=null">
cust_source=#{cust_source},
</if>
<if test="cust_industry!=null">
cust_industry=#{cust_industry},
</if>
<if test="cust_level!=null">
cust_level=#{cust_level},
</if>
<if test="cust_linkman!=null">
cust_linkman=#{cust_linkman},
</if>
<if test="cust_phone!=null">
cust_phone=#{cust_phone},
</if>
<if test="cust_mobile!=null">
cust_mobile=#{cust_mobile},
</if>
<if test="cust_zipcode!=null">
cust_zipcode=#{cust_zipcode},
</if>
<if test="cust_address!=null">
cust_address=#{cust_address},
</if>
<if test="cust_createtime!=null">
cust_createtime=#{cust_createtime},
</if>
</set>
where cust_id=#{cust_id}
</update>
<!-- 删除客户 -->
<delete id="deleteCustomer" parameterType="Integer">
delete from customer where cust_id=#{id}
</delete>
源码下载地址: Boot-crm管理系统源码下载
Boot-crm管理系统开发教程(三)的更多相关文章
- Boot-crm管理系统开发教程(总结)
这个Boot-crm管理系统我花了大概两周写完,因为是刚学完SSM框架,所以立马开始了这个项目,项目初期,运行书本上给的前端代码都报了许多错误,导致这个原因是因为书本给的 设计说明文档 没有看清楚.然 ...
- MIP开发教程(三) 使用MIP-CLI工具调试组件
一 . 在 mip-extensions 仓库中创建新的组件 二 . 预览调试组件 三 . 在 MIP 页中引用自己编写的 MIP 组件 四 . 组件提交到 GitHub 仓库时需要进行校验 站长开发 ...
- Boot-crm管理系统开发教程(一)
ps:上周就把这个项目写完了,一直忘记记录,现在补上. Boot-crm是书上第十八章的内容,书上提供了前端的代码,所以只需要写后端的代码就可以了,①所以我们先把前端的代码移植到项目中. ②然后在li ...
- Odoo 二次开发教程(三)-第一个Model及Form、Tree视图
创建完我们的模块,接下来我们就要为我们的模块添加一些对象.今天我们将要创建一个学生对象(tech.student)和一些基本的属性,并将用form和tree视图将其展示出来: 一. 创建tech.st ...
- XAF应用开发教程(三)业务对象模型之引用类型与关联关系
本节介绍信息系统开发中最常见的问题,引用关系,一对多关系,多对多关系. 以客户信息为例,客户通常需要客户分类,如VIP客户,普通客户,潜在客户.当然,我们可以定义枚举类型进行定义出这个类型,并在客户类 ...
- Boot-crm管理系统开发教程(二)
ps:昨天将管理员登录的功能完成了,并完美的解决跳过登录从而进入管理界面的bug,今天我们将实现"查询用户"功能. ①在po包中创建Customer类,并编写相关变量和添加set/ ...
- Android OpenGL ES 开发教程 从入门到精通
感谢,摘自:http://blog.csdn.net/mapdigit/article/details/7526556 Android OpenGL ES 简明开发教程 Android OpenGL ...
- 微信开放平台 公众号第三方平台开发 教程四 代公众号调用接口的SDK和demo
原文:微信开放平台 公众号第三方平台开发 教程四 代公众号调用接口的SDK和demo 教程导航: 微信开放平台 公众号第三方平台开发 教程一 平台介绍 微信开放平台 公众号第三方平台开发 教程二 创建 ...
- 开发教程(四) MIP组件平台使用说明
组件审核平台用于上传 MIP 组件.经过自动校验之后,提交审核,通过审核的组件会定时推送到线上,供网站使用. 平台地址:https://www.mipengine.org/platform/ 1. 使 ...
随机推荐
- (转载)IOCP 浅析
转自:http://www.ibm.com/developerworks/cn/java/j-lo-iocp/#author 郭 仁祥, 软件工程师, IBM 简介: 传统的 Server/Cli ...
- ionic3引用外部插件--百度地图及echart报表的使用
前言 ionic3提供的组件已经相当丰富咯,但是事实上有些特殊的需求,比如使用百度地图,或者第三方插件echart报表插件是,就不能用传统的方式去使用第三方插件咯,如何在Ionic3项目中使用第三方J ...
- ueditor 图片选区错位问题,图片无法正常缩放
当编辑框高度固定可内部滚动时,ueditor插入图片调节框显示bug 在使用百度euditor的编辑器时,我们常常需要让用户对插入的图片进行拉伸修改大小.当euditor的编辑框不随内容的增加而调节高 ...
- Bootstrap视频教程
一.全局CSS样式 0.课件 001.概览_栅格系统 2.排版和代码 3.表格和按钮 4.表单 5.图片 6.辅助类 7.响应式工具 二.组件 8.图标_下拉菜单_按钮组 9.输入框组 10.导航 1 ...
- Android7.0 API变更
Android N 除了提供诸多新特性和功能外,还对系统和 API 行为做出了各种变更. 本文重点介绍您应该了解并在开发应用时加以考虑的一些重要变更. 如果您之前发布过 Android 应用,请注意您 ...
- layer.js错误Uncaught TypeError: i is not a function
最初是要写一个管理后台来着,项目中需要用到弹出层,但是没有前端配合,我一个小PHP需要去写这玩意,怎么办呢?查了一些资料,发现layer对我来说还行,文档写的也比较完全,学习成本不高,就下决心用这个了 ...
- ant-design-pro中引入bizcharts报错:BizCharts is not defined 解决
解决方法: 在config.js 中的 externals 配置项中进行了如下配置修改: externals: { '@antv/data-set': 'DataSet', // bizcharts: ...
- 找不到FileProvider类怎么办?找不到R资源怎么办?APPT2错误怎么办?
坑2: 在使用上述解决方案时,需要加入android.support.v4.content.FileProvider这个类,当时我没有这个包.但是在引入相应的依赖包后,各种异常就出现了. 先是把And ...
- R语言 我要如何开始R语言_数据分析师
R语言 我要如何开始R语言_数据分析师 我要如何开始R语言? 很多时候,我们的老板跟我们说,这个东西你用R语言去算吧,Oh,My god!什么是R语言?我要怎么开始呢? 其实回答这个问题很简单,首先, ...
- C语言JS引擎
基础知识 SpiderMonkey 简介 和其他的 JavaScript 引擎一样,SpiderMonkey 不直接提供像 DOM 这样的对象,而是提供解析,执行 JavaSccript 代码,垃圾回 ...