package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.page.MemberPrivilegesItemQueryInfo;
import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
import com.ym.mec.biz.service.MemberPrivilegesItemService;
import com.ym.mec.common.controller.BaseController;
import com.yonge.log.model.AuditLogAnnotation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RequestMapping("memberPrivilegesItem")
@Api(tags = "功能字典服务")
@RestController
public class MemberPrivilegesItemController extends BaseController {

    @Autowired
    private MemberPrivilegesItemService memberPrivilegesItemService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/add')")
    @AuditLogAnnotation(operateName = "新增系统功能类型")
    public Object add(@RequestBody MemberPrivilegesItem memberPrivilegesItem) {
        memberPrivilegesItemService.add(memberPrivilegesItem);
        return succeed();
    }

    @ApiOperation(value = "删除")
    @PostMapping("/del")
    @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/del')")
    public Object del(Integer id) {
        memberPrivilegesItemService.recursiveDel(id);
        return succeed();
    }

    @ApiOperation(value = "修改")
    @PostMapping("/update")
    @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/update')")
    public Object update(@RequestBody MemberPrivilegesItem memberPrivilegesItem) {
        memberPrivilegesItemService.updateItem(memberPrivilegesItem);
        return succeed();
    }

    @ApiOperation(value = "分页查询")
    @GetMapping("/queryPage")
    @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/queryPage')")
    public Object queryPage(MemberPrivilegesItemQueryInfo queryInfo) {
        return succeed(memberPrivilegesItemService.queryItemPage(queryInfo));
    }

    @ApiOperation(value = "查询所有")
    @GetMapping("/findAll")
    @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/findAll')")
    public Object findAll(MemberPrivilegesItemQueryInfo queryInfo) {
        return succeed(memberPrivilegesItemService.findAllItem(queryInfo));
    }
}
