好好编程-物流项目18【客户管理-查询客户】

简介: 好好编程-物流项目18【客户管理-查询客户】

客户管理

查询客户

 客户操作规则

image.png

 业务员只能查看属于自己的客户,操作员和管理员可以查看所有的客户。

image.png

1.常量

image.png

2.创建V_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
      ,t2.user_name
      ,t2.real_name
      ,t3.base_name
from t_customer t1
  left join t_user t2
     on t1.user_id = t2.user_id 
  left join t_basicdata t3
      on t1.base_id = t3.base_id

通过视图将对应的业务员姓名和常用区间信息查询了出来,便于展示数据

3.CustomerDto创建

image.png

package com.bobo.dto;
import com.bobo.pojo.Customer;
/**
 * 客户的数据传输对象
 * 
 * @author 波波烤鸭
 *
 * dengpbs@163.com
 */
public class CustomerDto extends BasePage{
  private Customer customer;
  // 业务员
  private String salesMan;
  // 常用区间
  private String interval;
  public Customer getCustomer() {
    return customer;
  }
  public void setCustomer(Customer customer) {
    this.customer = customer;
  }
  public String getSalesMan() {
    return salesMan;
  }
  public void setSalesMan(String salesMan) {
    this.salesMan = salesMan;
  }
  public String getInterval() {
    return interval;
  }
  public void setInterval(String interval) {
    this.interval = interval;
  }
}


4.CustomerMapper.xml

  <resultMap type="com.bobo.dto.CustomerDto" id="baseCustomerDto">
    <id column="customer_id" jdbcType="INTEGER" property="customer.customerId" />
    <result column="order_id" jdbcType="INTEGER" property="customer.orderId" />
    <result column="base_id" jdbcType="INTEGER" property="customer.baseId" />
    <result column="user_id" jdbcType="INTEGER" property="customer.userId" />
    <result column="customer_name" jdbcType="VARCHAR" property="customer.customerName" />
    <result column="mobile_phone" jdbcType="BIGINT" property="customer.mobilePhone" />
    <result column="email" jdbcType="VARCHAR" property="customer.email" />
    <result column="address" jdbcType="VARCHAR" property="customer.address" />
    <result column="id_card" jdbcType="VARCHAR" property="customer.idCard" />
    <result column="c_sex" jdbcType="BIT" property="customer.cSex" />
    <result column="remark" jdbcType="VARCHAR" property="customer.remark" />
    <result column="real_name" jdbcType="VARCHAR" property="salesMan" />
    <result column="base_name" jdbcType="VARCHAR" property="interval" />
  </resultMap>
  <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>
    </where>
  </select>

5.CustomerMapper.java

List<CustomerDto> queryView(Customer record);

6.service层

接口

/**
* 分页查询
 * @param dto
 * @return
 */
public PageInfo<CustomerDto> queryPage(CustomerDto dto,User user);

实现

/**
 * 当前用户如果是  业务员 只能查看所属的客户
 * 如果是 操作员 或者 管理员 能查看所有的客户
 */
@Override
public PageInfo<CustomerDto> queryPage(CustomerDto dto,User user) {
  PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
  // 获取角色信息
  List<Role> list = userService.queryRoleByUserId(user.getUserId());
  boolean flag = false;
  if(list != null && list.size() > 0){
    for (Role role : list) {
      if(Constant.ROLE_ADMIN.equals(role.getRoleName()) 
          || Constant.ROLE_OPERATOR.equals(role.getRoleName())){
        // 拥有操作员或者管理员的身份,查询所有的客户信息
        flag = true;
        break;
      }
    }
  }
  // 业务员 限制查询
  Customer customer = new Customer();
  if(flag == false){
    customer.setUserId(user.getUserId());
  }
  List<CustomerDto> customers = customerMapper.queryView(customer);
  return new PageInfo<>(customers);
}

7.控制器

@RequestMapping("/query")
public String query(CustomerDto dto,Model model){
  // 获取登录用户信息
  User user = (User) SecurityUtils.getSubject().getPrincipal();
  System.out.println("--->"+user.getUserId());
  PageInfo<CustomerDto> list = customerService.queryPage(dto,user);
  model.addAttribute(Constant.PAGE_MODEL, list);
  return "customer/customer";
}

8.Customer.jsp

image.png

<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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" />
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $(".click").click(function() {
      $(".tip").fadeIn(200);
    });
    $(".tiptop a").click(function() {
      $(".tip").fadeOut(200);
    });
    $(".sure").click(function() {
      $(".tip").fadeOut(100);
    });
    $(".cancel").click(function() {
      $(".tip").fadeOut(100);
    });
  });
</script>
</head>
<body>
  <div class="place">
    <span>位置:</span>
    <ul class="placeul">
      <li><a href="#">首页</a></li>
      <li><a href="#">数据表</a></li>
      <li><a href="#">基本内容</a></li>
    </ul>
  </div>
  <div class="rightinfo">
    <div class="tools">
      <ul class="toolbar">
        <li class="click">
          <a href="userUpdate">
            <span>
                <img src="/images/t01.png" />
            </span>
            添加
          </a>
        </li>
        <li class="click"><span><img src="/images/t02.png" /></span>修改</li>
        <li><span><img src="/images/t03.png" /></span>删除</li>
        <li><span><img src="/images/t04.png" /></span>统计</li>
      </ul>
      <ul class="toolbar1">
        <li><span><img src="/images/t05.png" /></span>设置</li>
      </ul>
    </div>
    <table class="tablelist">
      <thead>
        <tr>
          <th><input name="" type="checkbox" value="" checked="checked" /></th>
          <th>编号<i class="sort"><img src="/images/px.gif" /></i></th>
          <th>客户姓名</th>
          <th>客户电话</th>
          <th>邮箱</th>
          <th>性别</th>
          <th>业务员</th>
          <th>常用区间</th>
          <th>身份证号</th>
          <th>通讯地址</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <c:forEach items="${pageModel.list }" var="dto">
          <tr>
            <td><input name="" type="checkbox" value="" /></td>
            <td>${dto.customer.customerId }</td>
            <td>${dto.customer.customerName }</td>
            <td>${dto.customer.mobilePhone }</td>
            <td>${dto.customer.email }</td>
            <td>${dto.customer.cSex eq true?"男":"女" }</td>
            <td>${dto.salesMan }</td>
            <td>${dto.interval }</td>
            <td>${dto.customer.idCard}</td>
            <td>${dto.customer.address }</td>
            <td>
              <a href="/user/userUpdate?id=${dto.customer.customerId }" 
              class="tablelink">修改</a> 
              <a href="javascript:void(0)" onclick="deleteUser(${dto.customer.customerId})" 
              class="tablelink"> 删除</a></td>
          </tr>
        </c:forEach>
      </tbody>
    </table>
      <div class="inline pull-right page" style="margin-top: 20px;">
        <form action="/user/queryPage" id="pager">
          <input type="hidden" name="pageSize" id="pageSize" value="${pageModel.pageSize }">
          <input type="hidden" name="pageNum" id="pageNum" value="${pageModel.pageNum }">
        </form>
        <jsp:include page="/pageBar.jsp"></jsp:include>
      </div>
  </div>
  <script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
    function deleteUser(userId){
      if(window.confirm("确定要删除该用户吗?")){
        location.href="/user/delete?id="+userId;
      }
    }
  </script>
</body>
</html>

9.访问测试

业务员访问

管理员访问

image.png

image.png

完成~~


相关文章
好好编程-物流项目20【客户管理-删除客户】
好好编程-物流项目20【客户管理-删除客户】
好好编程-物流项目20【客户管理-删除客户】
好好编程-物流项目19【客户管理-更新客户】
好好编程-物流项目19【客户管理-更新客户】
好好编程-物流项目19【客户管理-更新客户】
好好编程-物流项目17【客户管理-新增客户】
好好编程-物流项目17【客户管理-新增客户】
好好编程-物流项目17【客户管理-新增客户】
|
SQL JSON 前端开发
校园外卖点餐系统——Day02【员工管理业务开发】
校园外卖点餐系统——Day02【员工管理业务开发】
167 0
校园外卖点餐系统——Day02【员工管理业务开发】
|
搜索推荐 SEO
外贸业务客户开发「途径详情」
扩大找客户的各种途径和方法,例如通过skype. facebook, google. B2B平台、展会,外贸开发客户软件,广交会买家数据,或者是通过海关数据找客户。
250 0
|
监控 搜索推荐 数据挖掘
如何使用海关数据准确开发到客户
海关数据其实一直是外贸应用中最广泛的开发渠道,而且特别利好初学者,是企业开发新客户、监控同行、维护老客户以及决策参考的商战利器。当然,想通过海关数据精确找到客户,需要熟悉以下操作技巧。
272 0
|
网络协议 测试技术 Go
客户管理系统-修改客户和作业|学习笔记
快速学习客户管理系统-修改客户和作业
|
2月前
|
存储 供应链 数据可视化
宠物公司双旦备战,何种办公软件可优化库存管理?
在冬季双旦节期间,宠物行业的业务量激增,高效的团队协作和学习效率至关重要。合适的办公软件能助力企业在需求预测、库存管理、营销策划等方面顺畅运营。本文推荐6款可视化团队协作办公软件:板栗看板、Trello、Asana、飞书、腾讯文档和石墨文档。这些软件各具特色,如板栗看板的直观数据呈现、Trello的插件拓展、Asana的强大项目管理、飞书的实时协作文档、腾讯文档的便捷模板和石墨文档的深度协作功能,帮助宠物企业提升工作效率,实现业绩增长。
51 5
|
2月前
|
存储 搜索推荐 数据可视化
提升签单效率:CRM系统在客户签约管理中的关键作用
在竞争激烈的商业环境中,CRM系统作为企业销售和客户服务的核心工具,对签单速度的提升至关重要。本文探讨了CRM系统如何通过集中管理客户信息、可视化销售漏斗、自动化工作流程、个性化营销策略、数据分析与洞察、跨部门协作、移动办公便捷性和快速响应客户反馈等八大方面,有效加速签单过程,提高销售效率。

热门文章

最新文章