fix
This commit is contained in:
@@ -25,14 +25,11 @@ public class OpsController {
|
||||
*/
|
||||
@PostMapping("/points/add")
|
||||
public R<Void> addPoints(@RequestBody PointsDTO dto) {
|
||||
try {
|
||||
Long operatorId = UserContext.getUserId();
|
||||
pointsService.addPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_ADD, null, operatorId, dto.getRemark());
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
Long operatorId = UserContext.getUserId();
|
||||
pointsService.addPoints(dto.getUserId(), dto.getAmount(),
|
||||
IPointsService.TYPE_OPS_ADD, null, operatorId, dto.getRemark());
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,17 +37,14 @@ public class OpsController {
|
||||
*/
|
||||
@PostMapping("/points/sub")
|
||||
public R<Void> subPoints(@RequestBody PointsDTO dto) {
|
||||
try {
|
||||
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();
|
||||
}
|
||||
return R.fail("余额不足或用户不存在");
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
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();
|
||||
}
|
||||
return R.fail("余额不足或用户不存在");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,12 +52,9 @@ public class OpsController {
|
||||
*/
|
||||
@PostMapping("/group/pull")
|
||||
public R<Void> pullGroup(@RequestBody PullGroupDTO dto) {
|
||||
try {
|
||||
Long operatorId = UserContext.getUserId();
|
||||
groupService.pullUser(dto.getGroupId(), dto.getUserId(), operatorId);
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
Long operatorId = UserContext.getUserId();
|
||||
groupService.pullUser(dto.getGroupId(), dto.getUserId(), operatorId);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,9 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public R<Void> register(@RequestBody RegisterDTO dto) {
|
||||
try {
|
||||
userService.register(dto.getUsername(), dto.getPassword());
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
userService.register(dto.getUsername(), dto.getPassword());
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,14 +36,11 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public R<LoginVo> login(@RequestBody LoginDTO dto) {
|
||||
try {
|
||||
String token = userService.login(dto.getUsername(), dto.getPassword());
|
||||
LoginVo vo = new LoginVo();
|
||||
vo.setToken(token);
|
||||
return R.ok("登录成功", vo);
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
String token = userService.login(dto.getUsername(), dto.getPassword());
|
||||
LoginVo vo = new LoginVo();
|
||||
vo.setToken(token);
|
||||
return R.ok("登录成功", vo);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,13 +57,10 @@ public class UserController {
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public R<Void> update(@RequestBody UpdateUserDTO dto) {
|
||||
try {
|
||||
Long userId = UserContext.getUserId();
|
||||
userService.updateUserInfo(userId, dto);
|
||||
return R.ok();
|
||||
} catch (RuntimeException e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
Long userId = UserContext.getUserId();
|
||||
userService.updateUserInfo(userId, dto);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user