package com.younike.member.controller;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import com.younike.common.bean.APIResult;
import com.younike.common.bean.ResultGenerator;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import com.younike.common.core.page.PageParam;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.younike.common.annotation.OpLog;
import com.younike.common.core.controller.BaseController;
import com.younike.common.core.dto.AjaxResult;
import com.younike.common.constant.BusinessType;
import com.younike.service.pojo.AppMemberVlogAttach;
import com.younike.service.service.IAppMemberVlogAttachService;
import com.younike.common.core.page.TableResult;

/**
 * 会员日记附件信息Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/appMemberVlogAttach")
public class AppMemberVlogAttachController extends BaseController {
    @Autowired
    private IAppMemberVlogAttachService appMemberVlogAttachService;

    /**
     * 查询会员日记附件信息列表
     */
    @RequiresPermissions("attach:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<AppMemberVlogAttach> page) {

        return appMemberVlogAttachService.page(page);
    }


    /**
     * 获取会员日记附件信息详细信息
     */
    @RequiresPermissions("attach:query")
    @GetMapping(value = "/{memberVlogAttachId}")
    public APIResult getInfo(@PathVariable("memberVlogAttachId") String memberVlogAttachId) {
        return ResultGenerator.getSuccessResult(appMemberVlogAttachService.getById(memberVlogAttachId));
    }

    /**
     * 新增会员日记附件信息
     */
    @RequiresPermissions("attach:add")
    @OpLog(title = "会员日记附件信息", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody AppMemberVlogAttach appMemberVlogAttach) {
        return ResultGenerator.getSuccessResult(appMemberVlogAttachService.save(appMemberVlogAttach));
    }

    /**
     * 修改会员日记附件信息
     */
    @RequiresPermissions("attach:edit")
    @OpLog(title = "会员日记附件信息", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody AppMemberVlogAttach appMemberVlogAttach) {
        return ResultGenerator.getSuccessResult(appMemberVlogAttachService.updateById(appMemberVlogAttach));
    }

    /**
     * 删除会员日记附件信息
     */
    @RequiresPermissions("attach:remove")
    @OpLog(title = "会员日记附件信息", type = BusinessType.DELETE)
    @DeleteMapping("/{memberVlogAttachIds}")
    public APIResult remove(@PathVariable List<String> memberVlogAttachIds) {
        return ResultGenerator.getSuccessResult(appMemberVlogAttachService.removeByIds(memberVlogAttachIds));
    }
}
