AreaController.java 1.84 KB
Newer Older
eddie.woo's avatar
eddie.woo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
package pwc.taxtech.atms.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.dto.AreaDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.AreaService;

@RestController
@RequestMapping("/api/v1/area/")
public class AreaController {

    private static Logger logger = LoggerFactory.getLogger(AreaController.class);

    @Autowired
    private AreaService areaService;

    @ApiOperation(value = "Active or Deactive the specific area.")
    @RequestMapping(value = "isactive", method = RequestMethod.POST)
    public @ResponseBody OperationResultDto<List<String>> setIsActive(@RequestBody AreaDto areaDto) {
        logger.info("/api/v1/area/isactive");
        return areaService.setIsActive(areaDto);
    }

    @ApiOperation(value = "Get area list")
    @RequestMapping(value = "getAreaList", method = RequestMethod.GET)
    public @ResponseBody List<AreaDto> getAreaList(@RequestParam(defaultValue = "1") int type) {
        logger.info("/api/v1/area/getAreaList");
        return areaService.getAreaList(type);
    }

    @ApiOperation(value = "Get Tree")
    @RequestMapping(value = "tree", method = RequestMethod.GET)
    public @ResponseBody List<AreaDto> getAreaTree(@RequestParam(name = "type") int type) {
        logger.info("/api/v1/area/tree");
        return areaService.getAreaTree(type);
    }
}