新版
This commit is contained in:
@@ -42,23 +42,23 @@ public class AppLoginController {
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("login")
|
||||
@ApiOperation("登录")
|
||||
public R login(@RequestBody LoginForm form){
|
||||
//表单校验
|
||||
ValidatorUtils.validateEntity(form);
|
||||
|
||||
//用户登录
|
||||
long userId = userService.login(form);
|
||||
|
||||
//生成token
|
||||
String token = jwtUtils.generateToken(userId);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("token", token);
|
||||
map.put("expire", jwtUtils.getExpire());
|
||||
|
||||
return R.ok(map);
|
||||
}
|
||||
// @PostMapping("login")
|
||||
// @ApiOperation("登录")
|
||||
// public R login(@RequestBody LoginForm form){
|
||||
// //表单校验
|
||||
// ValidatorUtils.validateEntity(form);
|
||||
//
|
||||
// //用户登录
|
||||
// long userId = userService.login(form);
|
||||
//
|
||||
// //生成token
|
||||
// String token = jwtUtils.generateToken(userId);
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("token", token);
|
||||
// map.put("expire", jwtUtils.getExpire());
|
||||
//
|
||||
// return R.ok(map);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ package com.peanut.modules.app.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.validator.ValidatorUtils;
|
||||
import com.peanut.modules.app.entity.UserEntity;
|
||||
import com.peanut.modules.app.form.RegisterForm;
|
||||
import com.peanut.modules.app.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -37,19 +36,19 @@ public class AppRegisterController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("register")
|
||||
@ApiOperation("注册")
|
||||
public R register(@RequestBody RegisterForm form){
|
||||
//表单校验
|
||||
ValidatorUtils.validateEntity(form);
|
||||
|
||||
UserEntity user = new UserEntity();
|
||||
user.setMobile(form.getMobile());
|
||||
user.setUsername(form.getMobile());
|
||||
user.setPassword(DigestUtils.sha256Hex(form.getPassword()));
|
||||
user.setCreateTime(new Date());
|
||||
userService.save(user);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
// @PostMapping("register")
|
||||
// @ApiOperation("注册")
|
||||
// public R register(@RequestBody RegisterForm form){
|
||||
// //表单校验
|
||||
// ValidatorUtils.validateEntity(form);
|
||||
//
|
||||
// UserEntity user = new UserEntity();
|
||||
// user.setMobile(form.getMobile());
|
||||
// user.setUsername(form.getMobile());
|
||||
// user.setPassword(DigestUtils.sha256Hex(form.getPassword()));
|
||||
// user.setCreateTime(new Date());
|
||||
// userService.save(user);
|
||||
//
|
||||
// return R.ok();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ package com.peanut.modules.app.controller;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.app.annotation.Login;
|
||||
import com.peanut.modules.app.annotation.LoginUser;
|
||||
import com.peanut.modules.app.entity.UserEntity;
|
||||
import com.peanut.modules.book.entity.UserEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
Reference in New Issue
Block a user