From b84c35fe650d4ead7c9cad18b9c2258704ffdf53 Mon Sep 17 00:00:00 2001 From: ll <1079863556@qq.com> Date: Mon, 9 Feb 2026 21:57:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AE=A1=E7=90=86bug?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sale/controller/SxCustomerController.java | 79 ++++++++++++++++--- .../zhyc/module/sale/domain/SxCustomer.java | 5 ++ .../module/sale/domain/SxCustomerExport.java | 58 +++++++++++--- .../mapper/sale/SxCustomerMapper.xml | 19 ++++- 4 files changed, 134 insertions(+), 27 deletions(-) diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java index 5fc7735..0c09308 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java @@ -1,27 +1,44 @@ package com.zhyc.module.sale.controller; import java.util.List; +import java.util.Date; // 【修改点1】新增导入Date包 import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import com.zhyc.common.annotation.Log; import com.zhyc.common.core.controller.BaseController; import com.zhyc.common.core.domain.AjaxResult; import com.zhyc.common.enums.BusinessType; import com.zhyc.module.sale.domain.SxCustomer; -import com.zhyc.module.sale.domain.SxCustomerExport; // 新增导入 +import com.zhyc.module.sale.domain.SxCustomerExport; import com.zhyc.module.sale.service.ISxCustomerService; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.core.page.TableDataInfo; +/** + * 客户管理Controller + * + * @author ruoyi + * @date 2025-08-18 + */ @RestController @RequestMapping("/customer/customer") public class SxCustomerController extends BaseController { @Autowired private ISxCustomerService sxCustomerService; + /** + * 查询客户管理列表 + */ @PreAuthorize("@ss.hasPermi('customer:customer:list')") @GetMapping("/list") public TableDataInfo list(SxCustomer sxCustomer) { @@ -30,6 +47,9 @@ public class SxCustomerController extends BaseController { return getDataTable(list); } + /** + * 导出客户管理列表 + */ @PreAuthorize("@ss.hasPermi('customer:customer:export')") @Log(title = "客户管理", businessType = BusinessType.EXPORT) @PostMapping("/export") @@ -41,14 +61,22 @@ public class SxCustomerController extends BaseController { SxCustomerExport exportItem = new SxCustomerExport(); exportItem.setName(customer.getName()); exportItem.setPhone(customer.getPhone()); - // 拼接完整地址 - exportItem.setFullAddress( - (customer.getProvince() != null ? customer.getProvince() : "") + - (customer.getCity() != null ? customer.getCity() : "") + - (customer.getDistrict() != null ? customer.getDistrict() : "") + - (customer.getAddress() != null ? customer.getAddress() : "") - ); - exportItem.setRemark(customer.getRemark()); + + // 拼接所在地区 (省 + 市 + 区) + String area = (customer.getProvince() != null ? customer.getProvince() : "") + + (customer.getCity() != null ? customer.getCity() : "") + + (customer.getDistrict() != null ? customer.getDistrict() : ""); + exportItem.setArea(area); + + // 详细地址 + exportItem.setAddress(customer.getAddress()); + + // 创建人 (从BaseEntity获取) + exportItem.setCreateBy(customer.getCreateBy()); + + // 创建日期 (从BaseEntity获取) + exportItem.setCreateTime(customer.getCreateTime()); + return exportItem; }).collect(Collectors.toList()); @@ -56,29 +84,54 @@ public class SxCustomerController extends BaseController { util.exportExcel(response, exportList, "客户管理数据"); } + /** + * 获取客户管理详细信息 + */ @PreAuthorize("@ss.hasPermi('customer:customer:query')") - @GetMapping("/{id}") - public AjaxResult getInfo(@PathVariable Long id) { + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(sxCustomerService.selectSxCustomerById(id)); } + /** + * 新增客户管理 + */ @PreAuthorize("@ss.hasPermi('customer:customer:add')") @Log(title = "客户管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SxCustomer sxCustomer) { - // 【新增】自动填充当前登录用户的 userId 和 deptId + // 自动填充当前登录用户的 userId 和 deptId sxCustomer.setUserId(getUserId()); sxCustomer.setDeptId(getDeptId()); + + // 自动填充创建人 + sxCustomer.setCreateBy(getUsername()); + + // 【修改点2】自动填充创建时间为当前时间 + sxCustomer.setCreateTime(new Date()); + return toAjax(sxCustomerService.insertSxCustomer(sxCustomer)); } + /** + * 修改客户管理 + */ @PreAuthorize("@ss.hasPermi('customer:customer:edit')") @Log(title = "客户管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SxCustomer sxCustomer) { + // 自动填充更新人 + sxCustomer.setUpdateBy(getUsername()); + + // 【修改点3】自动填充更新时间为当前时间 + sxCustomer.setUpdateTime(new Date()); + return toAjax(sxCustomerService.updateSxCustomer(sxCustomer)); } + /** + * 删除客户管理 + */ @PreAuthorize("@ss.hasPermi('customer:customer:remove')") @Log(title = "客户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java index c6f717b..db96f1d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java @@ -122,6 +122,7 @@ public class SxCustomer extends BaseEntity { @Override public String toString() { + // 修改:补充 BaseEntity 中的创建人、创建时间等重要字段,便于日志排查 return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("name", getName()) @@ -133,6 +134,10 @@ public class SxCustomer extends BaseEntity { .append("remark", getRemark()) .append("userId", getUserId()) .append("deptId", getDeptId()) + .append("createBy", getCreateBy()) // 补充创建人 + .append("createTime", getCreateTime()) // 补充创建时间 + .append("updateBy", getUpdateBy()) // 补充更新人 + .append("updateTime", getUpdateTime()) // 补充更新时间 .toString(); } } \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java index 168563c..916c461 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java @@ -1,7 +1,11 @@ package com.zhyc.module.sale.domain; import com.zhyc.common.annotation.Excel; +import java.util.Date; +/** + * 客户管理导出对象 + */ public class SxCustomerExport { @Excel(name = "客户名称") private String name; @@ -9,11 +13,23 @@ public class SxCustomerExport { @Excel(name = "客户电话") private String phone; - @Excel(name = "客户地址") - private String fullAddress; + /** 新增:所在地区 */ + @Excel(name = "所在地区") + private String area; - @Excel(name = "备注") - private String remark; + /** 新增:详细地址 */ + @Excel(name = "详细地址") + private String address; + + /** 新增:创建人 */ + @Excel(name = "创建人") + private String createBy; + + /** 新增:创建日期 */ + @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date createTime; + + // --- 以下是 Getter 和 Setter 方法,必须包含 --- public String getName() { return name; @@ -31,19 +47,35 @@ public class SxCustomerExport { this.phone = phone; } - public String getFullAddress() { - return fullAddress; + public String getArea() { + return area; } - public void setFullAddress(String fullAddress) { - this.fullAddress = fullAddress; + public void setArea(String area) { + this.area = area; } - public String getRemark() { - return remark; + public String getAddress() { + return address; } - public void setRemark(String remark) { - this.remark = remark; + public void setAddress(String address) { + this.address = address; } -} + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml b/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml index b6f20ac..f631c68 100644 --- a/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml +++ b/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml @@ -13,10 +13,14 @@ + + + + - SELECT c.id, c.name, c.phone, c.province, c.city, c.district, c.address, c.remark, c.user_id, c.dept_id + SELECT c.id, c.name, c.phone, c.province, c.city, c.district, c.address, c.remark, c.user_id, c.dept_id, c.create_by, c.create_time, c.update_by, c.update_time FROM sx_customer c @@ -24,6 +28,9 @@ AND c.name LIKE CONCAT('%', #{name}, '%') + AND c.province = #{province} + AND c.city = #{city} + AND c.district = #{district} ${params.dataScope} @@ -45,6 +52,10 @@ remark, user_id, dept_id, + create_by, + create_time, + update_by, + update_time, #{name}, @@ -56,6 +67,10 @@ #{remark}, #{userId}, #{deptId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, @@ -69,6 +84,8 @@ district = #{district}, address = #{address}, remark = #{remark}, + update_by = #{updateBy}, + update_time = #{updateTime}, WHERE id = #{id}