AI智能工牌的门店管理, 销售管理 , 项目管理, 客户管理, 设备管理, 录音管理, 视频管理 ,代码骨架

This commit is contained in:
spllzh
2025-08-08 17:10:37 +08:00
parent bb031770be
commit 3e8ba9f6f1
40 changed files with 2701 additions and 12 deletions

View File

@@ -0,0 +1,291 @@
package com.rj.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rj.entity.CustomerManagement;
import com.rj.service.ICustomerManagementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* 客户管理表 前端控制器
* </p>
*
* @author 李中华 ,spllzh
* @since 2025-08-07
*/
@RestController
@RequestMapping("/api/customerManagement")
@Tag(name = "客户管理", description = "客户管理相关接口")
public class CustomerManagementController {
@Autowired
private ICustomerManagementService customerManagementService;
/**
* 新增客户
*/
@PostMapping("/add")
@Operation(summary = "新增客户", description = "添加新的客户信息")
public ResponseEntity<Map<String, Object>> addCustomer(
@Parameter(description = "客户信息", required = true)
@RequestBody CustomerManagement customerManagement) {
Map<String, Object> result = new HashMap<>();
try {
customerManagement.setCreateTime(LocalDateTime.now());
customerManagement.setUpdateTime(LocalDateTime.now());
boolean success = customerManagementService.save(customerManagement);
if (success) {
result.put("success", true);
result.put("message", "客户添加成功");
result.put("data", customerManagement);
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "客户添加失败");
return ResponseEntity.badRequest().body(result);
}
} catch (Exception e) {
result.put("success", false);
result.put("message", "客户添加异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 根据ID查询客户
*/
@GetMapping("/get/{id}")
@Operation(summary = "根据ID查询客户", description = "根据客户ID获取客户详细信息")
public ResponseEntity<Map<String, Object>> getCustomerById(
@Parameter(description = "客户ID", required = true)
@PathVariable String id) {
Map<String, Object> result = new HashMap<>();
try {
CustomerManagement customer = customerManagementService.getById(id);
if (customer != null) {
result.put("success", true);
result.put("message", "查询成功");
result.put("data", customer);
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "客户不存在");
return ResponseEntity.notFound().build();
}
} catch (Exception e) {
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 根据联系方式查询客户
*/
@GetMapping("/getByContact")
@Operation(summary = "根据联系方式查询客户", description = "根据客户联系方式查询客户信息")
public ResponseEntity<Map<String, Object>> getCustomerByContact(
@Parameter(description = "联系方式", required = true)
@RequestParam String contact) {
Map<String, Object> result = new HashMap<>();
try {
LambdaQueryWrapper<CustomerManagement> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CustomerManagement::getContact, contact);
List<CustomerManagement> customers = customerManagementService.list(queryWrapper);
result.put("success", true);
result.put("message", "查询成功");
result.put("data", customers);
result.put("count", customers.size());
return ResponseEntity.ok(result);
} catch (Exception e) {
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 分页查询客户列表
*/
@GetMapping("/list")
@Operation(summary = "分页查询客户列表", description = "分页查询客户信息列表")
public ResponseEntity<Map<String, Object>> getCustomerList(
@Parameter(description = "页码", example = "1")
@RequestParam(defaultValue = "1") Integer current,
@Parameter(description = "每页大小", example = "10")
@RequestParam(defaultValue = "10") Integer size,
@Parameter(description = "客户姓名(模糊查询)")
@RequestParam(required = false) String customerName,
@Parameter(description = "联系方式(模糊查询)")
@RequestParam(required = false) String contact,
@Parameter(description = "所属门店ID")
@RequestParam(required = false) String dealershipId) {
Map<String, Object> result = new HashMap<>();
try {
Page<CustomerManagement> page = new Page<>(current, size);
LambdaQueryWrapper<CustomerManagement> queryWrapper = new LambdaQueryWrapper<>();
// 添加查询条件
if (customerName != null && !customerName.trim().isEmpty()) {
queryWrapper.like(CustomerManagement::getCustomerName, customerName);
}
if (contact != null && !contact.trim().isEmpty()) {
queryWrapper.like(CustomerManagement::getContact, contact);
}
if (dealershipId != null && !dealershipId.trim().isEmpty()) {
queryWrapper.eq(CustomerManagement::getDealershipId, dealershipId);
}
// 按创建时间倒序排列
queryWrapper.orderByDesc(CustomerManagement::getCreateTime);
Page<CustomerManagement> customerPage = customerManagementService.page(page, queryWrapper);
result.put("success", true);
result.put("message", "查询成功");
result.put("data", customerPage.getRecords());
result.put("total", customerPage.getTotal());
result.put("current", customerPage.getCurrent());
result.put("size", customerPage.getSize());
result.put("pages", customerPage.getPages());
return ResponseEntity.ok(result);
} catch (Exception e) {
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 更新客户信息
*/
@PutMapping("/update")
@Operation(summary = "更新客户信息", description = "更新客户详细信息")
public ResponseEntity<Map<String, Object>> updateCustomer(
@Parameter(description = "客户信息", required = true)
@RequestBody CustomerManagement customerManagement) {
Map<String, Object> result = new HashMap<>();
try {
if (customerManagement.getId() == null || customerManagement.getId().trim().isEmpty()) {
result.put("success", false);
result.put("message", "客户ID不能为空");
return ResponseEntity.badRequest().body(result);
}
customerManagement.setUpdateTime(LocalDateTime.now());
boolean success = customerManagementService.updateById(customerManagement);
if (success) {
result.put("success", true);
result.put("message", "客户信息更新成功");
result.put("data", customerManagement);
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "客户信息更新失败");
return ResponseEntity.badRequest().body(result);
}
} catch (Exception e) {
result.put("success", false);
result.put("message", "更新异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 根据ID删除客户
*/
@DeleteMapping("/delete/{id}")
@Operation(summary = "删除客户", description = "根据客户ID删除客户信息")
public ResponseEntity<Map<String, Object>> deleteCustomer(
@Parameter(description = "客户ID", required = true)
@PathVariable String id) {
Map<String, Object> result = new HashMap<>();
try {
boolean success = customerManagementService.removeById(id);
if (success) {
result.put("success", true);
result.put("message", "客户删除成功");
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "客户删除失败");
return ResponseEntity.badRequest().body(result);
}
} catch (Exception e) {
result.put("success", false);
result.put("message", "删除异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 批量删除客户
*/
@DeleteMapping("/batchDelete")
@Operation(summary = "批量删除客户", description = "根据客户ID列表批量删除客户信息")
public ResponseEntity<Map<String, Object>> batchDeleteCustomers(
@Parameter(description = "客户ID列表", required = true)
@RequestBody List<String> ids) {
Map<String, Object> result = new HashMap<>();
try {
if (ids == null || ids.isEmpty()) {
result.put("success", false);
result.put("message", "客户ID列表不能为空");
return ResponseEntity.badRequest().body(result);
}
boolean success = customerManagementService.removeByIds(ids);
if (success) {
result.put("success", true);
result.put("message", "批量删除成功,共删除 " + ids.size() + " 条记录");
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "批量删除失败");
return ResponseEntity.badRequest().body(result);
}
} catch (Exception e) {
result.put("success", false);
result.put("message", "批量删除异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 获取客户统计信息
*/
@GetMapping("/statistics")
@Operation(summary = "获取客户统计信息", description = "获取客户总数等统计信息")
public ResponseEntity<Map<String, Object>> getCustomerStatistics() {
Map<String, Object> result = new HashMap<>();
try {
long totalCount = customerManagementService.count();
Map<String, Object> statistics = new HashMap<>();
statistics.put("totalCustomers", totalCount);
result.put("success", true);
result.put("message", "统计信息获取成功");
result.put("data", statistics);
return ResponseEntity.ok(result);
} catch (Exception e) {
result.put("success", false);
result.put("message", "统计信息获取异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
}