package com.njzscloud.supervisory.sys.dict.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.sys.dict.pojo.DictItemEntity;
import com.njzscloud.supervisory.sys.dict.service.DictItemService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 字典条目表
 */
@Slf4j
@RestController
@RequestMapping("/dict_item")
@RequiredArgsConstructor
public class SysDictItemController {

    private final DictItemService dictItemService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody DictItemEntity dictItemEntity) {
        dictItemService.add(dictItemEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody DictItemEntity dictItemEntity) {
        dictItemService.modify(dictItemEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        dictItemService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<DictItemEntity> detail(@RequestParam Long id) {
        return R.success(dictItemService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<DictItemEntity>> paging(PageParam pageParam, DictItemEntity dictItemEntity) {
        return R.success(dictItemService.paging(pageParam, dictItemEntity));
    }

}
