package com.mortals.xhx.daemon.demo;

import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

/**
 * @author karlhoo
 */
@CommonsLog
@RestController
@RequestMapping("test")
public class RequestDispatchController {




    /**
     * json提交
     *
     * @param info
     * @return
     */
    @PostMapping("/getHcpSin/json")
    public String submitJson(@RequestBody TestInfo info) {

        return "json submit ok";
    }

    /**
     * form提交
     *
     * @param
     * @return
     */
    @PostMapping("/getHcpSin/form")
    public String submitForm(TestInfo info) {

        return "form submit ok";
    }

    /**
     * json提交
     *
     * @param
     * @return
     */
    @PostMapping("/other")
    public String other() {

        return "200";
    }


    public static void main(String[] args) {


        File file = new File("E:\\test.txt");

        String json = FileUtil.readString(file, "utf-8");

        System.out.println(json);

        json = json.replaceAll("\\\\", "\\\\\\\\");

        JSONObject jsonObject = JSONObject.parseObject(json);

        //RequestDispatchController.buildJson(json);

//        Map<String, String> map = new HashMap<>();
//
//        map.put("1","纸质");
//        map.put("2","纸质");
//
//        BiMap<String, String> inverse = HashBiMap.create(map).inverse();
//        String value = inverse.getOrDefault("纸质", "0");
//
//
//        System.out.println(value);


    }

}
