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. 使 ...
随机推荐
- JAVA编程思想第二章答案
欢迎访问我的CSDN博客查看https://mp.csdn.net/mdeditor/94797839# 有其他问题欢迎发送邮箱至hpzhangjunjiell@163.com 感谢
- mysql: error while loading shared libraries: libnuma.so
安装mysql后,执行初始化配置脚本,创建系统自带的数据库和表时报异常: [root@VM_0_12_centos mysql]# scripts/mysql_install_db --basedir ...
- 【洛谷1361】 小M的作物(最小割)
传送门 洛谷 Solution 这是一个比较实用的套路,很多题目都有用,而且这个套路难以口胡出来. 考虑把每一个附加贡献重新建一个点,然后向必需的点连边,流量为val. 然后直接种植的从源点向这个点连 ...
- JVM模型及内存溢出
一.JVM截图及概念 图1:JVM虚拟机运行时数据区域概念模型 1.程序计数器:内存空间中的一块小区域,作为当前线程所执行的字节码的行号指示器,注:如果是native方法,计数器为空 2.虚拟机栈:线 ...
- javascript实现集合Set、字典Dictionary、HashTable
集合是由一组无序且唯一(即不能重复)的项组成的.这个数据结构使用了与有限集合相同的数学概念,但应用在计算机科学的数据结构中. function Set() { this.items = {}; } S ...
- LeetCode 25. k个一组翻转链表(Reverse Nodes in k-Group)
题目描述 给出一个链表,每 k 个节点一组进行翻转,并返回翻转后的链表. k 是一个正整数,它的值小于或等于链表的长度.如果节点总数不是 k 的整数倍,那么将最后剩余节点保持原有顺序. 示例 : 给定 ...
- Python 生成随机数函数和加密函数(MD5)
内容来自debugtalk import hashlib import random import string def gen_random_string(str_len): '''生成指定长度的随 ...
- koa 项目实战(十一)验证登录和注册的 input
1.验证注册参数 根目录/validation/register.js const Validator = require('validator'); const isEmpty = require( ...
- leetcode-hard-ListNode-148. Sort List
mycode 97.37% 如果用上一个题目中”参考“的方法,res中放节点而不是val,就会超时 # Definition for singly-linked list. # class Li ...
- ubuntu16.04下如何安装mkimage工具?
答: sudo apt-get install u-boot-tools -y