package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.ActMaterialModel;
import com.ruoyi.system.service.ActReadDataService;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
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;

/**
 * 2024/3/21
 */
@RestController
@RequestMapping("act/read/data")
public class ActReadDataController {
    private ActReadDataService actReadDataService;
    public ActReadDataController(ActReadDataService actReadDataService){
        this.actReadDataService = actReadDataService;
    }
    @PostMapping("/historyContentCopy")
    public AjaxResult historyContentCopy(@RequestBody @Validated ActMaterialModel actMaterialModel, BindingResult bindingResult) {
        if (bindingResult.hasErrors()){
            return AjaxResult.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return actReadDataService.read(actMaterialModel.getMineId());
    }

    @PostMapping("/readOfMId")
    public AjaxResult readOfMId(@RequestBody @Validated ActMaterialModel actMaterialModel, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return AjaxResult.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return actReadDataService.readOfMId(actMaterialModel.getMineId(), actMaterialModel.getDateNY());
    }

    @PostMapping("/delectOfMId")
    public AjaxResult delectOfMId(@RequestBody @Validated ActMaterialModel actMaterialModel, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return AjaxResult.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return actReadDataService.delectOfMId(actMaterialModel.getMineId(), actMaterialModel.getDateNY());
    }
}
