好好编程-物流项目19【客户管理-更新客户】

简介: 好好编程-物流项目19【客户管理-更新客户】

客户管理

更新客户

 更新规则如下

image.png

1.实现效果

1.1 业务员操作效果

image.pngimage.png

1.2 管理员操作效果

image.pngimage.png

2.实现步骤

2.1 customer.jsp

 改变修改按钮的地址信息

<a href="/customer/customerUpdate?id=${dto.customer.customerId }" class="tablelink">修改</a> 

2.2 CustomerController

 内容不用改变,和添加的时候一样

@RequestMapping("/customerUpdate")
public String customerUpdate(Integer id,Model model){
  customerService.getUpdateInfo(id, model);
  return "customer/customerUpdate";
}

2.2 CustomerServiceImpl

 注意:和添加时有调整

/**
 * 新增客户
 *    查询 所有的角色是业务员的用户
 *    查询 常用区间 基础数据
 * 修改客户
 *        查询 所有的角色是业务员的用户
 *    查询 常用区间 基础数据
 *    根据客户ID 查询详细信息
 */
@Override
public void getUpdateInfo(Integer id, Model m) {
  // 1.查询所有具有业务员角色的用户信息
  List<User> users = userService.queryUserByRoleName(Constant.ROLE_SALESMAN);
  // 2.查询 常用区间的基础数据
  List<BasicData> intervals = basicService.getBasicDataByParentName(Constant.BASIC_COMMON_INTERVAL);
  if(id!=null && id > 0){
    Customer customer = new Customer();
    customer.setCustomerId(id);
    // 查询更新需要的数据
    List<CustomerDto> list = customerMapper.queryView(customer);
    if(list != null&& list.size()==1){
      m.addAttribute("dto", list.get(0));
    }
  }
  m.addAttribute("users", users);
  m.addAttribute("intervals", intervals);
}

image.png

2.3 CustomerMapper.xml

 给queryView添加了查询条件

  <select id="queryView" resultMap="baseCustomerDto" parameterType="com.bobo.pojo.Customer" >
    select 
        t1.customer_id
      ,t1.customer_name
      ,t1.address
      ,t1.c_sex
      ,t1.email
      ,t1.base_id
      ,t1.id_card
      ,t1.mobile_phone
      ,t1.order_id
      ,t1.remark
      ,t1.user_id
      ,t1.user_name
      ,t1.real_name
      ,t1.base_name 
    from v_customer t1
    <where>
      <if test="userId !=null and userId > 0">
        user_id = #{userId}
      </if>
      <if test="customerId !=null and customerId > 0 ">
        customer_id = #{customerId}
      </if>
    </where>
  </select>

image.png

2.4 customerUpdate.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="/css/style.css" rel="stylesheet" type="text/css" />
<link href="/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="/js/select-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
    width : 345       
  });
  $(".select2").uedSelect({
    width : 167  
  });
  $(".select3").uedSelect({
    width : 100
  });
});
</script>
</head>
<body>
  <div class="place">
    <span>位置:</span>
    <ul class="placeul">
      <li><a href="/">首页</a></li>
      <li><a href="/user/query">客户管理</a></li>
    </ul>
  </div>
  <div class="formbody">
    <div class="formtitle">
      <span>新增客户信息</span>
    </div>
    <form action="/customer/saveOrUpdate">
      <ul class="forminfo">
        <input type="hidden" name="customerId" value="${dto.customer.customerId}">
        <li><label>客户姓名</label>
          <input name="customerName"  type="text" value="${dto.customer.customerName}" class="dfinput" />
          <i></i>
        </li>
        <li><label>客户电话</label>
          <input name="mobilePhone" type="text" value="${dto.customer.mobilePhone}" class="dfinput" />
        </li>
        <li><label>性别 ${dto.customer.cSex}</label>
          <input type="radio" name="cSex" value="0"  ${dto.customer.cSex eq true?"checked":"" }>&nbsp;男 
          <input type="radio" name="cSex" value="1" ${dto.customer.cSex eq false?"checked":"" }>&nbsp;女
        </li>
        <li><label>电子邮箱</label>
          <input name="email" type="text" class="dfinput" value="${dto.customer.email}"/><i></i>
        </li>
        <li><label>通讯地址</label>
          <input name="address" type="text" class="dfinput"  value="${dto.customer.address}"/><i></i>
        </li>
        <li><label>身份证号码</label>
          <input name="idCard" type="text" class="dfinput"  value="${dto.customer.idCard}"/><i></i>
        </li>
        <li><label>业务员</label>
          <div class="vocation">
              <select class="select1" name="userId">
              <!-- 和新增客户区分开 -->
              <c:if test="${empty dto}">
                <c:forEach items="${ users}" var="user">
                  <option value="${user.userId }" >
                    ${user.realName }
                  </option>
                </c:forEach>
              </c:if>
              <c:if test="${not empty dto }">
                <shiro:hasAnyRoles name="业务员,操作员">
                  <option value="${dto.customer.userId }" >${dto.salesMan }</option>
                </shiro:hasAnyRoles>
                <shiro:hasRole name="管理员">
                  <c:forEach items="${ users}" var="user">
                    <option value="${user.userId }" ${user.userId eq dto.customer.userId?"selected":"" } >
                      ${user.realName }
                    </option>
                  </c:forEach>
                </shiro:hasRole>
              </c:if>
              </select>
          </div>
          <i></i>
        </li>
        <li><label>常用区间</label>
          <div class="vocation">
              <select class="select1" name="baseId">
              <c:forEach items="${ intervals}" var="it">
                <option value="${it.baseId }" ${it.baseId eq dto.customer.baseId?"selected":"" }>
                  ${it.baseName }
                </option>
              </c:forEach>
              </select>
          </div>
          <i></i>
        </li>
         <li><label>备注</label>
          <textarea name="remark" cols="" rows="" class="textinput" >
            ${dto.customer.remark }
          </textarea>
         </li>
        <li><label>&nbsp;</label>
          <input name="" type="submit"
          class="btn" value="确认保存" /></li>
        </ul>
    </form>
  </div>
  <div style="display: none">
    <script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540'
      language='JavaScript' charset='gb2312'></script>
  </div>
</body>
</html>

2.5 CustomerController

 保存修改的内容

@RequestMapping("/saveOrUpdate")
public String saveOrUpdate(Customer customer) throws IOException{
  if(customer.getCustomerId()!=null && !"".equals(customer.getCustomerId())){
    // 更新
    customerService.updateCustomer(customer);
  }else{
    // 添加
    customerService.addCustomer(customer);
  }
  return "success";
}

image.png

2.6 ICustomerService

public void updateCustomer(Customer customer)

2.7 CustomerServiceImpl

@Override
public void updateCustomer(Customer customer) {
  // TODO Auto-generated method stub
  customerMapper.updateByPrimaryKey(customer);
}

ok 实现~


相关文章
|
8月前
|
安全
什么是互助预约排单系统开发丨dapp预约排单互助项目系统开发详细流程/规则方案/案例设计/逻辑功能/源码开发
Allow users to register accounts and perform identity verification to ensure the authenticity and credibility of user information.
|
10月前
|
供应链 数据可视化
只用2个小时,我把公司的进销存流程全部搬到了线上!
只用2个小时,我把公司的进销存流程全部搬到了线上!
|
10月前
|
安全 区块链 数据库
互助拍卖竞拍抢单模式系统开发项目方案丨DAPP拍卖竞拍抢拍互助系统开发(案例开发)/开发逻辑/源码运营版
    dapp的开发和运行基于智能合约,智能合约是一种运行在区块链上的自动执行合约,它可以实现自动化的交易和管理逻辑,And automatically supervise and execute according to the set rules.Dapp achieves decentralized data storage,business logic,and value exchange through smart contracts.
|
12月前
|
API 区块链 数据安全/隐私保护
为什么应用程序开发人员想要一个区块链支付解决方案
为什么应用程序开发人员想要一个区块链支付解决方案
|
搜索推荐 SEO
外贸业务客户开发「途径详情」
扩大找客户的各种途径和方法,例如通过skype. facebook, google. B2B平台、展会,外贸开发客户软件,广交会买家数据,或者是通过海关数据找客户。
164 0
|
SQL JSON 前端开发
校园外卖点餐系统——Day02【员工管理业务开发】
校园外卖点餐系统——Day02【员工管理业务开发】
125 0
校园外卖点餐系统——Day02【员工管理业务开发】
|
开发者 容器
招聘管理综合实践——审批结果更新|学习笔记
快速学习招聘管理综合实践——审批结果更新
100 0
招聘管理综合实践——审批结果更新|学习笔记
好好编程-物流项目20【客户管理-删除客户】
好好编程-物流项目20【客户管理-删除客户】
好好编程-物流项目20【客户管理-删除客户】
好好编程-物流项目17【客户管理-新增客户】
好好编程-物流项目17【客户管理-新增客户】
好好编程-物流项目17【客户管理-新增客户】
好好编程-物流项目18【客户管理-查询客户】
好好编程-物流项目18【客户管理-查询客户】
好好编程-物流项目18【客户管理-查询客户】