package com.ruoyi.ibs.list.controller;


import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ibs.customerselect.domain.ListSelectByUser;
import com.ruoyi.ibs.list.domain.LowcodeVisstFeedbackModel;
import com.ruoyi.ibs.list.domain.LowcodeVisstFeedbackModelDTO;
import com.ruoyi.ibs.list.service.LowcodeVisstFeedbackModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;


/**
 * 走访反馈搭建模板;(lowcode_visst_feedback_model)表控制层
 * @author : http://www.chiner.pro
 * @date : 2025-6-20
 */
@Api(tags = "走访反馈搭建模板对象功能接口")
@RestController
@RequestMapping("/lowcodeVisstFeedbackModel")
public class LowcodeVisstFeedbackModelController extends BaseController {
    @Autowired
    private LowcodeVisstFeedbackModelService lowcodeVisstFeedbackModelService;



    /**
     * 分页查询
     *
     * @param modelName
     * @param startDate
     * @param endDate
     * @return 查询结果
     */
    @ApiOperation("分页查询")
    @Log(title = "走访-走访反馈搭建模板")
    @GetMapping("/modelList")
    public TableDataPageInfo<LowcodeVisstFeedbackModel> modelList(String modelName,String startDate,String endDate){
        Page<Object> page = startPage();
        List<LowcodeVisstFeedbackModel> list = lowcodeVisstFeedbackModelService.modeList(modelName,startDate, endDate,null);
        return getDataTable(list ,page);
    }



    /**
     * 新增数据
     *
     * @param lowcodeVisstFeedbackModelDTO 实例对象
     * @return 实例对象
     */
    @ApiOperation("新增数据")
    @Log(title = "走访-走访反馈搭建模板", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Object> add(@RequestBody LowcodeVisstFeedbackModelDTO lowcodeVisstFeedbackModelDTO){
        lowcodeVisstFeedbackModelService.insert(lowcodeVisstFeedbackModelDTO);
        return R.ok();
    }

    /**
     * 更新数据
     *
     * @param lowcodeVisstFeedbackModelDTO 实例对象
     * @return 实例对象
     */
    @ApiOperation("更新数据")
    @Log(title = "走访-走访反馈搭建模板更新数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Object> edit(@RequestBody LowcodeVisstFeedbackModelDTO lowcodeVisstFeedbackModelDTO){
        lowcodeVisstFeedbackModelService.update(lowcodeVisstFeedbackModelDTO);
        return R.ok();
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @ApiOperation("通过主键删除数据")
    @Log(title = "走访-走访反馈搭建模板通过主键删除数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/deleteById")
    public R<Object> deleteById(String uuid){
         lowcodeVisstFeedbackModelService.deleteById(uuid);
         return R.ok();
    }

    @ApiOperation("通过主键删除数据")
    @Log(title = "走访-走访反馈搭建模板通过主键删除数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/deleteByIds")
    public R<Object> deleteByIds(@RequestParam List<String> uuids){
        for (String id: uuids) {
            lowcodeVisstFeedbackModelService.deleteById(id);
        }
        return R.ok();
    }

}