package shop.alien.store.controller;

import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.StoreCustomerService;
import shop.alien.store.service.StoreCustomerServiceService;

/**
 * <p>
 * 智能客服
 * </p>
 *
 * @author ssk
 * @since 2024-12-30
 */
@Api(tags = {"二期-智能客服"})
@Slf4j
@ApiSort(10)
@CrossOrigin
@RestController
@RequestMapping("/storeCustomerService")
@RequiredArgsConstructor
public class StoreCustomerServiceController {

    private final StoreCustomerServiceService storeCustomerServiceService;

    @ApiOperation("通过关键字获取答案")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams({@ApiImplicitParam(name = "question", value = "问题关键字", dataType = "String", paramType = "query", required = true)})
    @GetMapping("/getByQuestion")
    public R<StoreCustomerService> getByQuestion(@RequestParam String question) {
        StoreCustomerService result = storeCustomerServiceService.getByQuestion(question);
        if (null == result) {
            return R.fail("暂未搜索到相应答案");
        }
        return R.data(result);
    }

}
