package com.engine.kq.cmd.reportfielddefine;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.DBUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DeleteReportMoudleCmd extends AbstractCommonCommand<Map<String, Object>> {

  public DeleteReportMoudleCmd(Map<String, Object> params, User user) {
    this.user = user;
    this.params = params;
  }

  @Override
  public Map<String, Object> execute(CommandContext commandContext) {
    Map<String, Object> retmap = new HashMap<String, Object>();
    String sql = "";
    RecordSet rs = new RecordSet();
    try {

      String ids = Util.null2String(params.get("ids"));

      List sqlParams = new ArrayList();
      Object[] objects= DBUtil.transListIn(ids,sqlParams);

      sql = " delete from kq_report_moudle where id in ("+objects[0]+")";
      rs.executeUpdate(sql, sqlParams);

      retmap.put("status", "1");
    } catch (Exception e) {
      this.writeLog(e);
      retmap.put("status", "-1");
      retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage()));
    }
    return retmap;
  }

  @Override
  public BizLogContext getLogContext() {
    return null;
  }

}
