package com.shkj.wcs.controller.base;

import com.shkj.common.annotation.Log;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.wcs.domain.BasePoint;
import com.shkj.wcs.domain.BasePointGroup;
import com.shkj.wcs.service.IBasePointGroupService;
import com.shkj.wcs.service.IBasePointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 点位分组Controller
 *
 * @author zjx
 * @date 2023-04-20
 */
@RestController
@RequestMapping("/wcs/base/pointgroup")
public class BasePointGroupController extends BaseController
{

    @Autowired
    private IBasePointGroupService basePointGroupService;

    /**
     * 查询点位分组列表
     */
    @GetMapping("/list")
    public TableDataInfo<BasePointGroup> list(BasePointGroup basePointGroup)
    {
        startPage();
        List<BasePointGroup> list = basePointGroupService.selectBasePointGroupList(basePointGroup);
        return getDataTable(list);
    }


    /**
     * 获取点位分组详细信息
     */
    @GetMapping("/getBasePointByid")
    public Result<BasePoint> getInfo(@RequestParam("id") Long id){
        return Result.ok().data(basePointGroupService.selectBasePointGroupById(id));
    }

    /**
     * 新增点位分组
     */
    @Log(title = "点位分组", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody BasePointGroup basePointGroup) {
        return basePointGroupService.insertBasePointGroup(basePointGroup);
    }

    /**
     * 修改点位分组
     */
    @Log(title = "点位分组", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result<Boolean> edit(@RequestBody BasePointGroup basePointGroup){
        return basePointGroupService.updateBasePointGroup(basePointGroup);
    }

    /**
     * 删除点位分组
     */
    @Log(title = "点位分组", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public Result<Boolean> remove(@RequestParam Long id){
        return basePointGroupService.deleteBasePointGroupById(id);
    }


    /**
     * 获取点位分组
     */
    @GetMapping("/getBasePointGroup")
    public Result<BasePoint> getBasePoint(){
        return Result.ok().data(basePointGroupService.getBasePointGroup());
    }

}
