fix登录,积分
This commit is contained in:
@@ -25,6 +25,9 @@ public class OpsController {
|
||||
*/
|
||||
@PostMapping("/points/add")
|
||||
public R<Void> addPoints(@RequestBody PointsDTO dto) {
|
||||
if (!UserContext.isOps()) {
|
||||
return R.fail("无权限:仅运营可操作");
|
||||
}
|
||||
Long operatorId = UserContext.getUserId();
|
||||
pointsService.addPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_ADD, null, operatorId, dto.getRemark());
|
||||
@@ -36,17 +39,17 @@ public class OpsController {
|
||||
* 减积分
|
||||
*/
|
||||
@PostMapping("/points/sub")
|
||||
public R<Void> subPoints(@RequestBody PointsDTO dto) {
|
||||
Long operatorId = UserContext.getUserId();
|
||||
boolean success = pointsService.subPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_SUB, null, operatorId, dto.getRemark());
|
||||
if (success) {
|
||||
return R.ok();
|
||||
public R subPoints(@RequestBody PointsDTO dto) {
|
||||
if (!UserContext.isOps()) {
|
||||
return R.fail("无权限:仅运营可操作");
|
||||
}
|
||||
return R.fail("余额不足或用户不存在");
|
||||
|
||||
Long operatorId = UserContext.getUserId();
|
||||
pointsService.subPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_SUB, null, operatorId, dto.getRemark());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拉入群
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.tailbet.model.vo.LoginUserVo;
|
||||
import com.tailbet.model.vo.LoginVo;
|
||||
import com.tailbet.model.vo.R;
|
||||
import com.tailbet.model.vo.UserContext;
|
||||
import com.tailbet.openim.OpenIMClient;
|
||||
import com.tailbet.service.IUserService;
|
||||
import com.tailbet.util.JwtUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -20,6 +22,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class UserController {
|
||||
|
||||
private final IUserService userService;
|
||||
private final JwtUtil jwtUtil;
|
||||
private final OpenIMClient openIMClient;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
@@ -36,9 +40,13 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public R<LoginVo> login(@RequestBody LoginDTO dto) {
|
||||
String token = userService.login(dto.getUsername(), dto.getPassword());
|
||||
Long userId = userService.login(dto.getUsername(), dto.getPassword());
|
||||
String token = jwtUtil.generateToken(userId, dto.getUsername());
|
||||
String openIMToken = openIMClient.getUserToken(String.valueOf(userId));
|
||||
|
||||
LoginVo vo = new LoginVo();
|
||||
vo.setToken(token);
|
||||
vo.setOpenIMToken(openIMToken);
|
||||
return R.ok("登录成功", vo);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user