package com.xhpc.general.controller;

import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.general.domain.EtTokenEntity;
import com.xhpc.general.service.IXhpcEtTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * program: ruoyi
 * User: HongYun
 * Date:2021-09-10 14
 */
@RestController
@RequestMapping(value = "/token")
public class XhpcEtTokenController extends BaseController {


    @Autowired
    private IXhpcEtTokenService iXhpcEtTokenService;

    @GetMapping(value = "/list")
    public TableDataInfo list(String operatorId, String operatorId3irdpty){

        startPage();
        return getDataTable(iXhpcEtTokenService.list(operatorId, operatorId3irdpty));
    }

    @Log(title = "第三方token-删除", businessType = BusinessType.DELETE)
    @PostMapping(value = "/delete")
    public AjaxResult delete(@RequestBody EtTokenEntity etTokenEntity){

        return iXhpcEtTokenService.delete(etTokenEntity.getId());
    }

    @Log(title = "第三方token-添加", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody EtTokenEntity etTokenEntity){

        return iXhpcEtTokenService.add(etTokenEntity.getOperatorId(),etTokenEntity.getOperatorId3irdpty(),
                etTokenEntity.getSecretTokenType(),etTokenEntity.getDataSecret(),
                etTokenEntity.getDataSecretiv(),etTokenEntity.getOperatorSecret(),etTokenEntity.getSigSecret(),
                etTokenEntity.getEncrypt(),etTokenEntity.getUrlPrefix());
    }
}
