package jnpf.personnels.controller.web.employeetype;

import jnpf.base.ActionResult;
import jnpf.model.personnels.dto.employeetype.FtbEmployeeTypeAddDTO;
import jnpf.model.personnels.dto.employeetype.FtbEmployeeTypeEditDTO;
import jnpf.model.personnels.vo.employeetype.FtbPersonnelsEmployeeTypeVO;
import jnpf.personnels.service.FtbPersonnelsEmployeeTypeService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * web员工类型模块
 *
 * @author wangchunxiang
 * @date 2025/09/11
 */
@RestController
@RequestMapping("/web/employee-type")
public class FtbPersonnelsEmployeeTypeWebController {

    @Resource
    private FtbPersonnelsEmployeeTypeService employeeTypeService;

    /**
     * 添加员工类型
     */
    @PostMapping("/add")
    public ActionResult<Void> addEmployeeType(@RequestBody @Validated FtbEmployeeTypeAddDTO employeeType) {
        employeeTypeService.addEmployeeType(employeeType);
        return ActionResult.success();
    }

    /**
     * 修改员工类型
     */
    @PutMapping("/edit")
    public ActionResult<Void> editEmployeeType(@RequestBody @Validated FtbEmployeeTypeEditDTO employeeType) {
        employeeTypeService.editEmployeeType(employeeType);
        return ActionResult.success();
    }

    /**
     * 删除员工类型
     *
     * @param id 员工类型主键Id
     * @return {@link ActionResult }<{@link Void }>
     */
    @DeleteMapping("/delete/{id}")
    public ActionResult<Void> deleteEmployeeType(@PathVariable("id") String id) {
        employeeTypeService.deleteEmployeeType(id);
        return ActionResult.success();
    }

    /**
     * 员工类型列表
     */
    @GetMapping("/employee-list")
    public ActionResult<List<FtbPersonnelsEmployeeTypeVO>> list() {
        List<FtbPersonnelsEmployeeTypeVO> result = employeeTypeService.employeeList();
        return ActionResult.success(result);
    }

    /**
     * 根据用户ID集合查询员工类型ID、名称
     *
     * @param userIds 用户ID集合
     * @return key为用户Id，value为员工类型
     */
    @PostMapping("/get-employee-type-by-user-ids")
    public Map<String, FtbPersonnelsEmployeeTypeVO> getEmployeeTypeByUserIds(@RequestBody List<String> userIds) {
        return employeeTypeService.getEmployeeTypeByUserIds(userIds);
    }

}
