package com.docus.server.collect.user.http;

import com.docus.server.sys.common.pojo.dto.UserDTO;
import com.docus.server.collect.IConverter;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * 被动ws和http转化器
 */
@Component("httpUserConverter")
public class HttpUserConverter implements IConverter<UserDTO> {

    @Override
    public UserDTO convert(String message, String group) {
//        XmlUtil xmlParseUtil = XmlUtil.of(message);
//        Node msgIdNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/id/@extension");
//        Node receiverNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/receiver/device/id/item/@extension");
//        Node operateTypeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/@operateType");
//        Node employeeCodeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/EMPL_CODE/@value");
//        Node employeeNameNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/EMPL_NAME/@value");
//        Node deptCodeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/DEPT_CODE/@value");
//        Node positionNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/POSI_NAME/@value");
//        Node authorIdNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/author/assignedEntity/id/item/@extension");
//        Node authorNameNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/author/assignedEntity/assignedPerson/name/item/part/@value");
//        UserDTO userDTO = new UserDTO();
//        userDTO.setDeptId(deptCodeNode.getNodeValue());
//        userDTO.setReceiver(receiverNode.getNodeValue());
//        userDTO.setOperateType(operateTypeNode.getNodeValue());
//        userDTO.setUserName(employeeCodeNode.getNodeValue());
//        userDTO.setName(employeeNameNode.getNodeValue());
//        userDTO.setPosition(positionNode.getNodeValue());
//        userDTO.setAuthorId(authorIdNode.getNodeValue());
//        userDTO.setMessageId(msgIdNode.getNodeValue());
//        userDTO.setAuthorName(authorNameNode.getNodeValue());
//        userDTO.setRoleId(0L);
//
//        userDTO.setParams(ParamsUtils.addParam("msg", "操作成功！")
//            .addParam("msgId", userDTO.getMessageId())
//            .addParam("receiver", userDTO.getReceiver())
//            .param());


        UserDTO userDTO = new UserDTO();
        userDTO.setDeptId("1");
        userDTO.setReceiver("2");
        userDTO.setOperateType("3");
        userDTO.setUserName("4");
        userDTO.setName("5");
        userDTO.setPosition("6");
        userDTO.setAuthorId("7");
        userDTO.setMessageId(UUID.randomUUID().toString());
        userDTO.setAuthorName("9");
        userDTO.setRoleId(0L);

//        userDTO.setParams(ParamsUtils.addParam("msg", "操作成功！")
//                .addParam("msgId", userDTO.getMessageId())
//                .addParam("receiver", userDTO.getReceiver())
//                .param());


        return userDTO;
    }

}
