Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -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}")
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,14 @@
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSxCustomerVo">
|
||||
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
|
||||
</sql>
|
||||
|
||||
@@ -24,6 +28,9 @@
|
||||
<include refid="selectSxCustomerVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> AND c.name LIKE CONCAT('%', #{name}, '%')</if>
|
||||
<if test="province != null and province != ''"> AND c.province = #{province}</if>
|
||||
<if test="city != null and city != ''"> AND c.city = #{city}</if>
|
||||
<if test="district != null and district != ''"> AND c.district = #{district}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
</select>
|
||||
@@ -45,6 +52,10 @@
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
@@ -56,6 +67,10 @@
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -69,6 +84,8 @@
|
||||
<if test="district != null">district = #{district},</if>
|
||||
<if test="address != null">address = #{address},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user