package com.seer.teach.mp.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.common.ResultBean;
import com.seer.teach.mp.admin.controller.req.MpMenuSaveReq;
import com.seer.teach.mp.admin.controller.resp.AdminMpMenuResp;
import com.seer.teach.mp.admin.service.AdminMpAccountMenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 公众号菜单表 前端控制器
 * </p>
 *
 * @author Wang
 * @since 2025-08-02 15:45:13
 */
@Tag(name = "管理端 - 公众号菜单")
@RequiredArgsConstructor
@RestController
@RequestMapping("/mp/account/menu")
public class AdminMpAccountMenuController {
    
    private final AdminMpAccountMenuService adminMpAccountMenuService;

    @PostMapping("/create")
    @Operation(summary = "创建公众号菜单")
    @SaCheckPermission("admin:mp:account:menu:create")
    public ResultBean<Boolean> createAccountMenu(@Valid @RequestBody MpMenuSaveReq createReqVO) {
        return ResultBean.success(adminMpAccountMenuService.createAccountMenu(createReqVO));
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除公众号菜单")
    @SaCheckPermission("admin:mp:account:menu:delete")
    public ResultBean<Boolean> deleteMenu(@RequestParam("accountId") Integer accountId) {
        return ResultBean.success(adminMpAccountMenuService.deleteMenuByAppId(accountId));
    }

    @GetMapping("/list")
    @Operation(summary = "获取公众号菜单列表")
    @SaCheckPermission("admin:mp:account:menu:list")
    public ResultBean<List<AdminMpMenuResp>> getMenuList(@RequestParam("accountId") Integer accountId) {
        return ResultBean.success(adminMpAccountMenuService.getMenuList(accountId));
    }

}