package cn.stylefeng.guns.modular.demovalue.controller;

import cn.hutool.core.util.RandomUtil;
import cn.stylefeng.guns.modular.demovalue.pojo.PostRequestParam;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@ApiResource(name = "一些默认数据的示例")
public class GunsDefaultValueController {

    @GetResource(name = "GET_获取默认数据", path = "/demoData/randomString")
    public ResponseData<String> randomStringGet(@RequestParam(value = "fieldOne", required = false) String fieldOne) {
        System.out.println("fieldOne：" + fieldOne);
        return new SuccessResponseData<>(RandomUtil.randomString(10));
    }

    @PostResource(name = "POST_获取默认数据", path = "/demoData/randomString/post")
    public ResponseData<String> randomStringPost(@RequestBody PostRequestParam postRequestParam) {
        System.out.println("postRequestParam：" + postRequestParam);
        return new SuccessResponseData<>(RandomUtil.randomString(10));
    }

}
