package com.qianhe.zqbf.controller;

import com.qianhe.common.core.controller.BaseController;
import com.qianhe.common.core.domain.AjaxResult;
import com.qianhe.common.exception.BusinessException;
import com.qianhe.zqbf.domain.ZqbfXmzBfxm;
import com.qianhe.zqbf.domain.ZqbfXmzBfzj;
import com.qianhe.zqbf.domain.ZqczXmzBfjlQuery;
import com.qianhe.zqbf.domain.ZqczXmzDdzj;
import com.qianhe.zqbf.service.ZqczXmzDdzjService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/zqbf/ddzj")
public class ZqczXmzDdzjController extends BaseController {
    @Autowired
    private ZqczXmzDdzjService xmzDdzjService;

    /**
     * 分页查询
     */
    @GetMapping("/list")
    public AjaxResult list(ZqczXmzDdzj zqczXmzDdzj) {
        try {
            return success(xmzDdzjService.list(zqczXmzDdzj));
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }

    /**
     * 新增
     */
    @PostMapping
    public AjaxResult batchAdd(@RequestBody List<ZqbfXmzBfzj> xmzBfzjList) {
        try {
            return toAjax(xmzDdzjService.batchAdd(xmzBfzjList));
        } catch (BusinessException e) {
            log.warn("最强帮扶-调度专家-新增失败：" + e.getMessage());
            return warn(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage());
            return error(e.getMessage());
        }
    }
}
