package com.example.demo.controller;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@SpringBootApplication
@Tag(name ="你的接口",description = "test")
public class ControllerText {
    @Operation(summary = "获取用户列表",description = "test")
    @RequestMapping("getUser")

    public Map<String, Object> getUser(){
        System.out.println("微信小程序正在调用。。。");
        Map<String, Object> map = new HashMap<String, Object>();
        List<String> list = new ArrayList<String>();
        list.add("zhangsan");
        list.add("lisi");
        list.add("wanger");
        list.add("mazi");
        map.put("list",list);
        System.out.println("微信小程序调用完成。。。");
        return map;
    }
    @Operation(summary = "获取用户表",description = "test")
    @RequestMapping("getWord")
    public Map<String, Object> getText(String word){
        Map<String, Object> map = new HashMap<String, Object>();
        String message = "我能力有限，不要为难我";
        if ("后来".equals(word)) {
            message="正在热映的后来的我们是刘若英的处女作。";
        }else if("微信小程序".equals(word)){
            message= "想获取更多微信小程序相关知识，请更多的阅读微信官方文档，还有其他更多微信开发相关的内容，学无止境。";
        }else if("cauc".equals(word)){
            message="yes";
        }
        map.put("message", message);
        return map;
    }
    @Operation(summary = "获取列表",description = "test")
    @RequestMapping("")
    public String getText(){
        return "hello world";
    }

    @Autowired
    JdbcTemplate jct;
    @Operation(summary = "取用户列表",description = "test")
    @GetMapping("userslist")
    public List<Map<String, Object>> userlist(){
        String sql = "select * from user";
        List<Map<String, Object>> map = jct.queryForList(sql);
        System.out.println("调用sql");
        return map;
    }


}
