ExpressCompanyController.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.study.mall.controller;
  2. import com.study.mall.common.utils.CommonResult;
  3. import com.study.mall.common.utils.PageParam;
  4. import com.study.mall.common.utils.PageUtils;
  5. import com.study.mall.entity.ExpressCompanyEntity;
  6. import com.study.mall.service.ExpressCompanyService;
  7. import org.springframework.validation.annotation.Validated;
  8. import org.springframework.web.bind.annotation.DeleteMapping;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import java.util.Arrays;
  16. /**
  17. * 快递公司
  18. *
  19. * @author codingliang
  20. * @email codingliang@gmail.com
  21. * @date 2023-09-04 22:14:38
  22. */
  23. @RestController
  24. @RequestMapping("expressCompany")
  25. public class ExpressCompanyController {
  26. private final ExpressCompanyService expressCompanyService;
  27. public ExpressCompanyController(ExpressCompanyService expressCompanyService) {
  28. this.expressCompanyService = expressCompanyService;
  29. }
  30. /**
  31. * 快递公司列表
  32. */
  33. @GetMapping("open/list")
  34. public CommonResult<PageUtils<ExpressCompanyEntity>> list(PageParam pageParam){
  35. PageUtils page = expressCompanyService.queryPage(pageParam);
  36. return CommonResult.ok().setResult(page);
  37. }
  38. /**
  39. * 新增快递公司
  40. * @apiNote 快递公司编码不能随便乱填,具体参考快递100,参考链接:https://api.kuaidi100.com/document/5f0ffb5ebc8da837cbd8aefc#section_1
  41. */
  42. @PostMapping("admin/add")
  43. public CommonResult<Void> add(@RequestBody @Validated ExpressCompanyEntity expressCompany){
  44. expressCompanyService.add(expressCompany);
  45. return CommonResult.ok();
  46. }
  47. /**
  48. * 修改快递公司
  49. */
  50. @PutMapping("admin/update")
  51. public CommonResult<Void> update(@RequestBody @Validated ExpressCompanyEntity expressCompany){
  52. expressCompanyService.update(expressCompany);
  53. return CommonResult.ok();
  54. }
  55. /**
  56. * 删除快递公司
  57. * @param ids id集合
  58. */
  59. @DeleteMapping("admin/delete")
  60. public CommonResult<Void> deleteByIds(@RequestBody Long[] ids){
  61. expressCompanyService.deleteByIds(Arrays.asList(ids));
  62. return CommonResult.ok();
  63. }
  64. }