forked from dyf/fys-Multi-tenant
WEB:客户管理 接口
This commit is contained in:
@ -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<List<Customer>> queryAllCustomer(UserQueryCriteria criteria) {
|
||||
@ -37,4 +39,37 @@ public class CustomerController {
|
||||
}
|
||||
|
||||
|
||||
// @Log("新增客户")
|
||||
@Operation(summary = "新增客户")
|
||||
@PostMapping(value = "/addCustomer")
|
||||
public ResponseVO<Object> 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<Object> updateCustomer(@RequestBody Customer resources) throws Exception {
|
||||
customerService.updateCustomer(resources);
|
||||
return ResponseVO.success(null);
|
||||
}
|
||||
|
||||
|
||||
// @Log("删除客户")
|
||||
@Operation(summary = "删除客户")
|
||||
@DeleteMapping(value = "/deleteCustomer")
|
||||
public ResponseVO<Object> deleteCustomer(@RequestBody Set<Long> ids) throws BadRequestException {
|
||||
if (CollectionUtil.isEmpty(ids)) {
|
||||
throw new BadRequestException("请选择要删除的客户");
|
||||
}
|
||||
customerService.delete(ids);
|
||||
return ResponseVO.success(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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<Customer> queryAllCustomers(UserQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 新增客户
|
||||
*
|
||||
* @param customer /
|
||||
*/
|
||||
void addCustomer(Customer customer);
|
||||
|
||||
/**
|
||||
* 修改客户
|
||||
*
|
||||
* @param resources /
|
||||
* @throws Exception /
|
||||
*/
|
||||
void updateCustomer(Customer resources) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除客户
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void delete(Set<Long> ids);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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<CustomerMapper, Customer> implements CustomerService {
|
||||
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
||||
|
||||
private final CustomerMapper customerMapper;
|
||||
|
||||
@ -34,4 +36,40 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增客户
|
||||
*
|
||||
* @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<Long> ids) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user