package com.platform.yijia.controller;

import com.google.gson.Gson;
import com.platform.yijia.param.request.RequestParameter;
import com.platform.yijia.pojo.SysDept;
import com.platform.yijia.service.SysDeptService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

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

@Controller
@RequestMapping("/demo")
public class SydDeptController {

    @Resource
    private SysDeptService sysDeptService;

    @RequestMapping(value = "/getDeptInfo", consumes = "application/json", method = RequestMethod.POST)
    @ResponseBody
    public String getDeptInfo(@RequestBody RequestParameter requestParameter) {
        List<SysDept> sysDepts=sysDeptService.getDeptList(requestParameter.getParentId());
        Gson gson =new Gson();
        return  gson.toJson(sysDepts);
    }
}
