package com.diagbot.facade;

import com.diagbot.enums.IsDeleteEnum;
import com.diagbot.service.impl.ModuleInfoServiceImpl;
import com.diagbot.util.DateUtil;
import com.diagbot.util.StringUtil;
import com.diagbot.util.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author:zhoutg
 * @time: 2018/11/23 11:37
 */
@Component
public class ModuleInfoFacade extends ModuleInfoServiceImpl {


    @Autowired
    ModuleDetailFacade moduleDetailFacade;

    /**
     * 根据id删除标签模板
     *
     * @param ids
     * @return
     */
    public Boolean deleteByIdsFac(String ids) {
        if (StringUtil.isEmpty(ids)) {
            return true;
        }
        Map paramMap = new HashMap<>();
        paramMap.put("delete", IsDeleteEnum.Y.getKey());
        paramMap.put("ids", Arrays.asList(ids.split(",")));
        paramMap.put("gmtModified", DateUtil.now());
        paramMap.put("modifier", UserUtils.getCurrentPrincipleID());

        //删除模板
        this.deleteByIds(paramMap);

        //删除明细表
        moduleDetailFacade.deleteByModuleIdFac(paramMap);
        return true;
    }
}
