| package com.moral.api.controller; | 
|   | 
| import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | 
| import com.moral.api.entity.OrganizationLayout; | 
| import com.moral.api.pojo.form.organizationLayout.OrganizationLayoutSetUp; | 
| import com.moral.api.service.OrganizationLayoutService; | 
| import com.moral.constant.ResponseCodeEnum; | 
| import com.moral.constant.ResultMessage; | 
| import com.moral.util.WebUtils; | 
| import io.swagger.annotations.Api; | 
| import io.swagger.models.auth.In; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.annotation.Resource; | 
| import javax.servlet.http.HttpServletRequest; | 
| import java.util.ArrayList; | 
| import java.util.HashMap; | 
| import java.util.List; | 
| import java.util.Map; | 
|   | 
| @Slf4j | 
| @Api(tags = {"页面布局"}) | 
| @RestController | 
| @RequestMapping("/organizationLayout") | 
| public class OrganizationLayoutController { | 
|   | 
|     @Resource | 
|     private OrganizationLayoutService organizationLayoutService; | 
|   | 
|     @RequestMapping(value = "getLayoutData",method = RequestMethod.GET) | 
|     @ResponseBody | 
|     public ResultMessage getLayoutData(HttpServletRequest request){ | 
|         Map<String,Object> parameters = WebUtils.getParametersStartingWith(request,null); | 
|         int organization_id = Integer.parseInt(parameters.get("organization_id").toString()); | 
|         int version_id = Integer.parseInt(parameters.get("version_id").toString()); | 
|         if (ObjectUtils.isEmpty(organization_id) || ObjectUtils.isEmpty(version_id)){ | 
|             return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|         } | 
|         List<Map<String,Object>> result = organizationLayoutService.getData(parameters); | 
|         return ResultMessage.ok(result); | 
|     } | 
|   | 
|     @RequestMapping(value = "setUpLayout",method = RequestMethod.POST) | 
|     @ResponseBody | 
|     public ResultMessage setUpLayout(@RequestBody OrganizationLayoutSetUp organizationLayoutSetUp){ | 
|         int organization_id = organizationLayoutSetUp.getOrganizationId(); | 
|         int version_id = organizationLayoutSetUp.getVersionId(); | 
|         if (ObjectUtils.isEmpty(organization_id) || ObjectUtils.isEmpty(version_id)){ | 
|             return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|         } | 
|         Map<String, Integer> map = new HashMap<>(); | 
|         map.put("organization_id",organization_id); | 
|         map.put("version_id",version_id); | 
|         List<OrganizationLayout> organizationLayouts = organizationLayoutSetUp.getOrganizationLayouts(); | 
|         organizationLayoutService.setUp(map,organizationLayouts); | 
|         return ResultMessage.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "getLayoutByMac", method = RequestMethod.GET) | 
|     @ResponseBody | 
|     public ResultMessage getLayoutByMac(HttpServletRequest request){ | 
|         Map<String,Object> parameters = WebUtils.getParametersStartingWith(request,null); | 
|         if (ObjectUtils.isEmpty(parameters.get("mac"))){ | 
|             return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|         } | 
|         Map<String,Object> resultMap = organizationLayoutService.getLayoutByMac(parameters.get("mac").toString()); | 
|         if (ObjectUtils.isEmpty(resultMap)){ | 
|             return null; | 
|         } | 
|         return ResultMessage.ok(resultMap); | 
|     } | 
| } |