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

/**
 * 用户日志
 *
 * @author huwhois
 * @email huwhois@gmail.com
 * @date 2020-07-09 09:40:13
 */
@RestController
@RequestMapping("admin/memberlog")
public class MemberLogController {
    @Autowired
    private MemberLogService memberLogService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("admin:memberlog:info")
    public R info(@PathVariable("id") Long id){
		MemberLogEntity memberLog = memberLogService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:memberlog:save")
    public R save(@RequestBody MemberLogEntity memberLog){
		memberLogService.save(memberLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:memberlog:update")
    public R update(@RequestBody MemberLogEntity memberLog){
		memberLogService.updateById(memberLog);

        return R.ok();
    }

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

        return R.ok();
    }

}
