package com.zcloud.basic.info.web;


import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.basic.info.api.UserCorpRecordServiceI;
import com.zcloud.basic.info.dto.UserChangeRecordInfoQry;
import com.zcloud.basic.info.dto.UserCorpRecordAddCmd;
import com.zcloud.basic.info.dto.UserCorpRecordPageQry;
import com.zcloud.basic.info.dto.UserCorpRecordUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.UserChangeRecordCO;
import com.zcloud.basic.info.dto.clientobject.UserCorpRecordCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * web-adapter
 *
 * @Author zhaokai
 * @Date 2025-12-03 10:21:58
 */
@Api(tags = "用户入职企业记录表")
@RequestMapping("/${application.gateway}/userCorpRecord")
@RestController
@AllArgsConstructor
public class UserCorpRecordController {
    private final UserCorpRecordServiceI userCorpRecordService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<UserCorpRecordCO> add(@Validated @RequestBody UserCorpRecordAddCmd cmd) {
        SSOUser ssoUser = AuthContext.getCurrentUser();
        return userCorpRecordService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<UserCorpRecordCO> page(@RequestBody UserCorpRecordPageQry qry) {
        return userCorpRecordService.listPage(qry);
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody UserCorpRecordUpdateCmd userCorpRecordUpdateCmd) {
        userCorpRecordService.edit(userCorpRecordUpdateCmd);
        return SingleResponse.buildSuccess();
    }
    @ApiOperation("变更记录详情详情")
    @PostMapping("/getUserCorpRecordById")
    public SingleResponse<UserCorpRecordCO> getChangerRecordInfoById(@RequestBody UserChangeRecordInfoQry userChangeRecordInfoQry) {
        return SingleResponse.of(userCorpRecordService.getChangerRecordInfoById(userChangeRecordInfoQry));
    }
}

