package io.renren.modules.business.controller;

import io.renren.common.utils.R;
import io.renren.modules.business.dao.BusinessAnnualDao;
import io.renren.modules.business.entity.BusinessAnnualEntity;
import io.renren.modules.business.service.BusinessAnnualService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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



/**
 * 年度总结表
 *
 * @author jiaqiao
 * @email jiaqiao@163.com
 * @date 2022-10-20 19:38:02
 */
@RestController
@RequestMapping("business/businessannual")
public class BusinessAnnualController {
    @Autowired
    private BusinessAnnualService businessAnnualService;

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

        return R.ok().put("page", page);
    }*/
    /**
     * 列表获取所有列表 无翻页
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:businessannual:list")
    public R list(@RequestParam Map<String, Object> params){
        List<BusinessAnnualEntity> page = businessAnnualService.queryList(params);

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:businessannual:info")
    public R info(@PathVariable("id") Integer id){
		BusinessAnnualEntity businessAnnual = businessAnnualService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:businessannual:save")
    public R save(@RequestBody BusinessAnnualEntity businessAnnual){
		businessAnnualService.save(businessAnnual);

        return R.ok();
    }

    /**
     * 修改
     */
    /*@RequestMapping("/update")
    @RequiresPermissions("business:businessannual:update")
    public R update(@RequestBody BusinessAnnualEntity businessAnnual){
		businessAnnualService.updateById(businessAnnual);
        //
        return R.ok();
    }*/

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:businessannual:update")
    public R update(@RequestBody BusinessAnnualEntity businessAnnual){
        businessAnnualService.updateByIdNew(businessAnnual);
        //
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:businessannual:delete")
    public R delete(@RequestBody Integer[] ids){
		businessAnnualService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 获取明细表总结表填写人信息
     * @param params
     * @return
     */
    @RequestMapping("/getWriteList")
    @RequiresPermissions("business:businessannual:list")
    public R getWriteList(){
        List<BusinessAnnualDao> tbr = businessAnnualService.getWriteList();
        return R.ok().put("getWriteList", tbr);
    }
}
