package org.dromara.system.controller.system;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.system.domain.vo.SysAreaVo;
import org.dromara.system.domain.bo.SysAreaBo;
import org.dromara.system.service.ISysAreaService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

/**
 * 区域
 * 前端访问路由地址为:/system/area
 *
 * @author LionLi
 * @date 2024-04-18
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/area")
public class SysAreaController extends BaseController {

    private final ISysAreaService sysAreaService;



    /***
     * @Param
     * @Return
     * @Author sunzexing
     * @Date 2024-04-19 15:10
     * 说明：省市级联
     **/
    @PostMapping("/queryList")
    @Log(title = "区域查询", businessType = BusinessType.OTHER)
    public R<List<SysAreaVo>>  queryList(SysAreaBo bo){
        return R.ok(this.sysAreaService.queryList(bo));
    }

//
//    /**
//     * 查询区域列表
//     */
//    @SaCheckPermission("system:area:list")
//    @GetMapping("/list")
//    public TableDataInfo<SysAreaVo> list(SysAreaBo bo, PageQuery pageQuery) {
//        return sysAreaService.queryPageList(bo, pageQuery);
//    }
//
//    /**
//     * 导出区域列表
//     */
//    @SaCheckPermission("system:area:export")
//    @Log(title = "区域", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(SysAreaBo bo, HttpServletResponse response) {
//        List<SysAreaVo> list = sysAreaService.queryList(bo);
//        ExcelUtil.exportExcel(list, "区域", SysAreaVo.class, response);
//    }
//
//    /**
//     * 获取区域详细信息
//     *
//     * @param areaId 主键
//     */
//    @SaCheckPermission("system:area:query")
//    @GetMapping("/{areaId}")
//    public R<SysAreaVo> getInfo(@NotNull(message = "主键不能为空")
//                                     @PathVariable Long areaId) {
//        return R.ok(sysAreaService.queryById(areaId));
//    }
//
//    /**
//     * 新增区域
//     */
//    @SaCheckPermission("system:area:add")
//    @Log(title = "区域", businessType = BusinessType.INSERT)
//    @RepeatSubmit()
//    @PostMapping()
//    public R<Void> add(@Validated(AddGroup.class) @RequestBody SysAreaBo bo) {
//        return toAjax(sysAreaService.insertByBo(bo));
//    }
//
//    /**
//     * 修改区域
//     */
//    @SaCheckPermission("system:area:edit")
//    @Log(title = "区域", businessType = BusinessType.UPDATE)
//    @RepeatSubmit()
//    @PutMapping()
//    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysAreaBo bo) {
//        return toAjax(sysAreaService.updateByBo(bo));
//    }
//
//    /**
//     * 删除区域
//     *
//     * @param areaIds 主键串
//     */
//    @SaCheckPermission("system:area:remove")
//    @Log(title = "区域", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{areaIds}")
//    public R<Void> remove(@NotEmpty(message = "主键不能为空")
//                          @PathVariable Long[] areaIds) {
//        return toAjax(sysAreaService.deleteWithValidByIds(List.of(areaIds), true));
//    }
}
