BillingLogServiceImpl.java 1.82 KB
package com.zteits.bill.biz.billlog;

import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSONObject;

import com.zteits.bill.dao.billlog.BillingLogDao;
import com.zteits.bill.domain.TBillingLogs;
import com.zteits.clouds.api.apibase.bean.BizResult;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.bill.billinglog.dto.BillingLogDTO;
import com.zteits.clouds.api.dto.bill.billinglog.param.BillingLogByIdQueryReq;
import com.zteits.clouds.api.service.bill.billlog.BillingLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright: Copyright (c) 2017  zteits
 *
 * @ClassName: com.zteits.bill.biz.billlog
 * @Description:
 * @version: v1.0.0
 * @author: atao
 * @date: 2017/11/13   下午3:36
 * Modification History:
 * Date         Author          Version      Description
 * ---------------------------------------------------------*
 * 2017/11/13      atao          v1.0.0          创建
 */
@Component
public class BillingLogServiceImpl implements BillingLogService {

    @Autowired
    private BillingLogDao billingLogDao;

    @Override
    public BizResult<BillingLogDTO> queryBillingLogById(BillingLogByIdQueryReq req) {
        if (StringUtils.isBlank(req.getId())) {
            throw new BizException(ErrorType.PARAMM_NULL, "计费日志ID");
        }

        TBillingLogs billingLogs = billingLogDao.queryBillingLogById(req.getId());

        if (StringUtils.isBlank(billingLogs.getLogDetail())) {
            throw new BizException(ErrorType.BIZ_ERROR, "计费日志不存在");
        }

        BillingLogDTO dto = JSONObject.parseObject(billingLogs.getLogDetail(), BillingLogDTO.class);

        return new BizResult<>(dto);
    }
}