package com.docus.server.collect.user.ws.impl;

import com.docus.core.util.json.JSON;
import com.docus.log.annotation.TrackGroup;
import com.docus.log.context.TrackHelper;
import com.docus.server.collect.IConverter;
import com.docus.server.collect.IWsResult;
import com.docus.server.collect.user.ws.IUserServer;
import com.docus.server.collect.web.process.VisitorProcessor;
import com.docus.server.collect.web.service.CollectService;
import com.docus.server.enums.CollectTypeEnum;
import com.docus.server.sys.common.pojo.dto.UserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author wen yongbin
 * @date 2023年2月25日21:56:33
 * @see CollectTypeEnum 枚举
 * @see IConverter 通用转化器
 * @see IWsResult 通用返回结果
 * @see VisitorProcessor#initBeans(String[])  通用处理器
 */
@Service
@Slf4j
public class UserServerImpl implements IUserServer {
    @Resource
    private CollectService collectService;

    /**
     * ws 用户信息接收，进行操作
     *
     * @param message 接收到的用户参数
     * @return 返回结果
     */
    @Override
    @TrackGroup(
        group = "WEBSERVICE_XML_USER", retryKey = "user",
        beanNames = {"wsUserConverter", "wsUserResultImpl"},
        processor = VisitorProcessor.class)
    public String userModify(String message) {
        log.info("新增/修改用户数据：{}", message);
        collectService.insertOrUpdateUser(JSON.fromJSON((String) TrackHelper.getValue("jsonStr"), UserDTO.class));
        return null;
    }

}

