¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.basicSetup; |
| | | |
| | | import com.zhitan.basicSetup.service.ISysEquipmentfileService; |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.config.BaseConfig; |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.enums.BusinessType; |
| | | import com.zhitan.common.utils.file.FileUploadUtils; |
| | | import com.zhitan.common.utils.uuid.UUID; |
| | | import com.zhitan.realtimedata.domain.SysEquipmentFile; |
| | | import com.zhitan.realtimedata.domain.SysSvgInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * ç»æå¾Controller |
| | | * |
| | | * @author sys |
| | | * @date 2020-02-24 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/basicSetup/equipmentfile") |
| | | public class SysEquipmentfileController extends BaseController { |
| | | |
| | | private final ISysEquipmentfileService sysEquipmentfileService; |
| | | |
| | | public SysEquipmentfileController( |
| | | ISysEquipmentfileService sysEquipmentfileService) { |
| | | this.sysEquipmentfileService = sysEquipmentfileService; |
| | | } |
| | | |
| | | @PostMapping(value = "/upload") |
| | | @Log(title = "ç³»ç»å¾", businessType = BusinessType.IMPORT) |
| | | public AjaxResult upload(MultipartFile file) throws IOException { |
| | | if (!file.isEmpty()) { |
| | | String fileSuffix = FileUploadUtils.getExtension(file); |
| | | if (StringUtils.containsIgnoreCase(".svg,.jpg,.png,.gif", fileSuffix)) { |
| | | //æä»¶æç»ä¿åçç»å¯¹è·¯å¾ |
| | | String filePath = FileUploadUtils.upload(BaseConfig.getConfigurePath(), file); |
| | | return AjaxResult.success(filePath); |
| | | } |
| | | return AjaxResult.error("æä»¶æ ¼å¼é误"); |
| | | } |
| | | return AjaxResult.error("ç³»ç»å¾ä¸ä¼ 失败"); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç»æå¾ |
| | | */ |
| | | @Log(title = "ç³»ç»å¾", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysEquipmentFile sysEquipmentfile) { |
| | | try { |
| | | sysEquipmentfileService.saveEquipmentFile(sysEquipmentfile); |
| | | return AjaxResult.success(); |
| | | } catch (Exception ex) { |
| | | log.error("ç»æå¾æ´æ°å¤±è´¥", ex); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @PutMapping("/setting/{nodeId}") |
| | | public AjaxResult saveSetting(@PathVariable("nodeId") String nodeId, |
| | | @RequestBody List<SysSvgInfo> svgInfo) { |
| | | try { |
| | | svgInfo.forEach(info -> info.setId(UUID.fastUUID().toString())); |
| | | sysEquipmentfileService.saveSettingInfo(nodeId, svgInfo); |
| | | return AjaxResult.success("ä¿åæåï¼"); |
| | | } catch (Exception ex) { |
| | | return AjaxResult.error("ä¿å失败ï¼"); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/configure/{nodeId}") |
| | | public AjaxResult getConfigure(@PathVariable("nodeId") String nodeId) { |
| | | try { |
| | | SysEquipmentFile sysEquipmentfile = sysEquipmentfileService.getConfigure(nodeId); |
| | | return AjaxResult.success(sysEquipmentfile); |
| | | } catch (Exception ex) { |
| | | return AjaxResult.error("æ¥è¯¢å¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | } |