You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomerController.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Copyright (c) 2022 雷掣 All rights reserved.
  3. *
  4. * https://www.lc_crm.com
  5. *
  6. * 版权所有,侵权必究!
  7. */
  8. package io.renren.controller;
  9. import io.renren.common.exception.ErrorCode;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.GetMapping;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import io.renren.common.utils.Result;
  17. import io.renren.common.validator.ValidatorUtils;
  18. import io.renren.common.validator.group.AddGroup;
  19. import io.renren.common.validator.group.DefaultGroup;
  20. import io.renren.dto.CustomersDTO;
  21. import io.renren.service.CustomersService;
  22. import io.renren.service.UserService;
  23. import io.swagger.annotations.Api;
  24. import io.swagger.annotations.ApiOperation;
  25. @RestController
  26. @RequestMapping("api/customer")
  27. @Api(tags="客户表")
  28. public class CustomerController{
  29. @Autowired
  30. private CustomersService customersService;
  31. @Autowired
  32. private UserService userService;
  33. @PostMapping("save")
  34. @ApiOperation(value = "保存")
  35. public Result<String> save(@RequestBody CustomersDTO dto) throws Exception {
  36. ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
  37. return customersService.inserCustomer(dto);
  38. }
  39. @PostMapping("update")
  40. @ApiOperation(value = "更新")
  41. public Result<String> update(@RequestBody CustomersDTO dto) throws Exception {
  42. ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
  43. return customersService.updateCustomer(dto);
  44. }
  45. @PostMapping("sendSms")
  46. @ApiOperation("发送手机验证码")
  47. public Result<String> getverificationCode(String mobile){
  48. Boolean flag = userService.getverificationCode(mobile);
  49. if(flag) {
  50. return new Result<String>().pageOk(ErrorCode.SUCCESS_CODE,"发送短信成功");
  51. }
  52. return new Result<String>().error(ErrorCode.SEND_CODE_ERROR,"发送短信失败");
  53. }
  54. }