package com.sqx.modules.material.controller;

import java.util.List;

import com.sqx.common.utils.Result;
import com.sqx.modules.artificer.entity.Period;
import com.sqx.modules.material.entity.Material;
import com.sqx.modules.material.entity.MaterialArtificer;
import com.sqx.modules.material.entity.MaterialMassage;
import com.sqx.modules.material.service.MaterialArtificerService;
import com.sqx.modules.material.service.MaterialMassageService;
import com.sqx.modules.material.service.MaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(value = "物料包", tags = {"物料包"})
@RequestMapping(value = "/material")
public class MaterialController {

    @Autowired
    private MaterialService materialService;
    @Autowired
    private MaterialArtificerService materialArtificerService;
    @Autowired
    private MaterialMassageService materialMassageService;
    /**
     * 查询所有记录
     *
     * @return 返回集合，没有返回空List
     */
    @GetMapping("materialList")
    @ApiOperation("查询物料包列表（无分页）")
    public Result materialList(Material material) {
        return materialService.materialList(material);
    }
    @GetMapping("list")
    @ApiOperation("查询列表(带分页)")
    public Result listAll(Integer page, Integer limit, Material material) {
        return materialService.selectPage(page,limit, material);
    }
    /**
     * 查询技师关联物料包数据
     *
     * @return 返回集合，没有返回空List
     */
    @GetMapping("selectMaterialArtificer")
    @ApiOperation("查询技师关联物料包数据")
    public Result selectMaterialArtificer(Integer page, Integer limit, MaterialArtificer materialArtificer) {
        return materialService.selectMaterialArtificer(page,limit, materialArtificer);
    }
    @GetMapping("selectMaterialMassage")
    @ApiOperation("查询服务关联物料包数据")
    public Result selectMaterialMassage(Integer page, Integer limit, MaterialMassage materialMassage) {
        return materialService.selectMaterialMassage(page,limit, materialMassage);
    }
    @PostMapping("materialArtificerInsert")
    @ApiOperation("新增技师关联物料包数据")
    public Result materialArtificerInsert(MaterialArtificer materialArtificer) {
        return materialArtificerService.insertMaterialArtificer(materialArtificer);
    }
    @PostMapping("materialArtificerUpdata")
    @ApiOperation("修改技师关联物料包数据")
    public Result materialArtificerUpdata(MaterialArtificer materialArtificer) {
        return materialArtificerService.materialArtificerUpdata(materialArtificer);
    }
    @PostMapping("materialArtificerDelete")
    @ApiOperation("删除技师关联物料包数据")
    public Result materialArtificerDelete(MaterialArtificer materialArtificer) {
        return materialArtificerService.materialArtificerDelete(materialArtificer);
    }
    @PostMapping("materialMassageInsert")
    @ApiOperation("新增服务关联物料包数据")
    public Result materialMassageInsert(@RequestBody MaterialMassage materialMassage ) {
        return materialMassageService.insert(materialMassage);
    }
    @PostMapping("materialMassageDelete")
    @ApiOperation("删除服务关联物料包数据")
    public Result materialMassageDelete(@RequestBody MaterialMassage materialMassage) {
        return  materialMassageService.materialMassageDelete(materialMassage);
    }
    @PostMapping("materialMassageUpdata")
    @ApiOperation("修改服务关联物料包数据")
    public Result materialMassageUpdata(@RequestBody MaterialMassage materialMassage) {
        return materialMassageService.materialMassageUpdata(materialMassage);
    }
    /**
     * 根据主键查询
     *
     * @param id 主键
     * @return 返回记录，没有返回null
     */
    @GetMapping("getById")
    @ApiOperation("根据主键查询物料包")
    public Result getById(Integer id) {
        return Result.success().put("data", materialService.getById(id)) ;
    }    
     
    /**
     * 新增，忽略null字段
     *
     * @param material 新增的记录
     * @return 返回影响行数
     */
    @PostMapping("insert")
    @ApiOperation("新增物料包，忽略null字段")
    public Result insert(Material material) {
        return materialService.insertIgnoreNull(material) ;
    }
      
    /**
     * 修改，忽略null字段
     *
     * @param material 修改的记录
     * @return 返回影响行数
     */
    @PostMapping("update")
    @ApiOperation("修改物料包")
    public Result update(Material material) {
        return materialService.updateIgnoreNull(material) ;
    }
    
    /**xaX
     * 删除记录
     *
     * @param material 待删除的记录
     * @return 返回影响行数
     */
    @PostMapping("delete")
    @ApiOperation("删除物料包记录（伪删除）")
    public Result delete(Material material) {
        return  materialService.delete(material);
    }
    
}