huanghongfa
2021-08-19 c40be027ef8068b9a77bb24c94291dee25f563d8
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/IndexApi.java
@@ -1,7 +1,9 @@
package com.panzhihua.applets.api;
import com.panzhihua.applets.weixin.CheckService;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.CommonDTO;
import com.panzhihua.common.model.dtos.PageDTO;
import com.panzhihua.common.model.dtos.community.ComActEasyPhotoCommentDTO;
import com.panzhihua.common.model.dtos.community.PageComActEasyPhotoCommentDTO;
@@ -10,10 +12,7 @@
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.advertisement.ComOpsAdvVO;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoCommentVO;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO;
import com.panzhihua.common.model.vos.community.ComActMessageVO;
import com.panzhihua.common.model.vos.community.ComActMicroWishVO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.user.NoticeUnReadVO;
import com.panzhihua.common.model.vos.user.SysUserAgreementVO;
import com.panzhihua.common.model.vos.user.SysUserNoticeVO;
@@ -50,13 +49,11 @@
    @ApiOperation(value = "分页展示社区随手拍",response = ComActEasyPhotoVO.class)
    @PostMapping("pageeasyphoto")
    public R pageEasyPhoto (@RequestBody ComActEasyPhotoVO comActEasyPhotoVO){
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        if (null==communityId||0==communityId) {
            return R.fail("用户未绑定社区");
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        if(loginUserInfo != null){
            comActEasyPhotoVO.setCommunityId(loginUserInfo.getCommunityId());
            comActEasyPhotoVO.setLogInUserId(loginUserInfo.getUserId());
        }
        comActEasyPhotoVO.setCommunityId(communityId);
        comActEasyPhotoVO.setLogInUserId(loginUserInfo.getUserId());
        return communityService.pageEasyPhotoApplets(comActEasyPhotoVO);
    }
@@ -80,18 +77,38 @@
        return communityService.addEasyPhoto(comActEasyPhotoVO);
    }
    @ApiOperation(value = "查询随手拍是否有活动",response = ComActEasyPhotoActivityVO.class)
    @PostMapping("getEasyPhotoActivity")
    public R getEasyPhotoActivity (@RequestBody CommonDTO commonDTO){
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        Long communityId = commonDTO.getCommunityId();
        if(loginUserInfo != null){
            communityId = loginUserInfo.getCommunityId();
        }
        return communityService.getEasyPhotoActivity(communityId);
    }
    @ApiOperation(value = "随手拍详情",response =ComActEasyPhotoVO.class )
    @GetMapping("detaileasyphoto")
    @ApiImplicitParam(name = "id",value = "随手拍主键")
    public R detailEasyPhoto (@RequestParam("id") Long id){
        Long userId = this.getUserId();
        Long userId = 0L;
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        if(loginUserInfo != null){
            userId = loginUserInfo.getUserId();
        }
        return communityService.detailEasyPhoto(id,userId);
    }
    @ApiOperation(value = "随手拍--评论--分页查询",response = ComActEasyPhotoCommentVO.class )
    @PostMapping("pagecomacteasyphotocomment")
    public R pageComActEasyPhotoComment (@RequestBody PageComActEasyPhotoCommentDTO pageComActEasyPhotoCommentDTO){
        pageComActEasyPhotoCommentDTO.setUserId(this.getUserId());
        Long userId = 0L;
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        if(loginUserInfo != null){
            userId = loginUserInfo.getUserId();
        }
        pageComActEasyPhotoCommentDTO.setUserId(userId);
        return communityService.pageComActEasyPhotoComment(pageComActEasyPhotoCommentDTO);
    }
@@ -129,15 +146,12 @@
    @ApiOperation(value = "分页展示社区微心愿",response = ComActMicroWishVO.class)
    @PostMapping("pagemicrowish")
    public R pageMicroWish (@RequestBody ComActMicroWishVO comActMicroWishVO){
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        if (null==communityId||0==communityId) {
            return R.fail("用户未绑定社区");
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        if(loginUserInfo != null){
            comActMicroWishVO.setCommunityId(loginUserInfo.getCommunityId());
            comActMicroWishVO.setResponsibleId(loginUserInfo.getUserId());//责任人暂时放登录用户id
        }
        Long userId = loginUserInfo.getUserId();
        comActMicroWishVO.setCommunityId(communityId);
        comActMicroWishVO.setIsApplets(1);
        comActMicroWishVO.setResponsibleId(userId);//责任人暂时放登录用户id
        comActMicroWishVO.setIsPageMyWish(null);
        return communityService.pageMicroWish(comActMicroWishVO);
    }
@@ -171,7 +185,11 @@
    @GetMapping("microwish")
    @ApiImplicitParam(name = "id",value = "微心愿主键")
    public R detailMicroWish (@RequestParam("id")Long id){
        Long userId = this.getUserId();
        Long userId = 0L;
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        if(loginUserInfo != null){
            userId = loginUserInfo.getUserId();
        }
        return communityService.detailMicroWish(id,userId);
    }
@@ -188,7 +206,7 @@
    }
    @ApiOperation(value = "首页广告banner",response = ComOpsAdvVO.class)
    @GetMapping("listadvertisement")
    @GetMapping("listadvertisement/noToken")
    public R listAdvertisement (){
        return communityService.listAdvertisement();
    }
@@ -238,7 +256,7 @@
            return R.fail("用户未绑定社区");
        }
        Integer type = loginUserInfo.getType();
        if(null==type||type!=1||type!=2) {
        if(null==type||(type!=1&&type!=2)) {
           return R.fail("留言对象类型错误!");
        }
        Long userId = loginUserInfo.getUserId();
@@ -246,16 +264,41 @@
        comActMessageVO.setUserId(userId);
        comActMessageVO.setUserName(loginUserInfo.getName());
        comActMessageVO.setUserAccount(loginUserInfo.getAccount());
        comActMessageVO.setUserPhone(loginUserInfo.getPhone());
        comActMessageVO.setIspublic(1);
        comActMessageVO.setStatus(1);
        return communityService.addMessage(comActMessageVO);
    }
    
    @ApiOperation("发布留言回复")
    @PostMapping("addmessageback")
    public R addMessageBack(@RequestBody @Validated(AddGroup.class) ComActMessageBackVO comActMessageBackVO){
        //        微信内容审核
        String msg = comActMessageBackVO.getMsgContent();
        if (!checkService.checkMessage(msg)) {
            return R.fail("内容违规");
        }
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        if (null==communityId||0==communityId) {
            return R.fail("用户未绑定社区");
        }
        Integer type = loginUserInfo.getType();
        if(null==type||(type!=1&&type!=2)) {
           return R.fail("留言对象类型错误!");
        }
        Long userId = loginUserInfo.getUserId();
        comActMessageBackVO.setCommunityId(communityId);
        comActMessageBackVO.setUserId(userId);
        comActMessageBackVO.setUserName(loginUserInfo.getName());
        comActMessageBackVO.setUserAccount(loginUserInfo.getAccount());
        comActMessageBackVO.setIspublic(1);
        comActMessageBackVO.setStatus(1);
        return communityService.addMessageBack(comActMessageBackVO);
    }
    @ApiOperation(value = "分页显示我的留言",response = ComActMessageVO.class)
    @GetMapping("pagemymessage")
    public R pageMyMessage (){
       ComActMessageVO comActMessageVO=new ComActMessageVO();
    @PostMapping("pagemymessage")
    public R pageMyMessage (@RequestBody ComActMessageVO comActMessageVO){
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        if (null==communityId||0==communityId) {
@@ -266,10 +309,9 @@
        return communityService.pageMyMessageApplets(comActMessageVO);
    }
    
    @ApiOperation(value = "分页显示给我的留言",response = ComActMessageVO.class)
    @GetMapping("pagesendtomemessage")
    public R pageSendToMessage (){
       ComActMessageVO comActMessageVO=new ComActMessageVO();
    @ApiOperation(value = "分页显示居民给我的留言",response = ComActMessageVO.class)
    @PostMapping("pagesendtomemessage")
    public R pageSendToMessage (@RequestBody ComActMessageVO comActMessageVO){
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        if (null==communityId||0==communityId) {
@@ -277,22 +319,43 @@
        }
        comActMessageVO.setCommunityId(communityId);
        comActMessageVO.setUserId(loginUserInfo.getUserId());
        comActMessageVO.setPhone(loginUserInfo.getPhone());
        return communityService.pageSendToMessageApplets(comActMessageVO);
    }
    @ApiOperation(value = "分页显示指定用户的留言",response =ComActMessageVO.class )
    @PostMapping("pagemessagebyuser")
    public R pageMessageByUser (@RequestBody ComActMessageVO comActMessageVO){
        return communityService.pageMessageByUser(comActMessageVO);
    }
    
    @ApiOperation(value = "分页显示社区的留言",response = ComActMessageVO.class)
    @GetMapping("pagemycommunitymessage")
    public R pageMyCommunityMessage (){
       ComActMessageVO comActMessageVO=new ComActMessageVO();
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        if (null==communityId||0==communityId) {
            return R.fail("用户未绑定社区");
        }
        comActMessageVO.setCommunityId(communityId);
        comActMessageVO.setUserId(loginUserInfo.getUserId());
        return communityService.pageMyCommunityMessageApplets(comActMessageVO);
    @ApiOperation(value = "留言详情",response =ComActMessageVO.class )
    @GetMapping("detailmessage")
    @ApiImplicitParam(name = "id",value = "随手拍主键")
    public R detailMessage(@RequestParam("id") Long id){
        return communityService.detailMessage(id);
    }
    @ApiOperation(value = "首页商城开关接口")
    @GetMapping("isShop")
    public R isShop(){
        return R.ok(Constants.IS_SHOP_OPEN);
    }
    @ApiOperation(value = "获取最新活动和用户最新收益",response =ComActEasyPhotoRewardVO.class )
    @GetMapping("getUserReward")
    public R getUserReward(@RequestParam("communityId") Long communityId){
        Long userId = 0L;
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin();
        if(loginUserInfo != null){
            userId = loginUserInfo.getUserId();
            communityId = loginUserInfo.getCommunityId();
        }
        return communityService.getUserReward(userId,communityId);
    }
    @ApiOperation(value = "读取用户随手拍奖励")
    @PostMapping("readUserReward")
    public R readUserReward(){
        return communityService.readUserReward(this.getUserId(),this.getCommunityId());
    }
}