From e673aa0ef18aab41547fe5c9639b907a15f69542 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 07 五月 2025 10:26:46 +0800
Subject: [PATCH] 基础客户

---
 src/main/java/com/ruoyi/basic_data/service/impl/CustomerServiceImpl.java |   90 ++++++++++
 src/main/java/com/ruoyi/basic_data/controller/CustomerController.java    |  105 +++++++++++
 src/main/java/com/ruoyi/basic_data/pojo/Customer.java                    |  165 ++++++++++++++++++
 src/main/java/com/ruoyi/basic_data/service/ICustomerService.java         |   63 +++++++
 src/main/java/com/ruoyi/basic_data/mapper/CustomerMapper.java            |   63 +++++++
 pom.xml                                                                  |   21 ++
 6 files changed, 506 insertions(+), 1 deletions(-)

diff --git a/pom.xml b/pom.xml
index a81794a..871bb56 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,6 +40,7 @@
         <logback.version>1.2.13</logback.version>
         <spring-security.version>5.7.12</spring-security.version>
         <spring-framework.version>5.3.39</spring-framework.version>
+        <mybatis-plus.version>3.5.3.1</mybatis-plus.version>
     </properties>
 
     <dependencies>
@@ -113,6 +114,20 @@
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
             <version>${druid.version}</version>
+        </dependency>
+
+        <!--mybatis-plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>${mybatis-plus.version}</version>
+        </dependency>
+
+        <!--mybatis-plus浠g爜鐢熸垚鍣�-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>${mybatis-plus.version}</version>
         </dependency>
 
         <!-- 鑷畾涔夐獙璇佹敞瑙� -->
@@ -232,8 +247,12 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
 
-	</dependencies>
+    </dependencies>
 
 	<build>
 	    <finalName>${project.artifactId}</finalName>
diff --git a/src/main/java/com/ruoyi/basic_data/controller/CustomerController.java b/src/main/java/com/ruoyi/basic_data/controller/CustomerController.java
new file mode 100644
index 0000000..67d9b98
--- /dev/null
+++ b/src/main/java/com/ruoyi/basic_data/controller/CustomerController.java
@@ -0,0 +1,105 @@
+package com.ruoyi.basic_data.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.basic_data.pojo.Customer;
+import com.ruoyi.basic_data.service.ICustomerService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+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.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.page.TableDataInfo;
+
+/**
+ * 瀹㈡埛妗fController
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+@RestController
+@RequestMapping("/system/customer")
+public class CustomerController extends BaseController
+{
+    @Autowired
+    private ICustomerService customerService;
+
+    /**
+     * 鏌ヨ瀹㈡埛妗f鍒楄〃
+     */
+    @PreAuthorize("@ss.hasPermi('system:customer:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Customer customer)
+    {
+        startPage();
+        List<Customer> list = customerService.selectCustomerList(customer);
+        return getDataTable(list);
+    }
+
+    /**
+     * 瀵煎嚭瀹㈡埛妗f鍒楄〃
+     */
+    @PreAuthorize("@ss.hasPermi('system:customer:export')")
+    @Log(title = "瀹㈡埛妗f", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Customer customer)
+    {
+        List<Customer> list = customerService.selectCustomerList(customer);
+        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
+        util.exportExcel(response, list, "瀹㈡埛妗f鏁版嵁");
+    }
+
+    /**
+     * 鑾峰彇瀹㈡埛妗f璇︾粏淇℃伅
+     */
+    @PreAuthorize("@ss.hasPermi('system:customer:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(customerService.selectCustomerById(id));
+    }
+
+    /**
+     * 鏂板瀹㈡埛妗f
+     */
+    @PreAuthorize("@ss.hasPermi('system:customer:add')")
+    @Log(title = "瀹㈡埛妗f", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Customer customer)
+    {
+        return toAjax(customerService.insertCustomer(customer));
+    }
+
+    /**
+     * 淇敼瀹㈡埛妗f
+     */
+    @PreAuthorize("@ss.hasPermi('system:customer:edit')")
+    @Log(title = "瀹㈡埛妗f", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Customer customer)
+    {
+        return toAjax(customerService.updateCustomer(customer));
+    }
+
+    /**
+     * 鍒犻櫎瀹㈡埛妗f
+     */
+    @PreAuthorize("@ss.hasPermi('system:customer:remove')")
+    @Log(title = "瀹㈡埛妗f", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(customerService.deleteCustomerByIds(ids));
+    }
+}
diff --git a/src/main/java/com/ruoyi/basic_data/mapper/CustomerMapper.java b/src/main/java/com/ruoyi/basic_data/mapper/CustomerMapper.java
new file mode 100644
index 0000000..b986075
--- /dev/null
+++ b/src/main/java/com/ruoyi/basic_data/mapper/CustomerMapper.java
@@ -0,0 +1,63 @@
+package com.ruoyi.basic_data.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.basic_data.pojo.Customer;
+
+import java.util.List;
+
+/**
+ * 瀹㈡埛妗fMapper鎺ュ彛
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+public interface CustomerMapper extends BaseMapper<Customer>
+{
+    /**
+     * 鏌ヨ瀹㈡埛妗f
+     * 
+     * @param id 瀹㈡埛妗f涓婚敭
+     * @return 瀹㈡埛妗f
+     */
+    Customer selectCustomerById(Long id);
+
+    /**
+     * 鏌ヨ瀹㈡埛妗f鍒楄〃
+     * 
+     * @param customer 瀹㈡埛妗f
+     * @return 瀹㈡埛妗f闆嗗悎
+     */
+    List<Customer> selectCustomerList(Customer customer);
+
+    /**
+     * 鏂板瀹㈡埛妗f
+     * 
+     * @param customer 瀹㈡埛妗f
+     * @return 缁撴灉
+     */
+    int insertCustomer(Customer customer);
+
+    /**
+     * 淇敼瀹㈡埛妗f
+     * 
+     * @param customer 瀹㈡埛妗f
+     * @return 缁撴灉
+     */
+    int updateCustomer(Customer customer);
+
+    /**
+     * 鍒犻櫎瀹㈡埛妗f
+     * 
+     * @param id 瀹㈡埛妗f涓婚敭
+     * @return 缁撴灉
+     */
+    int deleteCustomerById(Long id);
+
+    /**
+     * 鎵归噺鍒犻櫎瀹㈡埛妗f
+     * 
+     * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎
+     * @return 缁撴灉
+     */
+    int deleteCustomerByIds(Long[] ids);
+}
diff --git a/src/main/java/com/ruoyi/basic_data/pojo/Customer.java b/src/main/java/com/ruoyi/basic_data/pojo/Customer.java
new file mode 100644
index 0000000..58ec83c
--- /dev/null
+++ b/src/main/java/com/ruoyi/basic_data/pojo/Customer.java
@@ -0,0 +1,165 @@
+package com.ruoyi.basic_data.pojo;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import com.ruoyi.framework.web.domain.BaseEntity;
+
+/**
+ * 瀹㈡埛妗f瀵硅薄 customer
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+@TableName(value = "customer")
+@Data
+public class Customer extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 瀹㈡埛鍚嶇О */
+    @Excel(name = "瀹㈡埛鍚嶇О")
+    private String customerName;
+
+    /** 绾崇◣浜鸿瘑鍒彿 */
+    @Excel(name = "绾崇◣浜鸿瘑鍒彿")
+    private String taxpayerIdentificationNumber;
+
+    /** 鍏徃鍦板潃 */
+    @Excel(name = "鍏徃鍦板潃")
+    private String companyAddress;
+
+    /** 鍏徃鐢佃瘽 */
+    @Excel(name = "鍏徃鐢佃瘽")
+    private String companyPhone;
+
+    /** 鑱旂郴浜� */
+    @Excel(name = "鑱旂郴浜�")
+    private String contactPerson;
+
+    /** 鑱旂郴鐢佃瘽 */
+    @Excel(name = "鑱旂郴鐢佃瘽")
+    private String contactPhone;
+
+    /** 缁存姢浜� */
+    @Excel(name = "缁存姢浜�")
+    private String maintainer;
+
+    /** 缁存姢鏃堕棿 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "缁存姢鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date maintenanceTime;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+
+    public void setCustomerName(String customerName) 
+    {
+        this.customerName = customerName;
+    }
+
+    public String getCustomerName() 
+    {
+        return customerName;
+    }
+
+    public void setTaxpayerIdentificationNumber(String taxpayerIdentificationNumber) 
+    {
+        this.taxpayerIdentificationNumber = taxpayerIdentificationNumber;
+    }
+
+    public String getTaxpayerIdentificationNumber() 
+    {
+        return taxpayerIdentificationNumber;
+    }
+
+    public void setCompanyAddress(String companyAddress) 
+    {
+        this.companyAddress = companyAddress;
+    }
+
+    public String getCompanyAddress() 
+    {
+        return companyAddress;
+    }
+
+    public void setCompanyPhone(String companyPhone) 
+    {
+        this.companyPhone = companyPhone;
+    }
+
+    public String getCompanyPhone() 
+    {
+        return companyPhone;
+    }
+
+    public void setContactPerson(String contactPerson) 
+    {
+        this.contactPerson = contactPerson;
+    }
+
+    public String getContactPerson() 
+    {
+        return contactPerson;
+    }
+
+    public void setContactPhone(String contactPhone) 
+    {
+        this.contactPhone = contactPhone;
+    }
+
+    public String getContactPhone() 
+    {
+        return contactPhone;
+    }
+
+    public void setMaintainer(String maintainer) 
+    {
+        this.maintainer = maintainer;
+    }
+
+    public String getMaintainer() 
+    {
+        return maintainer;
+    }
+
+    public void setMaintenanceTime(Date maintenanceTime) 
+    {
+        this.maintenanceTime = maintenanceTime;
+    }
+
+    public Date getMaintenanceTime() 
+    {
+        return maintenanceTime;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("customerName", getCustomerName())
+            .append("taxpayerIdentificationNumber", getTaxpayerIdentificationNumber())
+            .append("companyAddress", getCompanyAddress())
+            .append("companyPhone", getCompanyPhone())
+            .append("contactPerson", getContactPerson())
+            .append("contactPhone", getContactPhone())
+            .append("maintainer", getMaintainer())
+            .append("maintenanceTime", getMaintenanceTime())
+            .toString();
+    }
+}
diff --git a/src/main/java/com/ruoyi/basic_data/service/ICustomerService.java b/src/main/java/com/ruoyi/basic_data/service/ICustomerService.java
new file mode 100644
index 0000000..c85d479
--- /dev/null
+++ b/src/main/java/com/ruoyi/basic_data/service/ICustomerService.java
@@ -0,0 +1,63 @@
+package com.ruoyi.basic_data.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.basic_data.pojo.Customer;
+
+import java.util.List;
+
+/**
+ * 瀹㈡埛妗fService鎺ュ彛
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+public interface ICustomerService extends IService<Customer>
+{
+    /**
+     * 鏌ヨ瀹㈡埛妗f
+     * 
+     * @param id 瀹㈡埛妗f涓婚敭
+     * @return 瀹㈡埛妗f
+     */
+    Customer selectCustomerById(Long id);
+
+    /**
+     * 鏌ヨ瀹㈡埛妗f鍒楄〃
+     * 
+     * @param customer 瀹㈡埛妗f
+     * @return 瀹㈡埛妗f闆嗗悎
+     */
+    List<Customer> selectCustomerList(Customer customer);
+
+    /**
+     * 鏂板瀹㈡埛妗f
+     * 
+     * @param customer 瀹㈡埛妗f
+     * @return 缁撴灉
+     */
+    int insertCustomer(Customer customer);
+
+    /**
+     * 淇敼瀹㈡埛妗f
+     * 
+     * @param customer 瀹㈡埛妗f
+     * @return 缁撴灉
+     */
+    int updateCustomer(Customer customer);
+
+    /**
+     * 鎵归噺鍒犻櫎瀹㈡埛妗f
+     * 
+     * @param ids 闇�瑕佸垹闄ょ殑瀹㈡埛妗f涓婚敭闆嗗悎
+     * @return 缁撴灉
+     */
+    int deleteCustomerByIds(Long[] ids);
+
+    /**
+     * 鍒犻櫎瀹㈡埛妗f淇℃伅
+     * 
+     * @param id 瀹㈡埛妗f涓婚敭
+     * @return 缁撴灉
+     */
+    int deleteCustomerById(Long id);
+}
diff --git a/src/main/java/com/ruoyi/basic_data/service/impl/CustomerServiceImpl.java b/src/main/java/com/ruoyi/basic_data/service/impl/CustomerServiceImpl.java
new file mode 100644
index 0000000..48d9cb2
--- /dev/null
+++ b/src/main/java/com/ruoyi/basic_data/service/impl/CustomerServiceImpl.java
@@ -0,0 +1,90 @@
+package com.ruoyi.basic_data.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic_data.mapper.CustomerMapper;
+import com.ruoyi.basic_data.pojo.Customer;
+import com.ruoyi.basic_data.service.ICustomerService;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * 瀹㈡埛妗fService涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+@Service
+@AllArgsConstructor
+public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements ICustomerService {
+    private CustomerMapper customerMapper;
+
+    /**
+     * 鏌ヨ瀹㈡埛妗f
+     *
+     * @param id 瀹㈡埛妗f涓婚敭
+     * @return 瀹㈡埛妗f
+     */
+    @Override
+    public Customer selectCustomerById(Long id) {
+        return customerMapper.selectCustomerById(id);
+    }
+
+    /**
+     * 鏌ヨ瀹㈡埛妗f鍒楄〃
+     *
+     * @param customer 瀹㈡埛妗f
+     * @return 瀹㈡埛妗f
+     */
+    @Override
+    public List<Customer> selectCustomerList(Customer customer) {
+        return customerMapper.selectCustomerList(customer);
+    }
+
+    /**
+     * 鏂板瀹㈡埛妗f
+     *
+     * @param customer 瀹㈡埛妗f
+     * @return 缁撴灉
+     */
+    @Override
+    public int insertCustomer(Customer customer) {
+        return customerMapper.insertCustomer(customer);
+    }
+
+    /**
+     * 淇敼瀹㈡埛妗f
+     *
+     * @param customer 瀹㈡埛妗f
+     * @return 缁撴灉
+     */
+    @Override
+    public int updateCustomer(Customer customer) {
+        return customerMapper.updateCustomer(customer);
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎瀹㈡埛妗f
+     *
+     * @param ids 闇�瑕佸垹闄ょ殑瀹㈡埛妗f涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteCustomerByIds(Long[] ids) {
+        return customerMapper.deleteCustomerByIds(ids);
+    }
+
+    /**
+     * 鍒犻櫎瀹㈡埛妗f淇℃伅
+     *
+     * @param id 瀹㈡埛妗f涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteCustomerById(Long id) {
+        return customerMapper.deleteCustomerById(id);
+    }
+}

--
Gitblit v1.9.3