83 lines
2.3 KiB
Java
83 lines
2.3 KiB
Java
package com.bycrm.controller;
|
|
|
|
import com.bycrm.common.Result;
|
|
import com.bycrm.dto.DealerDTO;
|
|
import com.bycrm.entity.Dealer;
|
|
import com.bycrm.service.DealerService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 经销商控制器
|
|
*/
|
|
@Api(tags = "经销商管理")
|
|
@RestController
|
|
@RequestMapping("/dealer")
|
|
public class DealerController {
|
|
|
|
private final DealerService dealerService;
|
|
|
|
public DealerController(DealerService dealerService) {
|
|
this.dealerService = dealerService;
|
|
}
|
|
|
|
/**
|
|
* 查询所有经销商
|
|
*/
|
|
@ApiOperation("查询所有经销商")
|
|
@GetMapping("/list")
|
|
public Result<List<Dealer>> getDealerList(
|
|
@ApiParam("经销商名称") @RequestParam(required = false) String name,
|
|
@ApiParam("经销商账号") @RequestParam(required = false) String code,
|
|
@ApiParam("状态") @RequestParam(required = false) Integer status) {
|
|
List<Dealer> dealers = dealerService.getDealerList(name, code, status);
|
|
return Result.success(dealers);
|
|
}
|
|
|
|
/**
|
|
* 根据ID获取经销商
|
|
*/
|
|
@ApiOperation("根据ID获取经销商")
|
|
@GetMapping("/{id}")
|
|
public Result<Dealer> getDealerById(@ApiParam("经销商ID") @PathVariable Long id) {
|
|
Dealer dealer = dealerService.getDealerById(id);
|
|
return Result.success(dealer);
|
|
}
|
|
|
|
/**
|
|
* 创建经销商
|
|
*/
|
|
@ApiOperation("创建经销商")
|
|
@PostMapping
|
|
public Result<Void> createDealer(@RequestBody DealerDTO dealerDTO) {
|
|
dealerService.createDealer(dealerDTO);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 更新经销商
|
|
*/
|
|
@ApiOperation("更新经销商")
|
|
@PutMapping("/{id}")
|
|
public Result<Void> updateDealer(
|
|
@ApiParam("经销商ID") @PathVariable Long id,
|
|
@RequestBody DealerDTO dealerDTO) {
|
|
dealerService.updateDealer(id, dealerDTO);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 删除经销商
|
|
*/
|
|
@ApiOperation("删除经销商")
|
|
@DeleteMapping("/{id}")
|
|
public Result<Void> deleteDealer(@ApiParam("经销商ID") @PathVariable Long id) {
|
|
dealerService.deleteDealer(id);
|
|
return Result.success();
|
|
}
|
|
}
|