亿众分发系统
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ApiRegisterController.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright (c) 2016-2019 人人开源 All rights reserved.
  3. *
  4. * https://www.renren.io
  5. *
  6. * 版权所有,侵权必究!
  7. */
  8. package io.renren.controller;
  9. import io.renren.common.utils.R;
  10. import io.renren.common.validator.ValidatorUtils;
  11. import io.renren.entity.UserEntity;
  12. import io.renren.form.RegisterForm;
  13. import io.renren.service.UserService;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import org.apache.commons.codec.digest.DigestUtils;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.PostMapping;
  19. import org.springframework.web.bind.annotation.RequestBody;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import java.util.Date;
  23. /**
  24. * 注册接口
  25. *
  26. * @author Mark sunlightcs@gmail.com
  27. */
  28. @RestController
  29. @RequestMapping("/api")
  30. @Api(tags="注册接口")
  31. public class ApiRegisterController {
  32. @Autowired
  33. private UserService userService;
  34. @PostMapping("register")
  35. @ApiOperation("注册")
  36. public R register(@RequestBody RegisterForm form){
  37. //表单校验
  38. ValidatorUtils.validateEntity(form);
  39. UserEntity user = new UserEntity();
  40. user.setMobile(form.getMobile());
  41. user.setUsername(form.getMobile());
  42. user.setPassword(DigestUtils.sha256Hex(form.getPassword()));
  43. user.setCreateTime(new Date());
  44. userService.save(user);
  45. return R.ok();
  46. }
  47. }