package io.renren.modules.admin.controller;

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

import org.apache.shiro.authz.annotation.RequiresPermissions;
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 io.renren.modules.admin.entity.SignEntity;
import io.renren.modules.admin.service.SignService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 签到表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-02-14 15:21:05
 */
@RestController
@RequestMapping("admin/sign")
public class SignController {
    @Autowired
    private SignService signService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("admin:sign:info")
    public R info(@PathVariable("id") Long id){
		SignEntity sign = signService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:sign:save")
    public R save(@RequestBody SignEntity sign){
		signService.save(sign);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:sign:update")
    public R update(@RequestBody SignEntity sign){
		signService.updateById(sign);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("admin:sign:delete")
    public R delete(@RequestBody Long[] ids){
		signService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
