package cn.com.ty.lift.ud.templateBase.controller;

import cn.com.ty.lift.ud.common.BaseController;
import cn.com.ty.lift.ud.common.DelReq;
import cn.com.ty.lift.ud.templateBase.controller.query.MaintenanceOptionQuery;
import cn.com.ty.lift.ud.templateBase.mapper.entity.MaintenanceOptionEntity;
import cn.com.ty.lift.ud.templateBase.service.IMaintenanceOptionService;
import cn.com.xwy.boot.web.dto.RestResponse;
import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;

/**
 * 维保项 API
 * 
 * @author Xson
 * @date 2020-04-23
 */
@Api(tags = "维保项 API- 小陶")
@RestController
@RequestMapping("/api/maintenanceOptions")
public class MaintenanceOptionController extends BaseController<MaintenanceOptionEntity,MaintenanceOptionQuery> {

    private final Logger log = LoggerFactory.getLogger(MaintenanceOptionController.class);
    
    private @Autowired IMaintenanceOptionService maintenanceOptionService;

    @Override
    protected IService<MaintenanceOptionEntity> getService() {
        return maintenanceOptionService;
    }

    @ApiOperation(value = "批量启用")
    @PostMapping("/useBath")
    public RestResponse useBath(@RequestBody DelReq req) {
        maintenanceOptionService.updateByIds(req.getIds(), 1);
        return RestResponse.success(null, "启用成功");
    }

    @ApiOperation(value = "批量关闭")
    @PostMapping("/noUseBath")
    public RestResponse noUseBath(@RequestBody DelReq req) {
        maintenanceOptionService.updateByIds(req.getIds(), 0);
        return RestResponse.success(null, "关闭成功");
    }

}