package com.xhkjedu.sapi.controller.system;

import com.xhkjedu.annotation.Action;
import com.xhkjedu.sapi.model.system.TAreazone;
import com.xhkjedu.sapi.service.system.AreazoneService;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* @author ywx
* @classname TAreazoneController
* @description
* @date 2021/04/08 09:20
**/
@RestController
@RequestMapping("/areazone")
public class AreazoneController {
    @Resource
    private AreazoneService areazoneService;

    @PostMapping("/add")
    @Action("区域管理-增加")
    public ResultVo add(@RequestBody TAreazone areazone) {
        areazoneService.save(areazone);
        return new ResultVo(0, "保存成功");
    }

    @PostMapping("/delete")
    @Action("区域管理-删除")
    public ResultVo delete(@RequestBody TAreazone areazone) {
        areazoneService.deleteById(areazone.getAreaid());
        return new ResultVo(0,"删除成功");
    }

    @PostMapping("/update")
    @Action("区域管理-修改")
    public ResultVo update(@RequestBody TAreazone areazone) {
        areazoneService.update(areazone);
        return new ResultVo(0,"修改成功");
    }

    @PostMapping("/list")
    public ResultVo list() {
        List<Map> list = areazoneService.listAll();
        return new ResultVo(0,"获取地区列表成功",list);
    }

    @PostMapping("/list_sel")
    public ResultVo listForSel() {
        List<Map> list = areazoneService.listForSel();
        return new ResultVo(0,"获取地区选择列表成功",list);
    }
}
