package com.fufan.mtsaas.modules.sysmgr.sylogtemp.controller;


import com.fufan.mtsaas.modules.common.bo.request.ResultPack;
import com.fufan.mtsaas.modules.common.bo.response.RequestPojo;
import com.fufan.mtsaas.modules.common.bo.response.Result;
import com.fufan.mtsaas.modules.sysmgr.sylogtemp.service.SyinplogSvc;
import com.fufan.mtsaas.modules.common.bo.request.ResultPack;
import com.fufan.mtsaas.modules.sysmgr.sylogtemp.model.Syinplog;
import com.fufan.mtsaas.modules.common.bo.response.RequestPojo;
import com.fufan.mtsaas.modules.common.bo.response.Result;
import com.fufan.mtsaas.modules.sysmgr.sylogtemp.service.SyinplogSvc;
import com.fufan.mtsaas.util.ParamUtil;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * <p>
 * 
 * </p>
 *
 * @author Liby
 * @since 2019-09-11
 */
@Slf4j
@Api(tags = "MTSaas：系统管理-日志消息模块", description = "Syinplog对象接口")
@RestController
@RequestMapping("/SYS/Syinplog")
public class SyinplogCtrl {
    @Autowired
    private SyinplogSvc targetService;

    /**
     * 分页查询
     * */
    @ApiOperation(value = "分页查询所有，根据需要传入分页参数：pageSize每页数量(默认为10)，currentPage当前页数(默认为1)", httpMethod = "POST", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "公司标识", name = "CompanyID", dataType = "string", required = true),
            @ApiImplicitParam(value = "导入用户ID", name = "UserID", dataType = "string", required = false),
            @ApiImplicitParam(value = "事件随机编号", name = "ExpID", dataType = "integer", required = false),
            @ApiImplicitParam(value = "调用脚本名称", name = "SPID", dataType = "integer", required = false)
    })
//    @PostMapping(value ="/doQueryPage")
    public Result<Syinplog> doQueryPage(@RequestParam @ApiIgnore Map<String,String> map){
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        return resultPack.doResultPack(targetService.doQueryPage(map),requestPojo.getIntfId(),requestPojo.getAppKey());
    }

    /**
     * 新增
     * */
    @ApiOperation(value = "新增", httpMethod = "POST", produces = "application/json")
    @ApiResponses({
            @ApiResponse(code = 4001, message = "参数错误"),
            @ApiResponse(code = 3002, message = "已存在"),
            @ApiResponse(code = 3003, message = "新增出错")
    })
//    @RequestMapping(value = "/doSave", method = RequestMethod.POST)
    public Result<Syinplog> doSaveMap(@RequestBody String entity, @ApiIgnore HttpSession session){
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        return resultPack.doResultPack(targetService.doSaveMap(entity.toString(),requestPojo),requestPojo.getIntfId(),requestPojo.getAppKey());
    }

    /**
     * 修改
     * */
    @ApiOperation(value = "修改", httpMethod = "POST", produces = "application/json")
    @ApiResponses({
            @ApiResponse(code = 4001, message = "参数错误"),
            @ApiResponse(code = 3002, message = "已存在"),
            @ApiResponse(code = 3003, message = "修改出错")
    })
//    @RequestMapping(value = "/doUpdate", method = RequestMethod.POST)
    public Result<Syinplog> doUpdateMap(@RequestBody String entity, @ApiIgnore HttpSession session){
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        return resultPack.doResultPack(targetService.doUpdateMap(entity,requestPojo),requestPojo.getIntfId(),requestPojo.getAppKey());
    }

    /**
     * 新增
     * */
    @ApiOperation(value = "新增", httpMethod = "POST", produces = "application/json")
    @ApiResponses({
            @ApiResponse(code = 4001, message = "参数错误"),
            @ApiResponse(code = 3002, message = "已存在"),
            @ApiResponse(code = 3003, message = "新增出错")
    })
//    @RequestMapping(value = "/doSave1", method = RequestMethod.POST)
    public Result<Syinplog> doSave(@RequestBody Syinplog entity){
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        return resultPack.doResultPack(targetService.doSave(entity,requestPojo),requestPojo.getIntfId(),requestPojo.getAppKey());
    }

    /**
     * 修改
     * */
    @ApiOperation(value = "修改", httpMethod = "POST", produces = "application/json")
    @ApiResponses({
            @ApiResponse(code = 4001, message = "参数错误"),
            @ApiResponse(code = 3002, message = "已存在"),
            @ApiResponse(code = 3003, message = "修改出错")
    })
//    @RequestMapping(value = "/doUpdate1",method = RequestMethod.POST)
    public Result<Syinplog> doUpdate(@RequestBody Syinplog entity){
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        return resultPack.doResultPack(targetService.doUpdate(entity,requestPojo),requestPojo.getIntfId(),requestPojo.getAppKey());
    }

    /**
     * 删除数据
     * */
    @ApiOperation(value = "删除数据", httpMethod = "DELETE", produces = "application/json")
    @ApiResponses({
            @ApiResponse(code = 4001, message = "参数错误"),
            @ApiResponse(code = 3003, message = "删除出错")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(value = "公司标识", name = "CompanyID", dataType = "string", required = true),
            @ApiImplicitParam(value = "导入用户ID", name = "UserID", dataType = "string", required = true),
            @ApiImplicitParam(value = "事件随机编号", name = "ExpID", dataType = "integer", required = true)
    })
//    @RequestMapping(value = "/doDelete", method = RequestMethod.DELETE)
    public Result doDelete(@RequestParam @ApiIgnore Map<String,String> map){
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        return resultPack.doResultPack(targetService.doDelete(map,requestPojo),requestPojo.getIntfId(),requestPojo.getAppKey());
    }
	
}
