package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.sys.dto.DigitalSealConfigDTO;
import com.jwipc.sys.entity.DigitalSealConfig;
import com.jwipc.sys.logic.DigitalSealConfigLogic;
import com.jwipc.sys.model.param.PurchaseOrgParam;
import com.jwipc.sys.model.query.DigitalSealConfigQuery;
import com.jwipc.sys.model.query.PurchaseOrgQuery;
import com.jwipc.sys.service.IDigitalSealConfigService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

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

/**
 * <p>
 * 电子印章配置表 前端控制器
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-06-19
 */
@RestController
@RequestMapping(MODULE_ROOT +"/digitalSealConfig/rest")
@RequiredArgsConstructor
public class DigitalSealConfigRestController {

    private final DigitalSealConfigLogic digitalSealConfigLogic;
    private final IDigitalSealConfigService digitalSealConfigService;
    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(DigitalSealConfigQuery query) {
        return digitalSealConfigLogic.findByPage(query);
    }

    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/listAll")
    public List<DigitalSealConfigDTO> listAll(DigitalSealConfigQuery query) {
        return digitalSealConfigLogic.listAll(query);
    }

    /**
     * 保存更新
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(DigitalSealConfig param){
        digitalSealConfigService.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }

    /**
     * 删除
     *
     * @param id 参数
     */
    @PostMapping("/remove")
    public ResponseEntity remove(Long id) {
        digitalSealConfigService.removeById(id);
        return ResponseEntity.ok(true);
    }
}
