package org.jeecg.modules.newWarning.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.newWarning.entity.WorkCondition;
import org.jeecg.modules.newWarning.service.WorkConditionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/newWarn/workCondition")
public class WorkConditionController {

    @Resource
    private WorkConditionService workConditionService;

    @GetMapping("/one")
    public Result<?> one(@RequestParam("jh")String jh){
        QueryWrapper<WorkCondition> wrapper=new QueryWrapper<>();
        WorkCondition res;
        System.out.println("jh:"+jh);
        wrapper.eq("jh",jh);
        WorkCondition one = workConditionService.getOne(wrapper);
        System.out.println("参数数据:"+one);
        if(one==null){
            QueryWrapper<WorkCondition> wrapper1=new QueryWrapper<>();
            wrapper1.eq("jh","0");
            res = workConditionService.getOne(wrapper1);
            System.out.println("参数数据1:"+res);
            return Result.OK(res);
        }
        res=one;
        return Result.OK(res);
    }
    @PostMapping("/save")
    public Result<?> save(@RequestBody WorkCondition workCondition){
        workConditionService.saveOrUpdate(workCondition);
        return Result.OK();
    }
}
