package com.younike.store.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.StoreEvaluateReplyTemplate;
import com.younike.service.service.IStoreEvaluateReplyTemplateService;
import com.younike.common.core.page.TableResult;

/**
 * 门店评价回复模板				Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/storeEvaluateReplyTemplate")
public class StoreEvaluateReplyTemplateController extends BaseController {
    @Autowired
    private IStoreEvaluateReplyTemplateService storeEvaluateReplyTemplateService;

    /**
     * 查询门店评价回复模板				列表
     */
    @RequiresPermissions("template:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<StoreEvaluateReplyTemplate> page) {

        return storeEvaluateReplyTemplateService.page(page);
    }


    /**
     * 获取门店评价回复模板				详细信息
     */
    @RequiresPermissions("template:query")
    @GetMapping(value = "/{evaluateReplyTemplateId}")
    public APIResult getInfo(@PathVariable("evaluateReplyTemplateId") String evaluateReplyTemplateId) {
        return ResultGenerator.getSuccessResult(storeEvaluateReplyTemplateService.getById(evaluateReplyTemplateId));
    }

    /**
     * 新增门店评价回复模板				
     */
    @RequiresPermissions("template:add")
    @OpLog(title = "门店评价回复模板				", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody StoreEvaluateReplyTemplate storeEvaluateReplyTemplate) {
        return ResultGenerator.getSuccessResult(storeEvaluateReplyTemplateService.save(storeEvaluateReplyTemplate));
    }

    /**
     * 修改门店评价回复模板				
     */
    @RequiresPermissions("template:edit")
    @OpLog(title = "门店评价回复模板				", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody StoreEvaluateReplyTemplate storeEvaluateReplyTemplate) {
        return ResultGenerator.getSuccessResult(storeEvaluateReplyTemplateService.updateById(storeEvaluateReplyTemplate));
    }

    /**
     * 删除门店评价回复模板				
     */
    @RequiresPermissions("template:remove")
    @OpLog(title = "门店评价回复模板				", type = BusinessType.DELETE)
    @DeleteMapping("/{evaluateReplyTemplateIds}")
    public APIResult remove(@PathVariable List<String> evaluateReplyTemplateIds) {
        return ResultGenerator.getSuccessResult(storeEvaluateReplyTemplateService.removeByIds(evaluateReplyTemplateIds));
    }
}
