BusinessCardController.java 17.6 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.model.response.businessCard.BusinessCardRecordRelationRpcResponse;
import cn.com.glsx.entmicro.request.card.*;
import cn.com.glsx.entmicro.response.card.*;
import cn.com.glsx.entmicro.service.card.BusinessCardService;
import cn.com.glsx.entmicro.utils.Pagination;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @ClassName BusinessCardController
 * @Description
 * @Author lichongyuan
 * @Date 2022/9/1
 */
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("智能名片")
@Slf4j
public class BusinessCardController {

    @Autowired
    private BusinessCardService businessCardService;


    @ServiceMethod(method = "entmicro.api.business.card.cardRecord", needInSession = NeedInSessionType.NO)
    @ApiOperation("智能名片埋点")
    public RopResponse<Boolean> cardRecord(SaveCardRecordRopRequest request) {
        try {
            businessCardService.cardRecord(request);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__cardRecord__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.listpage", needInSession = NeedInSessionType.YES)
    @ApiOperation("智能名片分页列表")
    public RopResponse<Pagination<BusinessCardPageRopResponse>> getCardListPage(BusinessCardPageRopRequest request) {
        try {
            Pagination<BusinessCardPageRopResponse> resultPage = businessCardService.listPage(request);
            return RopResponse.success(resultPage);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__getCardDetail__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    @ServiceMethod(method = "entmicro.api.business.card.cardDetail", needInSession = NeedInSessionType.YES)
    @ApiOperation("智能名片详情")
    public RopResponse<BusinessCardPageRopResponse> getBusinessCardDetail(DeleteCardRopRequest ropRequest){
        try {
            BusinessCardPageRopResponse businessCardDetail = businessCardService.getBusinessCardDetail(ropRequest);
            return RopResponse.success(businessCardDetail);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__cardDetail__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.save", needInSession = NeedInSessionType.YES)
    @ApiOperation("新增名片")
    public RopResponse<Integer> saveBusinessCard(SaveCardRopRequest ropRequest){
        try {
            Integer cardId = businessCardService.saveBusinessCard(ropRequest);
            return RopResponse.success(cardId);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__saveCard__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.update", needInSession = NeedInSessionType.YES)
    @ApiOperation("修改名片")
    public RopResponse<Integer> updateBusinessCard(SaveCardRopRequest ropRequest){
        try {
            Integer cardId = businessCardService.updateBusinessCard(ropRequest);
            return RopResponse.success(cardId);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__updateCard__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.delete", needInSession = NeedInSessionType.YES)
    @ApiOperation("删除名片")
    public RopResponse<Integer> updateBusinessCard(DeleteCardRopRequest ropRequest){
        try {
            Integer cardId = businessCardService.deleteBusinessCard(ropRequest);
            return RopResponse.success(cardId);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__deleteCard__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.cardRecord.page", needInSession = NeedInSessionType.YES)
    @ApiOperation("访客记录分页列表")
    public RopResponse<Pagination<CardRecordPageRopResponse>> listCardRecordPage(CardRecordPageRopRequest ropRequest){
        try {
            Pagination<CardRecordPageRopResponse> responsePagination = businessCardService.listCardRecordPage(ropRequest);
            return RopResponse.success(responsePagination);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__cardRecordPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.cardRecord.list", needInSession = NeedInSessionType.NO)
    @ApiOperation("访客记录列表(无session)")
    public RopResponse<Pagination<CardRecordPageRopResponse>> listCardRecord(CardRecordPageRopRequest ropRequest){
        try {
            if (ropRequest.getMerchant() != null) {
                ropRequest.setMerchantId(ropRequest.getMerchant());
            }
            Pagination<CardRecordPageRopResponse> responsePagination = businessCardService.listCardRecordPage(ropRequest);
            return RopResponse.success(responsePagination);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__cardRecordPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.activity.apply", needInSession = NeedInSessionType.YES)
    @ApiOperation("智能名片活动申请")
    public RopResponse<Boolean> activityApply(BusinessCardActivityApplyRopRequest ropRequest){
        try {
            Boolean responses = businessCardService.activityApply(ropRequest);
            return RopResponse.success(responses);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityApply__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.activity.record", needInSession = NeedInSessionType.YES)
    @ApiOperation("分页查询活动申请记录")
    public RopResponse<Pagination<BusinessCardActvityRopResponse>> viewActivityApplyPage(BusinessCardActivityPageRopRequest ropRequest){
        try {
            Pagination<BusinessCardActvityRopResponse> responsePagination = businessCardService.viewActivityApplyPage(ropRequest);
            return RopResponse.success(responsePagination);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__viewActivityApplyPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.activity.record.list", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询活动申请记录(无session)")
    public RopResponse<Pagination<BusinessCardActvityRopResponse>> viewActivityApplyList(BusinessCardActivityPageRopRequest ropRequest){
        try {
            if (ropRequest.getMerchant() != null) {
                ropRequest.setMerchantId(ropRequest.getMerchant());
            }
            Pagination<BusinessCardActvityRopResponse> responsePagination = businessCardService.viewActivityApplyPage(ropRequest);
            return RopResponse.success(responsePagination);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__viewActivityApplyPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.activity.follow", needInSession = NeedInSessionType.NO)
    @ApiOperation("智能名片活动跟进")
    public RopResponse<Boolean> followActivity(BusinessCardActivityRopRequest ropRequest){
        try {
            Boolean responses = businessCardService.followActivity(ropRequest);
            return RopResponse.success(responses);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__followActivity__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.activity.pagerecord", needInSession = NeedInSessionType.NO)
    @ApiOperation("智能名片活动页面访问记录")
    public RopResponse<List<BusinessCardRecordRelationRpcResponse>> viewActivityAccessRecord(BusinessCardActivityRopRequest ropRequest){
        try {
            List<BusinessCardRecordRelationRpcResponse> responses = businessCardService.viewActivityAccessRecord(ropRequest);
            return RopResponse.success(responses);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__viewActivityAccessRecord__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.export", needInSession = NeedInSessionType.YES)
    @ApiOperation("导出智能名片分页列表")
    public RopResponse<String> exportBusinessCard(BusinessCardPageRopRequest request){
        try {
            String resultPage = businessCardService.exportBusinessCard(request);
            return RopResponse.success(resultPage);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__exportBusinessCard__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.card.activity.export", needInSession = NeedInSessionType.YES)
    @ApiOperation("导出活动申请记录")
    public RopResponse<String> exportActivityApply(BusinessCardActivityPageRopRequest ropRequest){
        try {
            String responsePagination = businessCardService.exportActivityApply(ropRequest);
            return RopResponse.success(responsePagination);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__exportActivityApply__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.cardRecord.export", needInSession = NeedInSessionType.YES)
    @ApiOperation("导出访客记录")
    public RopResponse<String> exportBusinessCardRecord(CardRecordPageRopRequest ropRequest){
        try {
            String response = businessCardService.exportBusinessCardRecord(ropRequest);
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__exportBusinessCardRecord__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.page", needInSession = NeedInSessionType.NO)
    @ApiOperation("分页查找活动记录列表")
    public RopResponse<Pagination<BusinessCardActivityRecordRopResponse>> listActivityPage(ActivityRecordPageRopRequest ropRequest){
        try {
            Pagination<BusinessCardActivityRecordRopResponse> response = businessCardService.listActivityPage(ropRequest);
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.list", needInSession = NeedInSessionType.NO)
    @ApiOperation("获取活动记录全集")
    public RopResponse<List<BusinessCardActivityRecordRopResponse>> getActivityRecordList(ActivityRecordEmptyRopRequest ropRequest){
        try {
            List<BusinessCardActivityRecordRopResponse> response = businessCardService.getActivityRecordList();
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.add", needInSession = NeedInSessionType.YES)
    @ApiOperation("新增活动记录")
    public RopResponse<Boolean> addActivityRecord(BusinessCardActivityRecordRopRequest ropRequest){
        try {
            Boolean response = businessCardService.addActivityRecord(ropRequest);
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordAdd__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.update", needInSession = NeedInSessionType.YES)
    @ApiOperation("更新活动记录")
    public RopResponse<Boolean> updateActivityRecord(ActivityRecordUpdateRopRequest ropRequest){
        try {
            Boolean response = businessCardService.updateActivityRecord(ropRequest);
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordUpdate__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.detail", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据id查询活动记录详情")
    public RopResponse<BusinessCardActivityRecordRopResponse> findActivityRecordDetail(ActivityRecordIdRopRequest ropRequest){
        try {
            BusinessCardActivityRecordRopResponse response = businessCardService.findActivityRecordDetail(ropRequest.getId());
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordDetail__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.delete", needInSession = NeedInSessionType.YES)
    @ApiOperation("删除活动")
    public RopResponse<Boolean> deleteActivityRecord(ActivityRecordIdRopRequest ropRequest){
        try {
            Boolean response = businessCardService.deleteActivityRecord(ropRequest);
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordDelete__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.checkPhone", needInSession = NeedInSessionType.NO)
    @ApiOperation("检查登录用户是否是滴加智慧云的员工")
    public RopResponse<Boolean> checkPhone(ActivityRecordPhoneRopRequest ropRequest){
        try {
            Boolean response = businessCardService.checkPhone(ropRequest.getPhone());
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordCheckPhone__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.checkCooperate", needInSession = NeedInSessionType.NO)
    @ApiOperation("是否显示门店助手、生意助手按钮")
    public RopResponse<Boolean> checkCooperateByOpenId(ActivityRecordOpenIdRopRequest ropRequest){
        try {
            Boolean response = businessCardService.checkCooperateByOpenId(ropRequest.getOpenId());
            return RopResponse.success(response);
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordCheckCooperate__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.business.activityRecord.syn", needInSession = NeedInSessionType.YES)
    @ApiOperation("同步众筹活动")
    public RopResponse<BusinessCardActivityRecordRopResponse> synActivity(SynActivityRecordRopRequest ropRequest){
        try {
            return RopResponse.success(businessCardService.synActivity(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======ChannelCodeController__invoke__activityRecordsynActivity__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

}