package com.crunii.micro.service.sysmgr.controller;

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.entity.main.YcqAppConfigUrl;
import com.crunii.micro.domain.entity.main.YcqRollPic;
import com.crunii.micro.service.sysmgr.api.domain.dto.YcqQueryRollPicDTO;
import com.crunii.micro.service.sysmgr.api.domain.dto.YcqRollPicDTO;
import com.crunii.micro.service.sysmgr.api.domain.dto.YcqRollPicUrl;
import com.crunii.micro.service.sysmgr.service.AppHomeConfigService;
import com.crunii.micro.service.sysmgr.service.YcqRollPicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 轮播图
 * @author baoxy
 * @date 2023-05-30
 */
@Api(tags = "app端首页配置")
@RestController
@RequestMapping("/public/AppHomeConfigController")
public class PublicAppHomeConfigController {

    @Resource
    private AppHomeConfigService appHomeConfigService;

    @Resource
    private YcqRollPicService rollPicService;


    @ApiOperation(value = "查询app端配置url")
    @RequestMapping(path = "/findAppConfigUrl", method = RequestMethod.GET)
//    @ApiResponse(code=200,message = "成功",response = YcqAppConfigUrl.class)
    @ResponseBody
    public Result<List<YcqAppConfigUrl>> findAppConfigUrl() {
        return appHomeConfigService.findAppConfigUrl();
    }

    @ApiOperation(value = "查询轮播配置信息")
    @RequestMapping(path = "/queryByCondition", method = RequestMethod.POST)
    @ResponseBody
    public Result<List<YcqRollPicUrl>> queryByCondition(@Validated @RequestBody YcqQueryRollPicDTO ycqQueryRollPicDTO) {
        return Result.ofSuccess(rollPicService.queryByCondition(ycqQueryRollPicDTO));
    }

    @ApiOperation(value = "查询角色app配置权限(访客模式)")
    @RequestMapping(path = "/findRoleAppVisitor", method = RequestMethod.POST)
    @ResponseBody
    public Result<List<YcqAppConfigUrl>> findRoleAppVisitor() {
        return appHomeConfigService.findRoleAppVisitor();
    }

    @ApiOperation("根据二级位置查轮播图列表")
    @PostMapping("/getYcqRollPicByType")
    public Result<YcqRollPic> getYcqRollPicByType(@RequestBody YcqRollPicDTO ycqRollPic){
        return Result.ofSuccess(rollPicService.getYcqRollPicByType(ycqRollPic));
    }
}
