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 new file mode 100644 index 0000000..a499f88 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java @@ -0,0 +1,85 @@ +package com.zhyc.module.sale.controller; + +import java.util.List; +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 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.service.ISxCustomerService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +@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) { + startPage(); + List list = sxCustomerService.selectSxCustomerList(sxCustomer); + return getDataTable(list); + } + + @PreAuthorize("@ss.hasPermi('customer:customer:export')") + @Log(title = "客户管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SxCustomer sxCustomer) { + List list = sxCustomerService.selectSxCustomerList(sxCustomer); + + // 转换为导出DTO + List exportList = list.stream().map(customer -> { + 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()); + return exportItem; + }).collect(Collectors.toList()); + + ExcelUtil util = new ExcelUtil<>(SxCustomerExport.class); + util.exportExcel(response, exportList, "客户管理数据"); + } + + @PreAuthorize("@ss.hasPermi('customer:customer:query')") + @GetMapping("/{id}") + public AjaxResult getInfo(@PathVariable 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) { + return toAjax(sxCustomerService.insertSxCustomer(sxCustomer)); + } + + @PreAuthorize("@ss.hasPermi('customer:customer:edit')") + @Log(title = "客户管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SxCustomer sxCustomer) { + return toAjax(sxCustomerService.updateSxCustomer(sxCustomer)); + } + + @PreAuthorize("@ss.hasPermi('customer:customer:remove')") + @Log(title = "客户管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(sxCustomerService.deleteSxCustomerByIds(ids)); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..43e023e --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java @@ -0,0 +1,60 @@ +package com.zhyc.module.sale.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +public class SxCustomer extends BaseEntity { + private static final long serialVersionUID = 1L; + + private Long id; + + @Excel(name = "客户名称") + private String name; + + @Excel(name = "客户电话") + private String phone; + + @Excel(name = "省") + private String province; + + @Excel(name = "市") + private String city; + + @Excel(name = "区县") + private String district; + + @Excel(name = "详细地址") + private String address; + + // Getters and Setters + public Long getId() { return id; } + public void setId(Long id) { this.id = id; } + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public String getPhone() { return phone; } + public void setPhone(String phone) { this.phone = phone; } + public String getProvince() { return province; } + public void setProvince(String province) { this.province = province; } + public String getCity() { return city; } + public void setCity(String city) { this.city = city; } + public String getDistrict() { return district; } + public void setDistrict(String district) { this.district = district; } + public String getAddress() { return address; } + public void setAddress(String address) { this.address = address; } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", id) + .append("name", name) + .append("phone", phone) + .append("province", province) + .append("city", city) + .append("district", district) + .append("address", address) + .append("remark", getRemark()) + .toString(); + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxCustomerMapper.java b/zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxCustomerMapper.java new file mode 100644 index 0000000..e5b049d --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxCustomerMapper.java @@ -0,0 +1,61 @@ +package com.zhyc.module.sale.mapper; + +import java.util.List; +import com.zhyc.module.sale.domain.SxCustomer; + +/** + * 客户管理Mapper接口 + * + * @author ruoyi + * @date 2025-08-18 + */ +public interface SxCustomerMapper +{ + /** + * 查询客户管理 + * + * @param id 客户管理主键 + * @return 客户管理 + */ + public SxCustomer selectSxCustomerById(Long id); + + /** + * 查询客户管理列表 + * + * @param sxCustomer 客户管理 + * @return 客户管理集合 + */ + public List selectSxCustomerList(SxCustomer sxCustomer); + + /** + * 新增客户管理 + * + * @param sxCustomer 客户管理 + * @return 结果 + */ + public int insertSxCustomer(SxCustomer sxCustomer); + + /** + * 修改客户管理 + * + * @param sxCustomer 客户管理 + * @return 结果 + */ + public int updateSxCustomer(SxCustomer sxCustomer); + + /** + * 删除客户管理 + * + * @param id 客户管理主键 + * @return 结果 + */ + public int deleteSxCustomerById(Long id); + + /** + * 批量删除客户管理 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSxCustomerByIds(Long[] ids); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxCustomerService.java b/zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxCustomerService.java new file mode 100644 index 0000000..956891f --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxCustomerService.java @@ -0,0 +1,13 @@ +package com.zhyc.module.sale.service; + +import java.util.List; +import com.zhyc.module.sale.domain.SxCustomer; + +public interface ISxCustomerService { + SxCustomer selectSxCustomerById(Long id); + List selectSxCustomerList(SxCustomer sxCustomer); + int insertSxCustomer(SxCustomer sxCustomer); + int updateSxCustomer(SxCustomer sxCustomer); + int deleteSxCustomerByIds(Long[] ids); + int deleteSxCustomerById(Long id); +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxCustomerServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxCustomerServiceImpl.java new file mode 100644 index 0000000..b6483fe --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxCustomerServiceImpl.java @@ -0,0 +1,44 @@ +package com.zhyc.module.sale.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.sale.mapper.SxCustomerMapper; +import com.zhyc.module.sale.domain.SxCustomer; +import com.zhyc.module.sale.service.ISxCustomerService; + +@Service +public class SxCustomerServiceImpl implements ISxCustomerService { + @Autowired + private SxCustomerMapper sxCustomerMapper; + + @Override + public SxCustomer selectSxCustomerById(Long id) { + return sxCustomerMapper.selectSxCustomerById(id); + } + + @Override + public List selectSxCustomerList(SxCustomer sxCustomer) { + return sxCustomerMapper.selectSxCustomerList(sxCustomer); + } + + @Override + public int insertSxCustomer(SxCustomer sxCustomer) { + return sxCustomerMapper.insertSxCustomer(sxCustomer); + } + + @Override + public int updateSxCustomer(SxCustomer sxCustomer) { + return sxCustomerMapper.updateSxCustomer(sxCustomer); + } + + @Override + public int deleteSxCustomerByIds(Long[] ids) { + return sxCustomerMapper.deleteSxCustomerByIds(ids); + } + + @Override + public int deleteSxCustomerById(Long id) { + return sxCustomerMapper.deleteSxCustomerById(id); + } +} \ 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 new file mode 100644 index 0000000..f50db7f --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + SELECT id, name, phone, province, city, district, address, remark + FROM sx_customer + + + + + + + + INSERT INTO sx_customer + + name, + phone, + province, + city, + district, + address, + remark, + + + #{name}, + #{phone}, + #{province}, + #{city}, + #{district}, + #{address}, + #{remark}, + + + + + UPDATE sx_customer + + name = #{name}, + phone = #{phone}, + province = #{province}, + city = #{city}, + district = #{district}, + address = #{address}, + remark = #{remark}, + + WHERE id = #{id} + + + + DELETE FROM sx_customer WHERE id = #{id} + + + + DELETE FROM sx_customer WHERE id IN + + #{id} + + + \ No newline at end of file