package com.keyware.shandan.mark.controller;

import com.keyware.shandan.common.entity.Result;
import com.keyware.shandan.mark.pojo.MarkRecord;
import com.keyware.shandan.mark.services.MarkRecordService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author GuoXin
 * @date 2022-07-15
 */
@RestController
@RequestMapping("/mark/api/record")
public class MarkRecordController {

    @Autowired
    private MarkRecordService markRecordService;

    @PostMapping("/save/batch")
    public Result<Object> batchSave(BatchSaveParam param){
        return Result.of(markRecordService.saveOrUpdateBatch(param.getRecords()));
    }

    @GetMapping("/get/{entityId}")
    public Result<List<MarkRecord>> getByEntityId(@PathVariable String entityId){
        return Result.of(markRecordService.listByEntityId(entityId));
    }

    @Getter
    @Setter
    public static class BatchSaveParam{
        private List<MarkRecord> records;
    }
}
