| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.yuanchu.limslaboratory.clients.UserLoginUtils; |
| | | import com.yuanchu.limslaboratory.pojo.Enterprise; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.shiro.realm.ShiroRealm; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtils; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authc.IncorrectCredentialsException; |
| | | import org.apache.shiro.authc.UnknownAccountException; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/user") |
| | | @Api(tags = "用户模块") |
| | | public class UserController { |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @ApiOperation("用户登录") |
| | | @ApiImplicitParams(value = { |
| | |
| | | return Result.fail("登录失败"); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/getUserById") |
| | | @ApiOperation("获取指定用户id的用户信息和企业信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "用户id", name = "userId", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public Result<?> getUserById(int userId) { |
| | | try { |
| | | Map<String, String> map = userService.selectUserByUserId(userId); |
| | | User user = new User(map.get("account"),map.get("uname"),map.get("phone"),map.get("email"),map.get("info")); |
| | | Enterprise enterprise = new Enterprise(map.get("name"),map.get("byname"),map.get("link_name"),map.get("link_phone")); |
| | | Map map1 = new HashMap<>(); |
| | | map1.put("enterprise", enterprise); |
| | | map1.put("user", user); |
| | | return Result.success(map1); |
| | | } catch (Exception e) { |
| | | return Result.fail("用户id为空!"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |