package cn.iocoder.yudao.module.member.controller.app.alloc;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.controller.app.alloc.vo.AppAllocRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.alloc.AllocDO;
import cn.iocoder.yudao.module.member.service.alloc.AllocService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 App - 配置")
@RestController
@RequestMapping("/member/alloc")
@Validated
public class AppAllocController {

    @Resource
    private AllocService allocService;

    //@PostMapping("/create")
    //@Operation(summary = "创建配置")
    //@PreAuthorize("@ss.hasPermission('member:alloc:create')")
    //public CommonResult<Long> createAlloc(@Valid @RequestBody AllocSaveReqVO createReqVO) {
    //    return success(allocService.createAlloc(createReqVO));
    //}
    //
    //@PutMapping("/update")
    //@Operation(summary = "更新配置")
    //@PreAuthorize("@ss.hasPermission('member:alloc:update')")
    //public CommonResult<Boolean> updateAlloc(@Valid @RequestBody AllocSaveReqVO updateReqVO) {
    //    allocService.updateAlloc(updateReqVO);
    //    return success(true);
    //}
    //
    //@DeleteMapping("/delete")
    //@Operation(summary = "删除配置")
    //@Parameter(name = "id", description = "编号", required = true)
    //@PreAuthorize("@ss.hasPermission('member:alloc:delete')")
    //public CommonResult<Boolean> deleteAlloc(@RequestParam("id") Long id) {
    //    allocService.deleteAlloc(id);
    //    return success(true);
    //}
    //
    //@GetMapping("/get")
    //@Operation(summary = "获得配置")
    //@Parameter(name = "id", description = "编号", required = true, example = "1024")
    //@PreAuthorize("@ss.hasPermission('member:alloc:query')")
    //public CommonResult<AllocRespVO> getAlloc(@RequestParam("id") Long id) {
    //    AllocDO alloc = allocService.getAlloc(id);
    //    return success(BeanUtils.toBean(alloc, AllocRespVO.class));
    //}
    //
    //@GetMapping("/page")
    //@Operation(summary = "获得配置分页")
    //@PreAuthorize("@ss.hasPermission('member:alloc:query')")
    //public CommonResult<PageResult<AllocRespVO>> getAllocPage(@Valid AllocPageReqVO pageReqVO) {
    //    PageResult<AllocDO> pageResult = allocService.getAllocPage(pageReqVO);
    //    return success(BeanUtils.toBean(pageResult, AllocRespVO.class));
    //}
    //
    //@GetMapping("/export-excel")
    //@Operation(summary = "导出配置 Excel")
    //@PreAuthorize("@ss.hasPermission('member:alloc:export')")
    //@OperateLog(type = EXPORT)
    //public void exportAllocExcel(@Valid AllocPageReqVO pageReqVO,
    //          HttpServletResponse response) throws IOException {
    //    pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
    //    List<AllocDO> list = allocService.getAllocPage(pageReqVO).getList();
    //    // 导出 Excel
    //    ExcelUtils.write(response, "配置.xls", "数据", AllocRespVO.class,
    //                    BeanUtils.toBean(list, AllocRespVO.class));
    //}

    @GetMapping("/list")
    @Operation(summary = "联系我们配置列表")
    public CommonResult<List<AppAllocRespVO>> getAllocList() {
        List<AllocDO> allocList = allocService.getAllocList();
        return success(BeanUtils.toBean(allocList, AppAllocRespVO.class));
    }

}