package com.huimv.manage.eartag.controller;

import com.huimv.manage.eartag.service.impl.BusinessConfigService;
import com.huimv.manage.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.biosafety.uface.controller
 * @Description : TODO
 * @Version : 1.0
 * @Author : ZhuoNing
 * @Create : 2020-12-25
 **/
@CrossOrigin
@RestController
@Slf4j
@RequestMapping(value = "/system/config")
public class BusinessConfigController {
    @Autowired
    private BusinessConfigService configService;

    /**
     * @Method      : listEarmark
     * @Description : 展示列表
     * @Params      : [paramType, pageSize, pageNo]
     * @Return      : com.huimv.manage.util.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/11/10       
     * @Time        : 20:57
     */
    @RequestMapping(value = "/listConfigParam",method = RequestMethod.GET)
    public Result listConfigParam(
            @RequestParam(value = "paramType",required = false) String paramType,
            @RequestParam(value = "pageSize",required = true) Integer pageSize,
            @RequestParam(value = "pageNum", required = true) Integer pageNo){
        log.info("输入参数-->");
        log.info("paramType="+paramType);
        log.info("pageSize="+pageSize);
        log.info("pageNum="+pageNo);
        //
        return configService.listConfigParam(paramType,pageSize,pageNo);
    }

    /**
     * @Method      : addConfigParam
     * @Description : 添加配置参数
     * @Params      : [paramName, paramId, aramValue, paramType, remark]
     * @Return      : com.huimv.manage.util.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/11/10       
     * @Time        : 21:03
     */
    @RequestMapping(value = "/addConfigParam",method = RequestMethod.GET)
    public Result addConfigParam(@RequestParam(value = "paramName") String paramName,
                                 @RequestParam(value = "paramId") String paramId,
                                 @RequestParam(value = "paramValue") String paramValue,
                                 @RequestParam(value = "paramType") String paramType,
                                 @RequestParam(value = "remark") String remark){
        //
        return configService.addConfigParam(paramName,paramId,paramValue,paramType,remark);
    }

    /**
     * @Method      : editConfigParam
     * @Description : 编辑配置参数
     * @Params      : [id, paramName, paramId, aramValue, paramType, remark]
     * @Return      : com.huimv.manage.util.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/11/10       
     * @Time        : 21:04
     */
    @RequestMapping(value = "/editConfigParam",method = RequestMethod.GET)
    public Result editConfigParam(@RequestParam(value = "id") Integer id,
                                  @RequestParam(value = "paramName") String paramName,
                                  @RequestParam(value = "paramId") String paramId,
                                  @RequestParam(value = "paramValue") String paramValue,
                                  @RequestParam(value = "paramType") String paramType,
                                  @RequestParam(value = "remark") String remark){
        log.info("输入参数-->");
        log.info("id="+id);
        log.info("paramName="+paramName);
        log.info("paramId="+paramId);
        log.info("paramValue="+paramValue);
        log.info("paramType="+paramType);
        log.info("remark="+remark);
        //
        return configService.editConfigParam(id,paramName,paramId,paramValue,paramType,remark);
    }

    /**
     * @Method      : editConfigParam
     * @Description : 删除配置参数
     * @Params      : [ids]
     * @Return      : com.huimv.manage.util.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/11/10       
     * @Time        : 20:54
     */
    @RequestMapping(value = "/removeConfigParam",method = RequestMethod.GET)
    public Result editConfigParam(@RequestParam(value = "ids") String ids){
        //
        return configService.removeConfigParam(ids);
    }
    
    /**
     * @Method      : getConfigParam
     * @Description : 
     * @Params      : [param_id]
     * @Return      : com.huimv.manage.util.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/11/10       
     * @Time        : 21:30
     */
    @RequestMapping(value = "/getConfigParam",method = RequestMethod.GET)
    public Result getConfigParam(@RequestParam(value = "paramId") String paramId){
        //
        return configService.getConfigParam(paramId);
    }

}
