package com.hzs.activity.base.controller.api;

import com.hzs.activity.base.param.ActivityParam;
import com.hzs.activity.base.service.IAcBaseConfigService;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.activity.base.AcBaseConfig;
import com.hzs.common.domain.activity.base.ext.AcBaseConfigExt;
import com.hzs.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 查询活动列表
 * @author: sui q
 * @time: 2023/4/27 09:15
 * @classname: ApiActivityController
 * @package_name: com.hzs.activity.base.controller.api
 * version 1.0.0
 */
@RestController
@RequestMapping("/api/base")
public class ApiActivityController extends BaseController {

    private IAcBaseConfigService baseConfigService;

    @Autowired
    public void setBaseConfigService(IAcBaseConfigService baseConfigService) {
        this.baseConfigService = baseConfigService;
    }

    /*
     * @description: 查询活动列表
     * @author: sui q
     * @date: 2023/4/21 17:33
     * @param: null null
     **/
    @GetMapping("/activity-list")
    public TableDataInfo activityList(){
        return getDataTable( baseConfigService.queryBaseConfigList(SecurityUtils.getPkCountry(), SecurityUtils.getUserId()));
    }

    /*
     * @description: 查询活动列表
     * @author: sui q
     * @date: 2023/4/21 17:33
     * @param: null null
     **/
    @PostMapping("/activity-detail")
    public TableDataInfo activityDetail(@RequestBody ActivityParam activityParam){
        AcBaseConfigExt acBaseConfig = baseConfigService.queryBaseConfigDetail(activityParam.getPkId(), SecurityUtils.getPkCountry());
        List<AcBaseConfig> acBaseConfigList = new ArrayList<>();
        acBaseConfigList.add(acBaseConfig);
        return getDataTable(acBaseConfigList);
    }
}
