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.UserExpandInfoServiceI;
import com.zcloud.basic.info.dto.UserExpandInfoAddCmd;
import com.zcloud.basic.info.dto.UserExpandInfoPageQry;
import com.zcloud.basic.info.dto.UserExpandInfoUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.UserExpandInfoCO;
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 2026-01-05 14:12:18
 */
@Api(tags = "用户扩展信息表")
@RequestMapping("/${application.gateway}/userExpandInfo")
@RestController
@AllArgsConstructor
public class UserExpandInfoController {
    private final UserExpandInfoServiceI userExpandInfoService;

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

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<UserExpandInfoCO> page(@RequestBody UserExpandInfoPageQry qry) {
        return userExpandInfoService.listPage(qry);
    }

    @ApiOperation("所有数据")
    @GetMapping("/listAll")
    public MultiResponse<UserExpandInfoCO> listAll() {
        return MultiResponse.of(new ArrayList<UserExpandInfoCO>());
    }

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

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

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

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody UserExpandInfoUpdateCmd userExpandInfoUpdateCmd) {
        userExpandInfoService.edit(userExpandInfoUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

