package com.zcloud.basic.info.web;


import com.zcloud.basic.info.api.ProblemFeedbackServiceI;
import com.zcloud.basic.info.dto.ProblemFeedbackAddCmd;
import com.zcloud.basic.info.dto.ProblemFeedbackPageQry;
import com.zcloud.basic.info.dto.ProblemFeedbackListQry;
import com.zcloud.basic.info.dto.ProblemFeedbackUpdateCmd;
import com.zcloud.basic.info.dto.ProblemFeedbackRemoveCmd;
import com.zcloud.basic.info.dto.clientobject.ProblemFeedbackCO;
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-06 11:26:34
 */
@Api(tags = "问题反馈表")
@RequestMapping("/${application.gateway}/problemFeedback")
@RestController
@AllArgsConstructor
public class ProblemFeedbackController {
    private final ProblemFeedbackServiceI problemFeedbackService;

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

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

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<ProblemFeedbackCO> page(@RequestBody ProblemFeedbackPageQry qry) {
        return problemFeedbackService.listPage(qry);
    }

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

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

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

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

}

