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.MemberLocation;
import com.huijy.management.service.IMemberLocationService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 会员坐标记录Controller
 *
 * @author luobo
 * @date 2021-09-12
 */
@RestController
@RequestMapping("/management/location")
public class MemberLocationController extends BaseController
{
    @Autowired
    private IMemberLocationService memberLocationService;

    /**
     * 查询会员坐标记录列表
     */
    @PreAuthorize("@ss.hasPermi('management:location:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberLocation memberLocation)
    {
        startPage();
        List<MemberLocation> list = memberLocationService.selectMemberLocationList(memberLocation);
        return getDataTable(list);
    }

    /**
     * 导出会员坐标记录列表
     */
    @PreAuthorize("@ss.hasPermi('management:location:export')")
    @Log(title = "会员坐标记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MemberLocation memberLocation)
    {
        List<MemberLocation> list = memberLocationService.selectMemberLocationList(memberLocation);
        ExcelUtil<MemberLocation> util = new ExcelUtil<MemberLocation>(MemberLocation.class);
        return util.exportExcel(list, "会员坐标记录数据");
    }

    /**
     * 获取会员坐标记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:location:query')")
    @GetMapping(value = "/{memberLocationId}")
    public AjaxResult getInfo(@PathVariable("memberLocationId") Long memberLocationId)
    {
        return AjaxResult.success(memberLocationService.selectMemberLocationByMemberLocationId(memberLocationId));
    }

    /**
     * 新增会员坐标记录
     */
    @PreAuthorize("@ss.hasPermi('management:location:add')")
    @Log(title = "会员坐标记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberLocation memberLocation)
    {
        return toAjax(memberLocationService.insertMemberLocation(memberLocation));
    }

    /**
     * 修改会员坐标记录
     */
    @PreAuthorize("@ss.hasPermi('management:location:edit')")
    @Log(title = "会员坐标记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberLocation memberLocation)
    {
        return toAjax(memberLocationService.updateMemberLocation(memberLocation));
    }

    /**
     * 删除会员坐标记录
     */
    @PreAuthorize("@ss.hasPermi('management:location:remove')")
    @Log(title = "会员坐标记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberLocationIds}")
    public AjaxResult remove(@PathVariable Long[] memberLocationIds)
    {
        return toAjax(memberLocationService.deleteMemberLocationByMemberLocationIds(memberLocationIds));
    }
}
