ReceptionCustomerFileController.java 2.77 KB
package cn.com.glsx.dj.script.controller;

import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.remote.ReceptionCustomerFileRemote;
import cn.com.glsx.dj.script.request.customer.ReceptionCustomerFileIdRequest;
import cn.com.glsx.dj.script.request.customer.ReceptionCustomerFileUpdateRequest;
import cn.com.glsx.dj.script.utils.CommonUtil;
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;

/**
 * 客户档案管理
 */
@Slf4j
@Api("客户档案管理")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class ReceptionCustomerFileController {

    @Autowired
    private ReceptionCustomerFileRemote receptionCustomerFileRemote;

    @ApiOperation("查询客户档案详情")
    @ServiceMethod(method = "dj.api.script.customer.file.detail", needInSession = NeedInSessionType.NO)
    public RopResponse<ReceptionCustomerFileDetailDTO> findDetailByReceptionId(ReceptionCustomerFileIdRequest request) {
        try {
            return CommonUtil.convertRopResponse(receptionCustomerFileRemote.findDetailByReceptionId(request.getReceptionId()));
        } catch (RpcServiceException e) {
            log.error("=====查询客户档案详情 rpcServiceException:{}", e.getMessage(), e);
            return RopResponse.error(e);
        } catch (Exception e) {
            log.error("=====查询客户档案详情 exception:{}", e.getMessage(), e);
            return RopResponse.error("查询客户档案详情失败");
        }
    }

    @ApiOperation("更新客户档案")
    @ServiceMethod(method = "dj.api.script.customer.file.update", needInSession = NeedInSessionType.NO)
    public RopResponse<Boolean> updateCustomerFile(ReceptionCustomerFileUpdateRequest request) {
        ReceptionCustomerFileUpdateRequestDTO dto = CommonUtil.convertRequest(ReceptionCustomerFileUpdateRequestDTO.class);
        try {
            return CommonUtil.convertRopResponse(receptionCustomerFileRemote.updateCustomerFile(dto));
        } catch (RpcServiceException e) {
            log.error("=====更新客户档案 rpcServiceException:{}", e.getMessage(), e);
            return RopResponse.error(e);
        } catch (Exception e) {
            log.error("=====更新客户档案 exception:{}", e.getMessage(), e);
            return RopResponse.error("更新客户档案失败");
        }
    }
}