package com.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.common.service.DmColumnService;
import com.common.entity.DmColumn;
import com.common.service.DmNormalizeRuleService;
import com.common.entity.DmNormalizeRule;

import com.Modules.NormalData.LogNormalProcessor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;


@RestController
//@RequestMapping("/api")
public class DmColumnController {
    @Autowired
    private  DmColumnService dmColumnService;
    @Autowired
    private  DmNormalizeRuleService dmNormalizeRuleService;

    private static HashMap OrginalColumnMap ;

    public DmColumnController(DmColumnService dmColumnService) {
        this.dmColumnService = dmColumnService;
    }

    @GetMapping("/")
    public String home() {
        return "🚀 Spring Boot 应用运行正常！";
    }

    @GetMapping("/dmcolumn")
    public String getUsers() {

        return "用户列表";
    }

    @GetMapping("/dmcolumn/id")
    public String getDmcolumnByID () {
        //DmColumn  dmColumn=dmColumnService.findById((long)682);
        DmColumn  dmColumn=dmColumnService.findByDmColumnId((long)682);
        //List<Map<String, Object>> columnList=dmColumnService.selectAllNormal();
        //List<Map<String, Object>> rulelst=  dmNormalizeRuleService.selectByDeviceIdAuto((long)1);
        //OrginalColumnMap= getMessageToMap(strLogMsg);
       LogNormalProcessor  logNormalProcessor=new LogNormalProcessor( "", UUID.randomUUID().toString(),"test-topic");
       logNormalProcessor.init();

        return dmColumn.getDisplayName()  ;
        //return dmColumn.getDisplayName()  ;


    }
    @GetMapping("/rule/id/{id}")
    public  ResponseEntity<DmNormalizeRule> getById(@PathVariable Long id) {
        System.out.println("rule_id："+id.toString());
        DmNormalizeRule dmNormalizeRule=dmNormalizeRuleService.getById(id);
        System.out.println("dmNormalizeRuleService："+dmNormalizeRule.toString());
        return  ResponseEntity.ok(dmNormalizeRule);
    }


    @RequestMapping("/hello")
    public String hello() {
        return "Hello World";
    }
}
