package com.fjhx.controller.tda;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.params.tda.TdaDeviceEx;
import com.fjhx.params.tda.TdaDeviceVo;
import com.fjhx.service.tda.TdaDeviceService;
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-07-21
 */
@RestController
@RequestMapping("/tdaDevice")
public class TdaDeviceController {

    @Autowired
    private TdaDeviceService tdaDeviceService;

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

    @PostMapping("/add")
    public R add(@RequestBody TdaDeviceVo tdaDeviceVo) {
        tdaDeviceService.add(tdaDeviceVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody TdaDeviceVo tdaDeviceVo) {
        tdaDeviceService.delete(tdaDeviceVo);
        return R.success();
    }

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

}

