package com.yh.saas.plugin.operation.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.winsea.svc.base.base.entity.CommonTenant;
import com.yh.saas.plugin.operation.qo.TenantQO;
import com.yh.saas.plugin.operation.service.IOperationTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * 试用租户API
 *
 * @author hs
 */
@RequestMapping("/trialTenant")
@RestController
public class TrialTenantController {


        @Autowired
        private IOperationTenantService tenantService;

        /**
         * 修改试用租户信息
         *
         * @param tenant 租户信息
         */
        @PostMapping("/api/changeTrialInfo")
        public void changeTrialInfo(@RequestBody CommonTenant tenant) throws ParseException {
        tenantService.changeTrialInfo(tenant);
    }


        /**
         * 分页搜索试用租户
         *
         * @param tenantQO 租户查询对象
         * @return 租户分页列表
         */
        @GetMapping("/query/getTrialList")
        public Page<CommonTenant> getTrialList(TenantQO tenantQO) throws ParseException {
        return tenantService.getTrialList(tenantQO);
    }

        /**
         * 获取租户详情
         *
         * @param tenantId 租户ID
         * @return 租户详情
         */
        @GetMapping("/query/tenantDetail")
        public CommonTenant getTenantDetail(@RequestParam String tenantId) throws ParseException {
        return tenantService.getTenantDetail(tenantId);
    }


//        /**
//         * 获取租户已购服务
//         *
//         * @param tenantId 租户id
//         * @return 返回服务
//         */
//        @GetMapping("/query/tenantServiceForm")
//        public List<TenantService> findTenantServiceForm(@RequestParam String tenantId) {
//        if (StringUtils.isEmpty(tenantId)) {
//            return null;
//        }
//        return tenantService.getTenantService(tenantId);
//    }
}
