package com.tofly.xrtygis.custom.controller.dma;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.entity.Dmaicf;
import com.tofly.xrtygis.entity.Dmapietype;
import com.tofly.xrtygis.service.DmaicfService;
import com.tofly.xrtygis.service.DmapietypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author FlashWJL
 * @date 2021/5/22 14:14
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dmaicf")
@Api(tags = "分区计量--对应设施管材以及ICF值状况")
public class CustomIcfController {

    private final DmaicfService dmaicfService;
    private final DmapietypeService dmapietypeService;


    /**
     * 分页查询
     *
     * @param page       分页对象
     * @param dmapietype 分区计量ICF管材类别表
     * @return
     */
    @GetMapping("/type")
    @ApiOperation(value = "管材类别分页查询")
    public ResultRespone getDmapietypePage(Page page, @ModelAttribute Dmapietype dmapietype) {
        return ResultRespone.success(dmapietypeService.page(page, Wrappers.query(dmapietype)));
    }

    /**
     * 分页查询
     *
     * @param page   分页对象
     * @param dmaicf 分区计量对应的基础设施的状况因子表
     * @return
     */
    @GetMapping("/icf")
    @ApiOperation(value = "ICF值分页查询")
    public ResultRespone getDmaicfPage(Page<Dmaicf> page, @ModelAttribute Dmaicf dmaicf) {
        return ResultRespone.success(dmaicfService.selectICF(page, dmaicf));
    }


    /**
     * 修改分区计量对应的基础设施的状况因子表
     *
     * @param dmaicf 分区计量对应的基础设施的状况因子表
     * @return ResultRespone
     */
    //(title = "修改分区计量对应的基础设施的状况因子表ICF")
    @ApiOperation(value = "修改分区计量对应的基础设施的状况因子表ICF")
    @PostMapping("/icfUpdate")
    public ResultRespone updateById(@RequestBody Dmaicf dmaicf) {
        Long id = dmaicf.getId();
        String icf = dmaicf.getIcf();
        return ResultRespone.success(dmaicfService.update(Wrappers.<Dmaicf>lambdaUpdate()
                .eq(Dmaicf::getId, id).set(Dmaicf::getIcf, icf)));
    }
    /**
     * 修改分区计量ICF管材类别表
     * @param dmapietype 分区计量ICF管材类别表
     * @return ResultRespone
     */
    //(title="修改分区计量管材类别表" )
    @ApiOperation(value = "修改分区计量管材类别表")
    @PostMapping("/updateType")
    public ResultRespone updateById(@RequestBody Dmapietype dmapietype) {
        return ResultRespone.success(dmapietypeService.updateById(dmapietype));
    }




}
