| | |
| | |
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import com.ruoyi.project.system.domain.vo.SysUserDeptVo;
|
| | | import com.ruoyi.project.system.service.ISysUserDeptService;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.framework.security.LoginBody;
|
| | |
| | |
|
| | | @Autowired
|
| | | private TokenService tokenService;
|
| | |
|
| | | @Autowired
|
| | | private ISysUserDeptService userDeptService;
|
| | |
|
| | | /**
|
| | | * 登录方法
|
| | |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
| | | return AjaxResult.success(menuService.buildMenus(menus));
|
| | | }
|
| | |
|
| | | @PostMapping("/loginCheck")
|
| | | public AjaxResult loginCheck(@RequestBody LoginBody loginBody)
|
| | | {
|
| | | try {
|
| | | Long userId = loginService.loginCheck(loginBody.getUsername(), loginBody.getPassword());
|
| | | return AjaxResult.success(userId);
|
| | | }catch (Exception e) {
|
| | | return AjaxResult.error(e.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | | @GetMapping("/userDeptList")
|
| | | public AjaxResult userDeptList(SysUserDeptVo sysUserDeptVo){
|
| | | return AjaxResult.success(userDeptService.selectUserDeptList(sysUserDeptVo));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 选择公司登录
|
| | | *
|
| | | * @param loginBody 登录信息
|
| | | * @return 结果
|
| | | */
|
| | | @PostMapping("/loginCheckFactory")
|
| | | public AjaxResult loginCheckFactory(@RequestBody LoginBody loginBody)
|
| | | {
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | // 生成令牌
|
| | | String token = loginService.loginCheckFactory(loginBody.getUsername(), loginBody.getPassword(),loginBody.getFactoryId());
|
| | | ajax.put(Constants.TOKEN, token);
|
| | | return ajax;
|
| | | }
|
| | | }
|