New file |
| | |
| | | package com.panzhihua.grid_backstage.api; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 我的模块 |
| | | * @author lyq |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/user") |
| | | @Api(tags = {"我的模块"}) |
| | | public class UserApi extends BaseController { |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @ApiOperation(value = "当前登录用户信息", response = LoginUserInfoVO.class) |
| | | @GetMapping("/info") |
| | | public R getUserInfo() { |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | Long communityId = loginUserInfo.getCommunityId(); |
| | | Long userId = loginUserInfo.getUserId(); |
| | | R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId + ""); |
| | | |
| | | if (R.isOk(r)) { |
| | | Object data = r.getData(); |
| | | if (!ObjectUtils.isEmpty(data)) { |
| | | LoginUserInfoVO loginUserInfoVO = (LoginUserInfoVO) data; |
| | | //查询社区信息 |
| | | if (null != communityId && 0 != communityId) { |
| | | R r1 = communityService.detailCommunity(communityId); |
| | | if (R.isOk(r1)) { |
| | | Object data1 = r1.getData(); |
| | | if (!ObjectUtils.isEmpty(data1)) { |
| | | loginUserInfoVO.setComActVO(JSONObject.parseObject(JSONObject.toJSONString(data1), ComActVO.class)); |
| | | r.setData(loginUserInfoVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | |
| | | } |