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.StoreEvaluateAttach;
import com.younike.service.service.IStoreEvaluateAttachService;
import com.younike.common.core.page.TableResult;

/**
 * 门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/storeEvaluateAttach")
public class StoreEvaluateAttachController extends BaseController {
    @Autowired
    private IStoreEvaluateAttachService storeEvaluateAttachService;

    /**
     * 查询门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				列表
     */
    @RequiresPermissions("attach:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<StoreEvaluateAttach> page) {

        return storeEvaluateAttachService.page(page);
    }


    /**
     * 获取门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				详细信息
     */
    @RequiresPermissions("attach:query")
    @GetMapping(value = "/{evaluateAttachId}")
    public APIResult getInfo(@PathVariable("evaluateAttachId") String evaluateAttachId) {
        return ResultGenerator.getSuccessResult(storeEvaluateAttachService.getById(evaluateAttachId));
    }

    /**
     * 新增门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				
     */
    @RequiresPermissions("attach:add")
    @OpLog(title = "门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody StoreEvaluateAttach storeEvaluateAttach) {
        return ResultGenerator.getSuccessResult(storeEvaluateAttachService.save(storeEvaluateAttach));
    }

    /**
     * 修改门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				
     */
    @RequiresPermissions("attach:edit")
    @OpLog(title = "门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody StoreEvaluateAttach storeEvaluateAttach) {
        return ResultGenerator.getSuccessResult(storeEvaluateAttachService.updateById(storeEvaluateAttach));
    }

    /**
     * 删除门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				
     */
    @RequiresPermissions("attach:remove")
    @OpLog(title = "门店评价图片视频（主记录evaluate删除时，关联的附件直接删除）				", type = BusinessType.DELETE)
    @DeleteMapping("/{evaluateAttachIds}")
    public APIResult remove(@PathVariable List<String> evaluateAttachIds) {
        return ResultGenerator.getSuccessResult(storeEvaluateAttachService.removeByIds(evaluateAttachIds));
    }
}
