package com.xunmei.core.resumption.controller;

import com.xunmei.common.core.vo.IdNameVo;
import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import com.xunmei.common.core.web.page.TableDataInfo;
import com.xunmei.core.resumption.domain.AppRule;
import com.xunmei.core.resumption.dto.appRule.AppRuleEditDto;
import com.xunmei.core.resumption.dto.appRule.AppRuleListForOrgDto;
import com.xunmei.core.resumption.service.IAppRuleService;
import com.xunmei.core.resumption.vo.appRule.AppRulePageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 景远超
 * @since 2022-04-26
 */
@RestController()
@RequestMapping("/resumption/rule/")
public class AppRuleController  extends BaseController {

    @Resource(name = "appRuleService")
    private IAppRuleService appRuleService;

    @ApiOperation(value = "查询规范列表")
    @GetMapping("page")
    public TableDataInfo getAppRulePage(AppRule appRule) {
        final TableDataInfo appRulePage = appRuleService.getAppRulePage(appRule);
        return appRulePage;
    }

    @ApiOperation(value = "查询所有规范")
    @GetMapping("all")
    public AjaxResult getAllAppRule() {
        final List<AppRulePageVo> appRulePage = appRuleService.getAllAppRule();
        return success(appRulePage);
    }
    @ApiOperation(value = "规范详情")
    @GetMapping("{id}")
    public AjaxResult info(@PathVariable Long id) {
        return success(appRuleService.get(id));
    }

    @ApiOperation(value = "新增/编辑")
    @PostMapping("edit")
    public AjaxResult edit(@RequestBody AppRuleEditDto appRuleEditDto) {

        return success(appRuleService.edit(appRuleEditDto));
    }

    @ApiOperation(value = "删除规范")
    @GetMapping("del/{id}")
    public AjaxResult del(@PathVariable Long id) {
        appRuleService.del(id);
        return success();
    }

    @ApiOperation(value = "删除规范")
    @GetMapping("ruleListForOrg")
    public AjaxResult  ruleListForOrg(AppRuleListForOrgDto dto){
       List<IdNameVo> list=  appRuleService.ruleListForOrg(dto);
       return success(list);
    }
}
