package com.fjhx.iot.controller.tda;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.iot.entity.tda.dto.TdaProductDto;
import com.fjhx.iot.entity.tda.dto.TdaProductSelectDto;
import com.fjhx.iot.entity.tda.vo.TdaProductVo;
import com.fjhx.iot.service.tda.TdaProductService;
import com.ruoyi.common.core.domain.BaseSelectDto;
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;


/**
 * <p>
 * 产品管理 前端控制器
 * </p>
 *
 * @author zlj
 * @since 2023-03-21
 */
@DS(SourceConstant.IOT)
@RestController
@RequestMapping("/tdaProduct")
public class TdaProductController {

    @Autowired
    private TdaProductService tdaProductService;

    /**
     * 产品管理分页
     */
    @PostMapping("/page")
    public Page<TdaProductVo> page(@RequestBody TdaProductSelectDto dto) {
        return tdaProductService.getPage(dto);
    }

    /**
     * 产品管理明细
     */
    @PostMapping("/detail")
    public TdaProductVo detail(@RequestBody BaseSelectDto dto) {
        return tdaProductService.detail(dto.getId());
    }

    /**
     * 产品管理新增
     */
    @PostMapping("/add")
    public void add(@RequestBody TdaProductDto tdaProductDto) {
        tdaProductService.add(tdaProductDto);
    }

    /**
     * 产品管理删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        tdaProductService.delete(dto.getId());
    }

}
