package com.gtiit.shr.controller;

import com.gtiit.shr.common.Result;
import com.gtiit.shr.service.NewSynOrgPosPerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;

/**
 * @author ramon.wang
 * @date Created in 17/07/2025 16:46
 * @description shr同步组织岗位人员到oa系统
 */

@RestController
@RequestMapping("/new")
public class NewShrOrgPosPerController {

    @Autowired
    NewSynOrgPosPerService newsynOrgAndDeptService;


    @GetMapping({"/admin"})
    public Result admin(@RequestParam String statrTime, @RequestParam String endTime) {
        Result result = new Result();

        try {
            result = this.newsynOrgAndDeptService.SynOrg(statrTime, endTime);
            return result;
        } catch (Exception var5) {
            result.setMessage("系统异常，请联系管理员分析日志:" + var5.getMessage());
            result.setCode(0);
            return result;
        }
    }

    @GetMapping({"/position"})
    public Result position(@RequestParam String statrTime, @RequestParam String endTime) {
        SimpleDateFormat dat = new SimpleDateFormat("yyyy-MM-dd");
        Result result = new Result();

        try {
            result = this.newsynOrgAndDeptService.SynPosition(dat.parse(statrTime), dat.parse(endTime));
            return result;
        } catch (Exception var6) {
            result.setMessage("系统异常，请联系管理员分析日志:" + var6.getMessage());
            result.setCode(0);
            return result;
        }
    }

    @GetMapping({"/person"})
    public Result admin(@RequestParam String startDate, @RequestParam String endDate, @RequestParam String personNumber) throws Exception {
        return this.newsynOrgAndDeptService.synPerson(startDate, endDate, personNumber);
    }
}
