package com.sonic.pigeon.controller.api;

import com.sonic.common.rpc.Result;
import com.sonic.pigeon.lib.input.CreateConversationInput;
import com.sonic.pigeon.lib.input.CreateImUserInput;
import com.sonic.pigeon.lib.input.UpdateConversationInput;
import com.sonic.pigeon.service.ImConversationService;
import com.sonic.pigeon.service.ImUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * API-会话处理
 * @author coder
 */
@Validated
@RestController
public class ImConversationApi {

    @Autowired
    private ImConversationService imConversationService;

    @ApiOperation(value = "创建会话", tags = {"API-会话处理"})
    @PostMapping("/api/im-conversation/create")
    public Result<Void> createImConversation(@RequestBody @Valid CreateConversationInput input) {
        imConversationService.createConversation(input);
        return Result.success();
    }

    @ApiOperation(value = "更新会话扩展字段", tags = {"API-会话处理"})
    @PostMapping("/api/im-conversation/update")
    public Result<Void> updateImConversation(@RequestBody @Valid UpdateConversationInput input) {
        imConversationService.updateConversationExtension(input);
        return Result.success();
    }

}
