package com.fjhx.controller.process;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.process.ProcessInfo;
import com.fjhx.service.process.ProcessInfoService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-08-12
 */
@RestController
@RequestMapping("/processInfo")
public class ProcessInfoController {

    @Autowired
    private ProcessInfoService processInfoService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public R list(@RequestBody Map<String, String> condition) {
        List<ProcessInfo> list = processInfoService.getList(condition);
        return R.data(list);
    }

    /**
     * 分页
     */
    @PostMapping("/page")
    public R page(@RequestBody Map<String, String> condition) {
        Page<ProcessInfo> page = processInfoService.getPage(condition);
        return R.data(page);
    }

    /**
     * 添加系统流程
     */
    @PostMapping("/add")
    public R add(@RequestBody ProcessInfo processInfo) {
        processInfoService.add(processInfo);
        return R.success();
    }

    /**
     * 业务服务名称列表
     */
    @PostMapping("/serviceNameList")
    public R serviceNameList() {
        return R.data(processInfoService.getDistinctList(ProcessInfo::getServiceName));
    }

}

