客户管理–删除客户
具有删除客户的规则如下
1.实现效果
1.1 管理员操作效果
1.2 业务员操作效果
删除成功~
2.实现步骤
2.1 CustomerDto
2.2 新增视图(v_customer_order_num)
SELECT customer_id,count(1) num
FROM t_order
GROUP BY customer_id
2.3 修改视图(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
,ifnull(t4.num,0) num
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
left join v_customer_order_num t4
on t1.customer_id = t4.customer_id
2.4 customer.jsp页面
<shiro:hasAnyRoles name="业务员,操作员">
<c:if test="${dto.orderNum eq 0 }">
<a href="javascript:void(0)" onclick="deleteUser(${dto.customer.customerId})"
class="tablelink"> 删除</a></td>
</c:if>
</shiro:hasAnyRoles>
// .......
function deleteUser(userId){
if(window.confirm("确定要删除该用户吗?")){
location.href="/customer/delete?id="+userId;
}
}
2.5 CustomerController
@RequestMapping("/delete")
public String delete(Integer id) throws IOException{
customerService.deleteCustomer(id);
return "customer/query";
}
2.6 ICustomerService
public void deleteCustomer(Integer id);
2.7 CustomerServiceImpl
@Override
public void deleteCustomer(Integer id) {
// TODO Auto-generated method stub
customerMapper.deleteByPrimaryKey(id);
}