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

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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 com.baomidou.mybatisplus.extension.service.IService;

import cn.com.ty.lift.ud.common.BaseController;
import cn.com.ty.lift.ud.common.DelReq;
import cn.com.ty.lift.ud.userAgreement.controller.query.UserAgreementQuery;
import cn.com.ty.lift.ud.userAgreement.mapper.entity.UserAgreement;
import cn.com.ty.lift.ud.userAgreement.service.IUserAgreementService;
import cn.com.xwy.boot.web.dto.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 协议 API
 * 
 * @author Xson
 * @date 2020-05-13
 */
@Api(tags = "协议 API")
@RestController
@RequestMapping("/api/userAgreements")
public class UserAgreementController extends BaseController<UserAgreement, UserAgreementQuery> {

    private final Logger log = LoggerFactory.getLogger(UserAgreementController.class);

    private @Autowired IUserAgreementService userAgreementService;

    @Override
    protected IService<UserAgreement> getService() {
        return userAgreementService;
    }

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

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

    // 根据条件查询
    @PostMapping("/query-page")
    @ApiOperation(value = "分页查询")
    public RestResponse getCondition(@RequestBody UserAgreementQuery request) {
        return userAgreementService.selectByExample(request);
    }
    
  //根据条件查询
    @GetMapping("/queryListCharge")
    @ApiOperation(value = "专家协议列表")
    public RestResponse queryListCharge() {
        return userAgreementService.queryListCharge();
    }
}