package com.fjhx.controller.check;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.check.CheckDetails;
import com.fjhx.params.check.CheckDetailsVo;
import com.fjhx.service.check.CheckDetailsService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
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.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-12-23
 */
@RestController
@RequestMapping("/checkDetails")
public class CheckDetailsController {

    @Autowired
    private CheckDetailsService checkDetailsService;

    @PostMapping("/list")
    public R list(@RequestBody Condition condition) {
        Long checkInfoId = condition.getLong("checkInfoId");
        List<Map<String, Object>> result = checkDetailsService.getList(checkInfoId);
        return R.success(result);
    }

    @PostMapping("/page")
    public R page(@RequestBody Map<String, Object> condition) {
        Page<CheckDetails> result = checkDetailsService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody CheckDetailsVo checkDetailsVo) {
        checkDetailsService.add(checkDetailsVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody CheckDetailsVo checkDetailsVo) {
        checkDetailsService.edit(checkDetailsVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody CheckDetailsVo checkDetailsVo) {
        checkDetailsService.delete(checkDetailsVo);
        return R.success();
    }

}

