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.MemberFavoriteEntity;
import io.renren.modules.admin.service.MemberFavoriteService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用户收藏
 *
 * @author huwhois
 * @email huwhois@gmail.com
 * @date 2020-07-30 11:40:27
 */
@RestController
@RequestMapping("admin/memberfavorite")
public class MemberFavoriteController {
    @Autowired
    private MemberFavoriteService memberFavoriteService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("admin:memberfavorite:info")
    public R info(@PathVariable("id") Long id){
		MemberFavoriteEntity memberFavorite = memberFavoriteService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:memberfavorite:save")
    public R save(@RequestBody MemberFavoriteEntity memberFavorite){
		memberFavoriteService.save(memberFavorite);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:memberfavorite:update")
    public R update(@RequestBody MemberFavoriteEntity memberFavorite){
		memberFavoriteService.updateById(memberFavorite);

        return R.ok();
    }

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

        return R.ok();
    }

}
