package cn.cecep.talroad.controller;

import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.service.PcArchivesFactoryService;
import cn.cecep.talroad.vo.PcArchivesFactoryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "企业档案分类")
@RestController
@RequestMapping("/pcArchivesFactory")
public class PcArchivesFactoryController extends BasesController {
    @Autowired
    private PcArchivesFactoryService archivesFactoryService;

    @ApiOperation(value = "获取企业分类档案")
    @GetMapping("/{factoryId}")
    public AjaxResults<PcArchivesFactoryVo> getByFactoryId(@PathVariable("factoryId") String factoryId) {
        PcArchivesFactoryVo vo = archivesFactoryService.getByFactoryId(factoryId);
        return AjaxResults.success(vo);
    }

    @ApiOperation(value = "删除")
    @PostMapping("/remove/{id}")
    public AjaxResults remove(@PathVariable("id") String id) {
        archivesFactoryService.deleteById(id);
        return AjaxResults.success();
    }

    @ApiOperation(value = "还原")
    @PostMapping("/revert/{id}")
    public AjaxResults revert(@PathVariable("id") String id) {
        archivesFactoryService.revert(id);
        return AjaxResults.success();
    }

    @ApiOperation(value = "关注")
    @PostMapping("/follow/{id}")
    public AjaxResults follow(@PathVariable("id") String id) {
        archivesFactoryService.follow(id);
        return AjaxResults.success();
    }

    @ApiOperation(value = "取消关注")
    @PostMapping("/cancelFollow/{id}")
    public AjaxResults cancelFollow(@PathVariable("id") String id) {
        archivesFactoryService.cancelFollow(id);
        return AjaxResults.success();
    }

    @ApiOperation(value = "初始化企业分类档案")
    @PostMapping("/init")
    public AjaxResults init(@RequestParam(value = "factoryId", required = false) String factoryId) {
        archivesFactoryService.init(factoryId);
        return AjaxResults.success();
    }

}
