 package com.huimv.management.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huimv.management.entity.YearPigPedigreeEntity;
import com.huimv.management.service.YearPigPedigreeService;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.R;



/**
 * 年猪谱系
 *
 * @author yinhao
 * @email yinhao@163.com
 * @date 2021-05-07 15:32:42
 */
@Api(tags = "年猪谱系")
@RestController
@RequestMapping("management/yearpigpedigree")
public class YearPigPedigreeController {
    @Autowired
    private YearPigPedigreeService yearPigPedigreeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = yearPigPedigreeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		YearPigPedigreeEntity yearPigPedigree = yearPigPedigreeService.getById(id);

        return R.ok().put("yearPigPedigree", yearPigPedigree);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody YearPigPedigreeEntity yearPigPedigree){
		yearPigPedigreeService.save(yearPigPedigree);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody YearPigPedigreeEntity yearPigPedigree){
		yearPigPedigreeService.updateById(yearPigPedigree);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		yearPigPedigreeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
