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.UserEmploymentLogServiceI;
import com.zcloud.basic.info.dto.UserEmploymentLogAddCmd;
import com.zcloud.basic.info.dto.UserEmploymentLogPageQry;
import com.zcloud.basic.info.dto.UserEmploymentLogQryCmd;
import com.zcloud.basic.info.dto.UserEmploymentLogUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.UserEmploymentLogCO;
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 zhangyue
 * @Date 2025-11-06 19:15:37
 */
@Api(tags = "用户履职记录")
@RequestMapping("/${application.gateway}/userEmploymentLog")
@RestController
@AllArgsConstructor
public class UserEmploymentLogController {
    private final UserEmploymentLogServiceI userEmploymentLogService;

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

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<UserEmploymentLogCO> page(@RequestBody UserEmploymentLogPageQry qry) {
        return userEmploymentLogService.listPage(qry);
    }

    @ApiOperation("所有数据")
    @GetMapping("/listAll")
    public MultiResponse<UserEmploymentLogCO> listAll(UserEmploymentLogQryCmd qry) {
        return userEmploymentLogService.listAll(qry);
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<UserEmploymentLogCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(new UserEmploymentLogCO());
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Response remove(@PathVariable("id") Long id) {
        userEmploymentLogService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("删除多个")
    @DeleteMapping("/ids")
    public Response removeBatch(@RequestParam Long[] ids) {
        userEmploymentLogService.removeBatch(ids);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody UserEmploymentLogUpdateCmd userEmploymentLogUpdateCmd) {
        userEmploymentLogService.edit(userEmploymentLogUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

