package com.cpop.oam.framework.handler.wxCp;

import com.cpop.common.utils.JsonUtils;
import com.cpop.oam.business.service.StaffService;
import com.cpop.oam.framework.builder.wxCp.TextBuilder;
import com.cpop.oam.framework.constant.WxCpConstant;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 通讯录变更事件处理器.
 *
 * @author <a href="https://github.com/binarywang">Binary Wang</a>
 */
@Component
public class ContactChangeHandler extends AbstractHandler {

  @Autowired
  private StaffService staffService;

  @Override
  public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, WxCpService cpService, WxSessionManager sessionManager) {
    String content = "收到通讯录变更事件，内容：" + JsonUtils.toJson(wxMessage);
    this.logger.info(content);
    //通知处理
    switch (wxMessage.getChangeType()){
      case WxCpConstant.CREATE_USER:
        //staffService.createWxCpUser(wxMessage, cpService);
        break;
      case WxCpConstant.UPDATE_USER:
        break;
      case WxCpConstant.DELETE_USER:
        break;
      case WxCpConstant.CREATE_DEPT:
        break;
      case WxCpConstant.UPDATE_DEPT:
        break;
      case WxCpConstant.DELETE_DEPT:
        break;
      default:
    }
    return new TextBuilder().build(content, wxMessage, cpService);
  }

}
