package com.jy.business.corporation.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.business.corporation.model.dto.CorporationDto;
import com.jy.business.corporation.model.dto.CorporationSelectDto;
import com.jy.business.corporation.model.vo.CorporationVo;
import com.jy.business.corporation.service.CorporationService;
import com.jy.framework.model.base.BaseSelectDto;
import com.jy.framework.model.validation.AddGroup;
import com.jy.framework.model.validation.BatchDeleteGroup;
import com.jy.framework.model.validation.DetailGroup;
import com.jy.framework.model.validation.EditGroup;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * <p>
 * 公司信息 前端控制器
 * </p>
 *
 * @author
 * @since 2024-10-16
 */
@RestController
@RequestMapping("/corporation")
public class CorporationController {

    @Resource
    private CorporationService corporationService;

    /**
     * 公司信息分页
     */
    @GetMapping("/getPage")
    public Page<CorporationVo> getPage(CorporationSelectDto dto) {
        return corporationService.getPage(dto);
    }

    /**
     * 公司信息明细
     */
    @GetMapping("/getDetail")
    public CorporationVo getDetail(@Validated(DetailGroup.class) BaseSelectDto dto) {
        return corporationService.getDetail(dto.getId());
    }

    /**
     * 公司信息新增
     */
    @PostMapping("/add")
    public void add(@Validated(AddGroup.class) @RequestBody CorporationDto dto) {
        corporationService.add(dto);
    }

    /**
     * 公司信息编辑
     */
    @PostMapping("/edit")
    public void edit(@Validated(EditGroup.class) @RequestBody CorporationDto dto) {
        corporationService.edit(dto);
    }

    /**
     * 公司信息删除
     */
    @PostMapping("/delete")
    public void delete(@Validated(BatchDeleteGroup.class) @RequestBody BaseSelectDto dto) {
        corporationService.delete(dto.getIdList());
    }

}
