package com.zcloud.basic.info.web;


import com.zcloud.basic.info.api.UserJobHandoverServiceI;
import com.zcloud.basic.info.dto.UserJobHandoverAddCmd;
import com.zcloud.basic.info.dto.UserJobHandoverPageQry;
import com.zcloud.basic.info.dto.UserJobHandoverListQry;
import com.zcloud.basic.info.dto.UserJobHandoverUpdateCmd;
import com.zcloud.basic.info.dto.UserJobHandoverRemoveCmd;
import com.zcloud.basic.info.dto.clientobject.UserJobHandoverCO;
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 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 SondonYong
 * @Date 2025-12-02 14:08:56
 */
@Api(tags = "用户变更工作交接")
@RequestMapping("/${application.gateway}/userJobHandover")
@RestController
@AllArgsConstructor
public class UserJobHandoverController {
    private final UserJobHandoverServiceI userJobHandoverService;

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

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody UserJobHandoverUpdateCmd cmd) {
        userJobHandoverService.edit(cmd);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<UserJobHandoverCO> page(@RequestBody UserJobHandoverPageQry qry) {
        return userJobHandoverService.listPage(qry);
    }

    @ApiOperation("所有数据")
    @PostMapping("/listAll")
    public MultiResponse<UserJobHandoverCO> listAll(@RequestBody UserJobHandoverListQry qry) {
        return userJobHandoverService.list(qry);
    }

    @ApiOperation("详情")
    @GetMapping("/getInfoById")
    public SingleResponse<UserJobHandoverCO> getInfoById(@RequestParam(value = "id") Long id) {
        return userJobHandoverService.getInfoById(id);
    }

    @ApiOperation("删除")
    @PutMapping("/remove")
    public Response remove(@RequestParam(value = "id") Long id) {
        userJobHandoverService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("删除多个")
    @PutMapping("/removeBatch")
    public Response removeBatch(@Validated @RequestBody UserJobHandoverRemoveCmd cmd) {
        userJobHandoverService.removeBatch(cmd.getIds());
        return SingleResponse.buildSuccess();
    }

}

