package com.inkasso.factoring.org.controller;

import com.inkasso.adapter.response.ResponseData;
import com.inkasso.factoring.org.model.dto.OrgDTO;
import com.inkasso.factoring.org.service.OrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liutao
 * @date  2023-09-07
 */
@RestController
@RequestMapping(path = "org")
//@Permissions(name="组织结构表",code = "orgManage")
public class OrgController {

    @Autowired
    private OrgService orgService;

    /**
     * 查询省  直辖市
     * @return
     */
    @GetMapping("province")
    //@PermissionAndCheck(name = "用户有查询记录的所有年份", code="OrgController:province")
    public ResponseData getProvince(){
        List<OrgDTO> orgDOS = orgService.getProvince();
        return ResponseData.success(orgDOS);
    }

    /**
     * 查询省  直辖市
     * @return
     */
    @GetMapping("all")
    //@PermissionAndCheck(name = "用户有查询记录的所有年份", code="OrgController:province")
    public ResponseData getAll(){
        List<OrgDTO> orgDOS = orgService.getAll();
        return ResponseData.success(orgDOS);
    }

    /**
     * 查询市
     * @param parentId
     * @return
     */
    @GetMapping("city")
    //@PermissionAndCheck(name = "用户有查询记录的所有年份", code="OrgController:city")
    public ResponseData getCity(@RequestParam("parentId") Long parentId){
        List<OrgDTO> orgDOS = orgService.getCityByParentId(parentId);
        return ResponseData.success(orgDOS);
    }
}