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. 使 ...
随机推荐
- 预处理、const、static与sizeof-用宏定义得到一个字的高位和低位字节
1:代码如下: #define WORD_LO(XXX) ((byte) (word)(XXX) & 255) #define WORD_HI(XXX) ((byte) (word)(XXX) ...
- pytorch-VGG网络
VGG网络结构 第一层: 3x3x3x64, 步长为1, padding=1 第二层: 3x3x64x64, 步长为1, padding=1 第三层: 3x3x64x128, 步长为1, paddin ...
- LC 973. K Closest Points to Origin
We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the d ...
- handler四元素
Looper 一个线程可以产生一个Looper对象,由它来管理此线程里的MessageQueue(消息队列). 我们知道一个线程是一段可执行的代码,当可执行代码执行完成后,线程生命周期便会终止,线程就 ...
- Djang之ModelForm组件的简单使用
ModelForm组件的简单使用 models.py from django.db import models class UserInfo(models.Model): username = mod ...
- mysql 高性能日记之索引(持续更新)
本文仅限于自己读写的笔记,需要具有一定 mysql(inodb,myisam 引擎)基础的高端玩家,不感兴趣的玩家们就不用在意了 Inodb 引擎 1,每个新建索引,都需要考虑清楚看是否是必须的,很多 ...
- Linux命令集锦:ansible命令
ansible 命令主要用于批量管理,来实现自动化管理.常用批量操作包括:主机分组管理.实时批量执行命令或脚本.实时批量分发文件或目录.定时同步文件等. 一.安装 ansible yum instal ...
- 配置yum镜像源
centos7配置本地yum源 先从官网下载centos7镜像 以centos7.4 为例 CentOS-7-x86_64-Everything-1804 [root@kangvcar ~]# mv ...
- 关于LINQ中SELECT NEW 的问题
public static object SelectAnyInfo(){ DataAccessContext context = new DataAccessContext(); var ...
- Docker save and load镜像保存
持久化docker的镜像或容器的方法 Docker的镜像和容器可以有两种方式来导出 docker save #ID or #Name docker export #ID or #Name docker ...