package com.xhpc.general.controller;

import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.general.service.IXhpcServiceDataUpdateService;
import com.xhpc.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * program: ruoyi
 * User: HongYun
 * Date:2021-08-12 13
 */
@RestController
@RequestMapping("/wwdata")
public class XhpcServiceDataUpdateController {

    @Autowired
    IXhpcServiceDataUpdateService xhpcServiceDataUpdateService;
    @Resource
    TokenService tokenService;

    @GetMapping("/list")
    public AjaxResult list(){

        return AjaxResult.success(xhpcServiceDataUpdateService.list());
    }

    @Log(title = "小程序设置-修改", businessType = BusinessType.UPDATE)
    @GetMapping("/update")
    public AjaxResult update(@RequestParam(required = false) String SOC, @RequestParam(required = false) String version, @RequestParam(required = false) String phone, @RequestParam(required = false) String aliyunMessageCount) {
        LoginUser loginUser = tokenService.getLoginUser();
        String tenantId = loginUser.getTenantId();
        return xhpcServiceDataUpdateService.update(SOC, version, phone, aliyunMessageCount,tenantId);
    }

    /**
     * 异常充电订单处理配置
     * @param prompt
     * @return
     */
    @GetMapping("/pilePromptUpdate")
    public AjaxResult pilePromptUpdate(String prompt){
        return xhpcServiceDataUpdateService.pilePromptUpdate(prompt);
    }

    /**
     * 异常占位费订单处理配置
     * @param prompt
     * @return
     */
    @GetMapping("/placeholderUpdate")
    public AjaxResult placeholderUpdate(String prompt){
        return xhpcServiceDataUpdateService.placeholderUpdate(prompt);
    }

}
