From 2673320f02d89bddc7d0432c7013d37b8bbcd06b Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Tue, 1 Jul 2025 16:40:59 +0800 Subject: [PATCH] =?UTF-8?q?WEB=EF=BC=9A=E5=AE=A2=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 10 ++--- .../controller/CustomerController.java | 43 +++++++++++++++++-- .../fyscustomer/service/CustomerService.java | 25 +++++++++++ .../service/impl/CustomerServiceImpl.java | 40 ++++++++++++++++- 4 files changed, 108 insertions(+), 10 deletions(-) diff --git a/fys-admin/src/main/resources/application-dev.yml b/fys-admin/src/main/resources/application-dev.yml index 52b2877..43b5507 100644 --- a/fys-admin/src/main/resources/application-dev.yml +++ b/fys-admin/src/main/resources/application-dev.yml @@ -49,9 +49,9 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) - url: jdbc:mysql://120.79.224.186:3366/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + url: jdbc:mysql://localhost:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root - password: 1fys@QWER.. + password: root # # 从库数据源 # slave: # lazy: true @@ -98,13 +98,13 @@ spring: spring.data: redis: # 地址 - host: 120.79.224.186 + host: 123.207.99.140 # 端口,默认为6379 - port: 26379 + port: 6379 # 数据库索引 database: 2 # redis 密码必须配置 - password: 1fys@QWER.. + password: ccxx11234 # 连接超时时间 timeout: 10s # 是否开启ssl diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/controller/CustomerController.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/controller/CustomerController.java index 5cb25b0..e08ebd5 100644 --- a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/controller/CustomerController.java +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/controller/CustomerController.java @@ -1,18 +1,21 @@ package com.fuyuanshen.fyscustomer.controller; +import cn.hutool.core.collection.CollectionUtil; import com.fuyuanshen.common.core.domain.ResponseVO; +import com.fuyuanshen.common.core.utils.StringUtils; import com.fuyuanshen.fyscustomer.domain.Customer; import com.fuyuanshen.fyscustomer.domain.query.UserQueryCriteria; import com.fuyuanshen.fyscustomer.service.CustomerService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import io.undertow.util.BadRequestException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Set; /** * @author: 默苍璃 @@ -28,7 +31,6 @@ public class CustomerController { private final CustomerService customerService; - @GetMapping(value = "/allCustomer") @Operation(summary = "查询所有客户") public ResponseVO> queryAllCustomer(UserQueryCriteria criteria) { @@ -37,4 +39,37 @@ public class CustomerController { } + // @Log("新增客户") + @Operation(summary = "新增客户") + @PostMapping(value = "/addCustomer") + public ResponseVO addCustomer(@Validated @RequestBody Customer customer) throws BadRequestException { + if (StringUtils.isBlank(customer.getPassword())) { + throw new BadRequestException("账号密码不能为空"); + } + customerService.addCustomer(customer); + return ResponseVO.success("新增客户成功!!!"); + } + + + // @Log("修改客户") + @Operation(summary = "修改客户") + @PutMapping(value = "updateCustomer") + public ResponseVO updateCustomer(@RequestBody Customer resources) throws Exception { + customerService.updateCustomer(resources); + return ResponseVO.success(null); + } + + + // @Log("删除客户") + @Operation(summary = "删除客户") + @DeleteMapping(value = "/deleteCustomer") + public ResponseVO deleteCustomer(@RequestBody Set ids) throws BadRequestException { + if (CollectionUtil.isEmpty(ids)) { + throw new BadRequestException("请选择要删除的客户"); + } + customerService.delete(ids); + return ResponseVO.success(null); + } + + } diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/CustomerService.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/CustomerService.java index dff9ecd..ef0347c 100644 --- a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/CustomerService.java +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/CustomerService.java @@ -4,6 +4,7 @@ import com.fuyuanshen.fyscustomer.domain.Customer; import com.fuyuanshen.fyscustomer.domain.query.UserQueryCriteria; import java.util.List; +import java.util.Set; /** * @author: 默苍璃 @@ -19,4 +20,28 @@ public interface CustomerService { */ List queryAllCustomers(UserQueryCriteria criteria); + /** + * 新增客户 + * + * @param customer / + */ + void addCustomer(Customer customer); + + /** + * 修改客户 + * + * @param resources / + * @throws Exception / + */ + void updateCustomer(Customer resources) throws Exception; + + /** + * 删除客户 + * + * @param ids / + */ + void delete(Set ids); + + + } diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/impl/CustomerServiceImpl.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/impl/CustomerServiceImpl.java index 4e1f0cf..fd5e442 100644 --- a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/impl/CustomerServiceImpl.java +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/fyscustomer/service/impl/CustomerServiceImpl.java @@ -7,8 +7,10 @@ import com.fuyuanshen.fyscustomer.mapper.CustomerMapper; import com.fuyuanshen.fyscustomer.service.CustomerService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Set; /** * @author: 默苍璃 @@ -16,7 +18,7 @@ import java.util.List; */ @Service @RequiredArgsConstructor -public class CustomerServiceImpl extends ServiceImpl implements CustomerService { +public class CustomerServiceImpl extends ServiceImpl implements CustomerService { private final CustomerMapper customerMapper; @@ -34,4 +36,40 @@ public class CustomerServiceImpl extends ServiceImpl } + /** + * 新增客户 + * + * @param customer / + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void addCustomer(Customer customer) { + + } + + + /** + * 修改客户 + * + * @param resources / + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCustomer(Customer resources) throws Exception { + + } + + + /** + * 删除客户 + * + * @param ids / + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(Set ids) { + + } + + }