package cn.com.countrygarden.bi.main.controller.ck;
import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dto.ck.CkCleanerFieldConfigQuery;
import cn.com.countrygarden.bi.main.dto.ck.CkCleanerVo;
import cn.com.countrygarden.bi.main.model.ck.CkCleanerFieldConfig;
import cn.com.countrygarden.bi.main.service.ck.CkCleanerFieldConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;


/**
 * 字段配置表-业务逻辑层实现
 *
 * @author 李森林
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2020-04-13
 */
@RestController("CkCleanerFieldConfigController")
@RequestMapping("/api/ckCleanerFieldConfig")
public class CkCleanerFieldConfigController extends BaseController{
    @Autowired
    private CkCleanerFieldConfigService ckCleanerFieldConfigService;


    @GetMapping(value = "/list", produces = "application/json;charset=utf-8")
    public Result list(CkCleanerFieldConfigQuery query,
                       HttpServletRequest request){
        return  ckCleanerFieldConfigService.queryPageList(query);
    }

    @GetMapping(value = "/one", produces = "application/json;charset=utf-8")
    public Result queryById(@RequestParam(value = "id", required = true)Integer id,
                            HttpServletRequest request){
        return  ckCleanerFieldConfigService.queryById(id);
    }

    @PostMapping(value = "/addOrEdit")
    public Result add(CkCleanerFieldConfig ckCleanerFieldConfig,
                      HttpServletRequest request){
        return  ckCleanerFieldConfigService.addOrEdit(ckCleanerFieldConfig,getAccessToken(request));
    }


    @DeleteMapping(value="/del")
    public Result del(@RequestParam(value = "id")Integer id,HttpServletRequest request){
        return  ckCleanerFieldConfigService.del(id,getAccessToken(request));
    }

    @GetMapping(value = "/optionList", produces = "application/json;charset=utf-8")
    public Result optionData(CkCleanerVo query){
        query.setType(0);
        query.setStatus(1);
        return Response.response(ckCleanerFieldConfigService.optionList(query));
    }
    @GetMapping(value="/statusEdit",produces = "application/json;charset=utf-8")
    public Result statusEdit(@RequestParam(value = "id")Integer id,@RequestParam(value = "status")Integer status,HttpServletRequest request){
        return  ckCleanerFieldConfigService.statusEdit(id,status,getAccessToken(request));
    }
}