New file |
| | |
| | | package com.panzhihua.applets.api; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.model.dtos.user.SysUserFeedbackDTO; |
| | | import com.panzhihua.common.model.vos.community.*; |
| | | import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.partybuilding.PartyBuildingService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.exceptions.UnAuthenticationException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.validated.AddGroup; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | | * @description: 用户 |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-11-24 12:03 |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/user/") |
| | | @Api(tags = {"我的模块"}) |
| | | public class UserApi extends BaseController { |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | @Resource |
| | | private PartyBuildingService partyBuildingService; |
| | | |
| | | @ApiOperation(value = "当前登录用户信息", response = LoginUserInfoVO.class) |
| | | @GetMapping("info") |
| | | public R getUserInfo() { |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | Long communityId = loginUserInfo.getCommunityId(); |
| | | Long userId = loginUserInfo.getUserId(); |
| | | Long areaId = loginUserInfo.getAreaId(); |
| | | R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId + ""); |
| | | if (R.isOk(r)) { |
| | | Object data = r.getData(); |
| | | if (!ObjectUtils.isEmpty(data)) { |
| | | LoginUserInfoVO loginUserInfoVO = (LoginUserInfoVO) data; |
| | | R r1 = communityService.detailHouse(userId); |
| | | if (null!=communityId&&0!=communityId) { |
| | | R r2=communityService.detailCommunity(communityId); |
| | | if (R.isOk(r2)) { |
| | | Object data1 = r2.getData(); |
| | | if (!ObjectUtils.isEmpty(data1)) { |
| | | loginUserInfoVO.setComActVO(JSONObject.parseObject(JSONObject.toJSONString(data1),ComActVO.class)); |
| | | r.setData(loginUserInfoVO); |
| | | } |
| | | } |
| | | } |
| | | if (null!=areaId&&areaId!=0) { |
| | | R r3=communityService.detailArea(areaId); |
| | | if (R.isOk(r3)) { |
| | | Object data1 = r3.getData(); |
| | | if (!ObjectUtils.isEmpty(data1)) { |
| | | loginUserInfoVO.setComMngStructAreaVO(JSONObject.parseObject(JSONObject.toJSONString(data1),ComMngStructAreaVO.class)); |
| | | r.setData(loginUserInfoVO); |
| | | } |
| | | } |
| | | } |
| | | if (R.isOk(r1)) { |
| | | Object data1 = r1.getData(); |
| | | if (!ObjectUtils.isEmpty(data1)) { |
| | | loginUserInfoVO.setComMngStructHouseVOS((List<ComMngStructHouseVO>) data1); |
| | | r.setData(loginUserInfoVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | @ApiOperation(value = "用户实名认证") |
| | | @PutMapping("putuserauthentication") |
| | | public R putUserAuthentication(@RequestBody @Validated(AddGroup.class) LoginUserInfoVO loginUserInfoVO) { |
| | | Long userId = this.getUserId(); |
| | | loginUserInfoVO.setUserId(userId); |
| | | return userService.putUserAuthentication(loginUserInfoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "修改用户手机号") |
| | | @PutMapping("userphone") |
| | | public R putUserphone(@RequestBody UserPhoneVO userPhoneVO) { |
| | | Long userId = this.getUserId(); |
| | | userPhoneVO.setUserId(userId); |
| | | R r = userService.putUserphone(userPhoneVO); |
| | | if (R.isOk(r)) { |
| | | communityService.putVolunteerPhone(userPhoneVO); |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | @ApiOperation(value = "修改用户信息") |
| | | @PutMapping("user") |
| | | public R putUser(@RequestBody LoginUserInfoVO loginUserInfoVO) { |
| | | Long userId = this.getUserId(); |
| | | loginUserInfoVO.setUserId(userId); |
| | | return userService.putUser(loginUserInfoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "房屋地址下拉列表") |
| | | @GetMapping("listhouse") |
| | | @ApiImplicitParam(name = "parentCode",value = "父级地址编码",required = false) |
| | | public R listHouses(String parentCode) { |
| | | Long areaId = this.getAreaId(); |
| | | if (ObjectUtils.isEmpty(parentCode)) { |
| | | parentCode=""; |
| | | } |
| | | return communityService.listHouses(parentCode,areaId); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增房屋") |
| | | @PostMapping("houses") |
| | | public R addHouses(@RequestBody @Validated(AddGroup.class) ComMngStructHouseVO comMngStructHouseVO) { |
| | | String houseCode = comMngStructHouseVO.getHouseCode(); |
| | | if (ObjectUtils.isEmpty(houseCode)) { |
| | | return R.fail("房屋地址编码不能为空"); |
| | | } |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | comMngStructHouseVO.setUserId(loginUserInfo.getUserId()); |
| | | comMngStructHouseVO.setAreaId(loginUserInfo.getAreaId()); |
| | | return communityService.addHouses(comMngStructHouseVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "家庭成员列表") |
| | | @GetMapping("listfamily") |
| | | public R listFamily() { |
| | | Long userId = this.getUserId(); |
| | | return userService.listFamily(userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增家庭成员") |
| | | @PostMapping("addfamily") |
| | | public R addFamily(@RequestBody @Validated(AddGroup.class) ComMngFamilyInfoVO comMngFamilyInfoVO) { |
| | | Long userId = this.getUserId(); |
| | | comMngFamilyInfoVO.setUserId(userId); |
| | | return userService.addFamily(comMngFamilyInfoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑家庭成员") |
| | | @PutMapping("putfamily") |
| | | public R putFamily(@RequestBody ComMngFamilyInfoVO comMngFamilyInfoVO) { |
| | | Long id = comMngFamilyInfoVO.getId(); |
| | | if (null==id||0==id) { |
| | | return R.fail("成员主键不能为空"); |
| | | } |
| | | comMngFamilyInfoVO.setUserId(this.getUserId()); |
| | | return userService.putFamily(comMngFamilyInfoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "我的活动",response =ComActActivityVO.class ) |
| | | @GetMapping("listactivity") |
| | | public R listActivity() { |
| | | Long userId = this.getUserId(); |
| | | List<ComActActivityVO> comActActivityVOS=new ArrayList<>(); |
| | | R r=communityService.listActivity(userId); |
| | | if (R.isOk(r)) { |
| | | comActActivityVOS =(List<ComActActivityVO>) r.getData(); |
| | | } |
| | | R r1=partyBuildingService.listActivity(userId); |
| | | if (R.isOk(r1)) { |
| | | List<ComActActivityVO> data = (List<ComActActivityVO>) r1.getData(); |
| | | comActActivityVOS.addAll(data); |
| | | } |
| | | if (!ObjectUtils.isEmpty(comActActivityVOS)) { |
| | | String s = JSONArray.toJSONString(comActActivityVOS); |
| | | List<ComActActivityVO>comActActivityVOS1=new ArrayList<>(); |
| | | comActActivityVOS1=JSONArray.parseArray(s,ComActActivityVO.class); |
| | | List<ComActActivityVO> collect = comActActivityVOS1.stream().sorted(Comparator.comparing(ComActActivityVO::getBeginAt).reversed()).collect(Collectors.toList()); |
| | | comActActivityVOS=collect; |
| | | } |
| | | return R.ok(comActActivityVOS); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询我的随手拍",response = ComActEasyPhotoVO.class ) |
| | | @PostMapping("pageeasyphoto") |
| | | public R pageEasyPhoto(@RequestBody ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | Long userId = this.getUserId(); |
| | | comActEasyPhotoVO.setUserId(userId); |
| | | comActEasyPhotoVO.setLogInUserId(userId); |
| | | comActEasyPhotoVO.setCommunityId(null); |
| | | return communityService.pageEasyPhoto(comActEasyPhotoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询我的微心愿",response = ComActMicroWishVO.class ) |
| | | @PostMapping("pagemicrowish") |
| | | public R pageMicroWish(@RequestBody ComActMicroWishVO comActMicroWishVO) { |
| | | Long userId = this.getUserId(); |
| | | comActMicroWishVO.setUserId(userId); |
| | | comActMicroWishVO.setCommunityId(null); |
| | | return communityService.pageMicroWish(comActMicroWishVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "用户确认心愿" ) |
| | | @PutMapping("microwishconfirm") |
| | | public R putMicroWishConfirm(@RequestBody ComActMicroWishVO comActMicroWishVO) { |
| | | Long userId = this.getUserId(); |
| | | comActMicroWishVO.setUserId(userId); |
| | | comActMicroWishVO.setCommunityId(null); |
| | | Long id = comActMicroWishVO.getId(); |
| | | if (null==id||0==id) { |
| | | return R.fail("心愿主键不能为空"); |
| | | } |
| | | String evaluate = comActMicroWishVO.getEvaluate(); |
| | | if (ObjectUtils.isEmpty(evaluate)) { |
| | | return R.fail("用户评价不能为空"); |
| | | } |
| | | Integer score = comActMicroWishVO.getScore(); |
| | | if (null==score||0==score) { |
| | | return R.fail("评分不能为空"); |
| | | } |
| | | comActMicroWishVO.setEvaluateAt(new Date()); |
| | | comActMicroWishVO.setStatus(6); |
| | | return communityService.putMicroWishConfirm(comActMicroWishVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "调试接口--清除昵称、社区、小区" ) |
| | | @DeleteMapping("usertest") |
| | | public R deleteUserTest() { |
| | | Long userId = this.getUserId(); |
| | | return userService.deleteUserTest(userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "意见反馈" ) |
| | | @PostMapping("feedback") |
| | | public R addFeedback(@RequestBody @Validated(AddGroup.class) SysUserFeedbackDTO sysUserFeedbackDTO) { |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | Long userId = loginUserInfo.getUserId(); |
| | | Long communityId = loginUserInfo.getCommunityId(); |
| | | Long areaId = loginUserInfo.getAreaId(); |
| | | if (null==communityId||0==communityId) { |
| | | return R.fail("未绑定社区"); |
| | | } |
| | | sysUserFeedbackDTO.setCommunityId(communityId); |
| | | sysUserFeedbackDTO.setAreaId(areaId); |
| | | sysUserFeedbackDTO.setUserId(userId); |
| | | return userService.addFeedback(sysUserFeedbackDTO); |
| | | } |
| | | |
| | | |
| | | } |