package com.brilliance.isc.common.api.xxd.service.impl;

import com.brilliance.isc.common.api.xxd.service.XxdService;
import com.brilliance.isc.mda.dao.PublicMapper;
import com.google.common.collect.ImmutableBiMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class XxdServiceImpl implements XxdService {

    @Autowired
    private PublicMapper publicMapper;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public int updateFlwstaByObjinr(String objtyp, String inr) {
        if("GID|NID|LID|BRD|LED|BED|LTD|BTD|DID|BDD|DED|BFD|BCD|BOD|CCD|CPD|JSD|BPD|TRD|MCD".contains(objtyp.toUpperCase())){
           String  sql = String.format(" update %s set flwsta = '%s' where inr = '%s'", objtyp, "R", inr);
            logger.info("当前【"+ objtyp + "】业务已更新flwsta,更新主键【" + inr +"】");
           return publicMapper.updateByTableNameAndInr(ImmutableBiMap.of("sql", sql));
        }
        return 0;
    }
}
