package com.xunmei.core.resumption.controller;


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.common.security.utils.SecurityUtils;
import com.xunmei.core.resumption.domain.AppRuleItem;
import com.xunmei.core.resumption.dto.appRuleItem.AppRuleItemDto;
import com.xunmei.core.resumption.dto.appRuleItem.AppRuleItemPageDto;
import com.xunmei.core.resumption.dto.appRuleItem.AppRulePointSelectPageDto;
import com.xunmei.core.resumption.service.IAppRuleItemService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jingyuanchao
 * @since 2022-04-27
 */
@RestController()
@RequestMapping("/resumption/ruleItem/")
public class AppRuleItemController extends BaseController {

    @Resource
    private IAppRuleItemService appRuleItemService;


    @ApiOperation(value = "新增/编辑")
    @PostMapping("edit")
    public AjaxResult edit(@RequestBody AppRuleItemDto appRuleItemDto) {
        return success(appRuleItemService.edit(appRuleItemDto));
    }

    @ApiOperation(value = "分页查询")
    @GetMapping("page")
    public TableDataInfo page(AppRuleItemPageDto itemPageDto) {
        return appRuleItemService.pageQuery(itemPageDto);
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("{id}")
    public AjaxResult del(@PathVariable("id") Long id) {
        return success(appRuleItemService.del(id));
    }

    @ApiOperation(value = "详情")
    @GetMapping("{id}")
    public AjaxResult findOne(@PathVariable("id") Long id) {
        return success(appRuleItemService.findOne(id));
    }

    @ApiOperation(value = "规范组")
    @GetMapping("/rule/tree")
    public AjaxResult getRuleTree() {
        return success(appRuleItemService.getRuleTree(4352539158904832L));//SecurityUtils.getLoginUser().getSysUser().getOrgId())
    }

    /**
     * 获取履职内容选择框的翻页列表
     *
     * @return
     */
    @GetMapping("pointSelectionPage")
    public TableDataInfo pointSelectionPage(AppRulePointSelectPageDto dto) {
        TableDataInfo data = appRuleItemService.pointSelectionPage(dto);
        return data;
    }
}
