package com.seer.teach.user.app.user.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.user.response.HomeLayoutResp;
import com.seer.teach.user.convert.HomeLayoutConvert;
import com.seer.teach.user.service.IHomeLayoutService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name = "首页布局接口")
@Validated
@RequiredArgsConstructor
@RequestMapping("/app/home/layout")
public class AppHomeLayoutController {

    private final IHomeLayoutService homeLayoutService;

    @Operation(summary = "获取首页布局")
    @GetMapping("/list")
    @DecryptionAnnotation
    @EncryptionAnnotation
    @SaCheckPermission("app:user:layout:list")
    public ResultBean<List<HomeLayoutResp>> getHomeLayoutList() {
        return ResultBean.success(HomeLayoutConvert.INSTANCE.convertList(homeLayoutService.list()));
    }
}