| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.matrix.component.redis.RedisClient; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.UUIDUtil; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.app.dto.LoginDto; |
| | | import com.matrix.system.app.vo.UserInfoVo; |
| | | import com.matrix.system.common.authority.DefaultAuthorityManager; |
| | |
| | | import com.matrix.system.common.authority.strategy.LoginStrategy; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.service.SysUsersService; |
| | | import com.matrix.system.hive.bean.SysShopInfo; |
| | | import com.matrix.system.hive.service.SysShopInfoService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import io.swagger.annotations.ApiResponses; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | LoginStrategy apLogin = new AccountPasswordLogin(user, sysUsersService); |
| | | user = authorityManager.login(apLogin); |
| | | |
| | | UserInfoVo userInfoVo = new UserInfoVo(); |
| | | if(user.getShopId()!=null){ |
| | | user.setShopName(sysShopInfoService.findById(user.getShopId()).getShopName()); |
| | | SysShopInfo shopInfo = sysShopInfoService.findById(user.getShopId()); |
| | | user.setShopName(shopInfo.getShopName()); |
| | | userInfoVo.setShopName(shopInfo.getShopShortName()); |
| | | } |
| | | user.setSuPassword(null); |
| | | |
| | |
| | | redisClient.saveValueForever(token, JSONObject.toJSONString(user)); |
| | | redisClient.saveValueForever(user.getSuId().toString(), token); |
| | | |
| | | UserInfoVo userInfoVo = new UserInfoVo(); |
| | | userInfoVo.setId(user.getSuId()); |
| | | userInfoVo.setName(user.getSuName()); |
| | | userInfoVo.setRoleName(user.getRoleName()); |
| | |
| | | result.putInMap("token", token); |
| | | return result; |
| | | } |
| | | |
| | | @ApiOperation(value = "退出登陆", notes = "退出登陆") |
| | | @GetMapping(value = "/loginOut") |
| | | public AjaxResult loginOut() { |
| | | SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | String token = redisClient.getCachedValue(sysUsers.getSuId().toString()); |
| | | |
| | | redisClient.removeObject(token); |
| | | redisClient.removeObject(sysUsers.getSuId().toString()); |
| | | return AjaxResult.buildSuccessInstance("退出成功"); |
| | | } |
| | | } |