Compare commits

...

2 Commits

Author SHA1 Message Date
ll
9980d575e0 Merge remote-tracking branch 'origin/main' 2025-09-08 09:54:42 +08:00
ll
00840960bc 客户管理 2025-09-08 09:54:29 +08:00
6 changed files with 342 additions and 0 deletions

View File

@ -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<SxCustomer> 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<SxCustomer> list = sxCustomerService.selectSxCustomerList(sxCustomer);
// 转换为导出DTO
List<SxCustomerExport> 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<SxCustomerExport> 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));
}
}

View File

@ -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();
}
}

View File

@ -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<SxCustomer> 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);
}

View File

@ -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<SxCustomer> selectSxCustomerList(SxCustomer sxCustomer);
int insertSxCustomer(SxCustomer sxCustomer);
int updateSxCustomer(SxCustomer sxCustomer);
int deleteSxCustomerByIds(Long[] ids);
int deleteSxCustomerById(Long id);
}

View File

@ -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<SxCustomer> 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);
}
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.sale.mapper.SxCustomerMapper">
<resultMap type="SxCustomer" id="SxCustomerResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="phone" column="phone"/>
<result property="province" column="province"/>
<result property="city" column="city"/>
<result property="district" column="district"/>
<result property="address" column="address"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectSxCustomerVo">
SELECT id, name, phone, province, city, district, address, remark
FROM sx_customer
</sql>
<select id="selectSxCustomerList" parameterType="SxCustomer" resultMap="SxCustomerResult">
<include refid="selectSxCustomerVo"/>
<where>
<if test="name != null and name != ''"> AND name LIKE CONCAT('%', #{name}, '%')</if>
</where>
</select>
<select id="selectSxCustomerById" parameterType="Long" resultMap="SxCustomerResult">
<include refid="selectSxCustomerVo"/>
WHERE id = #{id}
</select>
<insert id="insertSxCustomer" parameterType="SxCustomer" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sx_customer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="phone != null">phone,</if>
<if test="province != null">province,</if>
<if test="city != null">city,</if>
<if test="district != null">district,</if>
<if test="address != null">address,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="phone != null">#{phone},</if>
<if test="province != null">#{province},</if>
<if test="city != null">#{city},</if>
<if test="district != null">#{district},</if>
<if test="address != null">#{address},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSxCustomer" parameterType="SxCustomer">
UPDATE sx_customer
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="province != null">province = #{province},</if>
<if test="city != null">city = #{city},</if>
<if test="district != null">district = #{district},</if>
<if test="address != null">address = #{address},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
WHERE id = #{id}
</update>
<delete id="deleteSxCustomerById" parameterType="Long">
DELETE FROM sx_customer WHERE id = #{id}
</delete>
<delete id="deleteSxCustomerByIds" parameterType="Long">
DELETE FROM sx_customer WHERE id IN
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>