package com.hys.app.controller.erp.basic;

import com.hys.app.framework.context.user.AdminUserContext;
import com.hys.app.framework.database.WebPage;
import com.hys.app.model.erp.dto.MemberDTO;
import com.hys.app.model.erp.dto.MemberQueryParams;
import com.hys.app.model.erp.dto.UserMenuDto;
import com.hys.app.model.erp.dto.UserMenuQueryParams;
import com.hys.app.model.erp.vo.MemberVO;
import com.hys.app.model.erp.vo.UserMenuVO;
import com.hys.app.model.support.LogClient;
import com.hys.app.model.support.validator.annotation.Log;
import com.hys.app.service.erp.MemberManager;
import com.hys.app.service.erp.UserMenuManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.List;

/**
 * 会员 API
 *
 * @author 张崧
 * 2024-01-23 09:28:16
 */
@RestController
@RequestMapping("/admin/erp/user/menu")
@Api(tags = "会员快捷菜单")
@Validated
public class UserMenuController {

    @Autowired
    private UserMenuManager userMenuManager;

    @ApiOperation(value = "分页列表")
    @GetMapping
    public WebPage<UserMenuDto> list(UserMenuQueryParams queryParams) {

        queryParams.setUserId(AdminUserContext.getAdminUserId());
        return userMenuManager.list(queryParams);
    }

    @ApiOperation(value = "新增菜单")
    @PostMapping
    @Log(client = LogClient.admin, detail = "新增菜单")
    public void add(@RequestBody @Valid UserMenuDto userMenuDto) {
        userMenuDto.setUserId(AdminUserContext.getAdminUserId());
        userMenuManager.add(userMenuDto);
    }



    @ApiOperation(value = "删除")
    @DeleteMapping("/{id}")
    @Log(client = LogClient.admin, detail = "删除id为[${id}]的菜单")
    public void delete(@PathVariable Long id) {
        userMenuManager.delete(id);
    }


}

