package com.jwipc.tender.controller.pc;

import com.alibaba.fastjson2.JSON;
import com.jwipc.page.PageView;

import com.jwipc.tender.dto.DimensionDTO;
import com.jwipc.tender.dto.ExpertManageSaveDTO;
import com.jwipc.tender.logic.DimensionLogic;
import com.jwipc.tender.logic.ExpertManageLogic;

import com.jwipc.tender.model.query.ExpertManageQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


import static com.jwipc.tender.constant.ModuleConst.MODULE_ROOT;

/**
 * @author Al
 * @create 2024-01-31 10:53
 * @desc 模具
 */

@RestController
@RequestMapping(MODULE_ROOT + "/expertManage/rest/")
@RequiredArgsConstructor
public class ExpertManageRestController {
    private final ExpertManageLogic expertManageLogic;
    private final DimensionLogic dimensionLogic;
    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(ExpertManageQuery query) {
        return expertManageLogic.findByPage(query);
    }
    /**
     * 保存更新
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(@RequestBody ExpertManageSaveDTO param){
        expertManageLogic.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }
//    @PostMapping("/save")
//    public ResponseEntity save(String data) {
//        final ExpertManageSaveDTO expertManageSaveDTO =
//                JSON.parseObject(data, ExpertManageSaveDTO.class);
//        expertManageLogic.save(expertManageSaveDTO);
//        return ResponseEntity.ok().build();
//    }
//    /**
//     * 删除
//     *
//     * @param moldCode 参数
//     */
//    @PostMapping("/remove")
//    public ResponseEntity remove(String moldCode) {
//        moldFormLogic.remove(moldCode);
//        return ResponseEntity.ok(true);
//    }
    /**
     * 维度主数据
     * @return 信息
     */
    @RequestMapping("/dc/listAll")
//    public List<DimensionDTO> listAll(){
//        return dimensionLogic.listAll();
//    }
    public ResponseEntity<List<DimensionDTO>> listAll(){
        return ResponseEntity.ok(dimensionLogic.listAll());
    }
}
