美文网首页
SpringMVC_CRM系统_修改数据5

SpringMVC_CRM系统_修改数据5

作者: 大鹏_xzlp | 来源:发表于2017-11-12 21:26 被阅读0次

数据展示出来了,我们接下来进行修改页面数据

  1. 点击修改,在弹出框中要先把用户信息填充进去,需要一个详情接口,我们先来在dao中添加一个方法
    CustomerDao:
 Customer queryCustomerById(Long id);

CustomerDao.xml:

    <select id="queryCustomerById" parameterType="long" resultType="Customer">
        SELECT * FROM customer WHERE cust_id = #{id}
    </select>

Service中增加对应的方法

    public Customer queryCustomerById(Long id){
        return this.customerDao.queryCustomerById(id);
    }

Controller中实现调用

    @RequestMapping("/customer/edit")
    @ResponseBody
    public Customer queryCustomerList(@RequestParam Long id) {
        return this.customerService.queryCustomerById(id);
    }

根据接口返回的数据填充页面


  1. 点击保存修改,调用修改接口,我们先去定义dao中的update方法
    CustomerDao:
    void updateCustomer(Customer customer);

CustomerDao.xml:

<select id="updateCustomer" parameterType="Customer">

        UPDATE `customer`
        SET
        <if test="cust_name !=null and cust_name != ''">
            `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 and cust_source != ''">
            `cust_source` = #{cust_source},
        </if>
        <if test="cust_industry !=null and cust_industry != ''">
            `cust_industry` = #{cust_industry},
        </if>
        <if test="cust_level !=null and cust_level != ''">
            `cust_level` = #{cust_level},
        </if>
        <if test="cust_linkman !=null and cust_linkman != ''">
            `cust_linkman` = #{cust_linkman},
        </if>
        <if test="cust_phone !=null and cust_phone != ''">
            `cust_phone` = #{cust_phone},
        </if>
        <if test="cust_mobile !=null and cust_mobile != ''">
            `cust_mobile` = #{cust_mobile},
        </if>
        <if test="cust_zipcode !=null and cust_zipcode != ''">
            `cust_zipcode` = #{cust_zipcode},
        </if>
        <if test="cust_address !=null and cust_address != ''">
            `cust_address` = #{cust_address},
        </if>
        `cust_createtime` = NOW()
        WHERE
        (`cust_id` = #{cust_id});
    </select>

在Service定义方法

   public void updateCustomer(Customer customer){
       this.customerDao.updateCustomer(customer);
   }

在Controller中实现接口

    @RequestMapping("/customer/update")
    @ResponseBody
    public String updateCustomer(Customer customer){
        System.out.println("updateCustomer");
        this.customerService.updateCustomer(customer);
        return "OK";
    }

这样页面修改完之后点击修改就OK了,后面还有一个删除,这里就不一步步说了,和修改类似,可以直接参考

总结

本系列到此结束,通过一个简单的小型系统来记录梳理一遍SpringMVC的整个开发流程。

本系列源码存放在github上 源码

相关文章

  • SpringMVC_CRM系统_修改数据5

    数据展示出来了,我们接下来进行修改页面数据 点击修改,在弹出框中要先把用户信息填充进去,需要一个详情接口,我们先来...

  • SpringMVC_CRM系统_页面加载数据4

    现在我们开始处理页面的数据显示 先填充这三个下拉框中的数据 新建service层 在CustomerControl...

  • 2018-11-27网站

    修改密码 系统设置——系统用户管理 数据库:单击其他选项菜单——单击phpmyadmin f297a57a5...

  • SpringMVC_CRM系统_配置数据库2

    数据库结构和建表语句我放在文章末尾了,下面我们开始配置数据库 在resources目录下新建 db.propert...

  • SpringMVC_CRM系统_环境搭建1

    准备做一个SpringMVC_CRM系统系列,本系列主要是演示使用SpringMVC+Mybatis来完整一个简单...

  • 三、PostgreSQL常用语句

    1、插入多条语句 2、清空表 3、查询当前系统时间 4、显示当前时区 5、查询可选的时区 6、修改数据库时区 修改...

  • 2019-06-21

    修改数据库系统。

  • Admin如何管理数据库数据?

    Admin系统中已经为管理员封装了一些常用的内容管理功能,如添加数据、删除数据、数据排序、修改数据。 在图6-5所...

  • Admin如何管理数据库数据?

    Admin系统中已经为管理员封装了一些常用的内容管理功能,如添加数据、删除数据、数据排序、修改数据。 在图6-5所...

  • 修改 centos docker镜像的时区

    修改 centos docker镜像的时区 Intro 有时系统可能需要修改系统的时区才能正常工作,否则显示的数据...

网友评论

      本文标题:SpringMVC_CRM系统_修改数据5

      本文链接:https://www.haomeiwen.com/subject/mlfomxtx.html