package org.springblade.system.expand.feign;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.system.expand.entity.CommonMenu;
import org.springblade.system.expand.vo.CommonMenuVO;
import org.springblade.system.expand.wrapper.CommonMenuWrapper;
import org.springblade.system.expand.service.ICommonMenuService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 常用菜单 client
 *
 * @author lianghanqiang
 * @since 2021-04-21
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/commonmenu")

public class CommonMenuClient implements ICommonMenuClient {

    private final ICommonMenuService commonMenuService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public CommonMenuVO detail(CommonMenu commonMenu) {
        CommonMenu detail = commonMenuService.getOne(Condition.getQueryWrapper(commonMenu));
        return CommonMenuWrapper.build().entityVO(detail);
        }

    /**
     * 查询 常用菜单
     */
    @Override
    @GetMapping("/list")
    public List<CommonMenuVO> list(CommonMenu commonMenu) {
        return CommonMenuWrapper.build().listVO(commonMenuService.list(Condition.getQueryWrapper(commonMenu)));
        }

    

    /**
     * 新增 常用菜单
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody CommonMenu commonMenu) {
        return commonMenuService.save(commonMenu);
        }

    /**
     * 修改 常用菜单
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody CommonMenu commonMenu) {
        return commonMenuService.updateById(commonMenu);
        }

    /**
     * 新增或修改 常用菜单
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody CommonMenu commonMenu) {
        return commonMenuService.saveOrUpdate(commonMenu);
        }

    
    /**
     * 删除 常用菜单
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return commonMenuService.deleteLogic(Func.toLongList(ids));
        }

    
}
