|
@@ -3,9 +3,12 @@ package com.leromro.web.controller.system;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import com.leromro.core.service.IClientAccountService;
|
|
|
+import com.leromro.core.service.IVolunteerAccountService;
|
|
|
import com.leromro.system.service.ISysUserService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.leromro.common.constant.Constants;
|
|
|
import com.leromro.common.core.domain.AjaxResult;
|
|
@@ -39,9 +42,16 @@ public class SysLoginController
|
|
|
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IVolunteerAccountService volunteerAccountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IClientAccountService clientAccountService;
|
|
|
+
|
|
|
/**
|
|
|
* 登录方法
|
|
|
*
|
|
@@ -108,6 +118,7 @@ public class SysLoginController
|
|
|
return AjaxResult.success(menuService.buildMenus(menus));
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@PutMapping("setUserOrWorker/{userOrWorker}")
|
|
|
public AjaxResult setUserOrWorker(@PathVariable Integer userOrWorker){
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
@@ -115,6 +126,12 @@ public class SysLoginController
|
|
|
user.setUserId(userId);
|
|
|
user.setUserOrWorker(userOrWorker);
|
|
|
userService.updateUserProfile(user);
|
|
|
+ //为对应角色创建对应账号
|
|
|
+ if (userOrWorker == 1){
|
|
|
+ clientAccountService.insertVolunteerAccount(userId);
|
|
|
+ }else if (userOrWorker == 2){
|
|
|
+ volunteerAccountService.insertVolunteerAccount(userId);
|
|
|
+ }
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
}
|