package com.huijy.web.controller.management;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.huijy.common.annotation.Log;
import com.huijy.common.core.controller.BaseController;
import com.huijy.common.core.domain.AjaxResult;
import com.huijy.common.enums.BusinessType;
import com.huijy.management.domain.MemberEvaluate;
import com.huijy.management.service.IMemberEvaluateService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 会员评价Controller
 *
 * @author luobo
 * @date 2021-09-12
 */
@RestController
@RequestMapping("/management/evaluate")
public class MemberEvaluateController extends BaseController
{
    @Autowired
    private IMemberEvaluateService memberEvaluateService;

    /**
     * 查询会员评价列表
     */
    @PreAuthorize("@ss.hasPermi('management:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberEvaluate memberEvaluate)
    {
        startPage();
        List<MemberEvaluate> list = memberEvaluateService.selectMemberEvaluateList(memberEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出会员评价列表
     */
    @PreAuthorize("@ss.hasPermi('management:evaluate:export')")
    @Log(title = "会员评价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MemberEvaluate memberEvaluate)
    {
        List<MemberEvaluate> list = memberEvaluateService.selectMemberEvaluateList(memberEvaluate);
        ExcelUtil<MemberEvaluate> util = new ExcelUtil<MemberEvaluate>(MemberEvaluate.class);
        return util.exportExcel(list, "会员评价数据");
    }

    /**
     * 获取会员评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:evaluate:query')")
    @GetMapping(value = "/{memberEvaluateId}")
    public AjaxResult getInfo(@PathVariable("memberEvaluateId") Long memberEvaluateId)
    {
        return AjaxResult.success(memberEvaluateService.selectMemberEvaluateByMemberEvaluateId(memberEvaluateId));
    }

    /**
     * 新增会员评价
     */
    @PreAuthorize("@ss.hasPermi('management:evaluate:add')")
    @Log(title = "会员评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberEvaluate memberEvaluate)
    {
        return toAjax(memberEvaluateService.insertMemberEvaluate(memberEvaluate));
    }

    /**
     * 修改会员评价
     */
    @PreAuthorize("@ss.hasPermi('management:evaluate:edit')")
    @Log(title = "会员评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberEvaluate memberEvaluate)
    {
        return toAjax(memberEvaluateService.updateMemberEvaluate(memberEvaluate));
    }

    /**
     * 删除会员评价
     */
    @PreAuthorize("@ss.hasPermi('management:evaluate:remove')")
    @Log(title = "会员评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberEvaluateIds}")
    public AjaxResult remove(@PathVariable Long[] memberEvaluateIds)
    {
        return toAjax(memberEvaluateService.deleteMemberEvaluateByMemberEvaluateIds(memberEvaluateIds));
    }
}
