gaodm преди 4 години
родител
ревизия
af05bbf424

+ 18 - 0
src/main/java/com/diagbot/dto/Cn2SpellDTO.java

@@ -0,0 +1,18 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/9/22 16:05
+ */
+@Getter
+@Setter
+public class Cn2SpellDTO {
+    private List<Cn2SpellDetailDTO> cn2SpellDetailDTOList = new ArrayList<>();
+}

+ 18 - 0
src/main/java/com/diagbot/dto/Cn2SpellDetailDTO.java

@@ -0,0 +1,18 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/9/22 16:06
+ */
+@Getter
+@Setter
+public class Cn2SpellDetailDTO {
+    //汉字
+    private String cn;
+    //拼音
+    private String spell;
+}

+ 43 - 0
src/main/java/com/diagbot/facade/Cn2SpellFacade.java

@@ -0,0 +1,43 @@
+package com.diagbot.facade;
+
+import com.diagbot.dto.Cn2SpellDTO;
+import com.diagbot.dto.Cn2SpellDetailDTO;
+import com.diagbot.util.Cn2SpellUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.Cn2SpellVO;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/9/22 16:02
+ */
+@Component
+public class Cn2SpellFacade {
+    /**
+     * 拼音转化汉字拼音首字母
+     *
+     * @param cn2SpellVO 拼音转化入参
+     * @return 拼音转化出参
+     */
+    public Cn2SpellDTO cn2Spell(Cn2SpellVO cn2SpellVO) {
+        Cn2SpellDTO cn2SpellDTO = new Cn2SpellDTO();
+        if (null != cn2SpellVO && ListUtil.isNotEmpty(cn2SpellVO.getCnList())) {
+            List<Cn2SpellDetailDTO> cn2SpellDetailDTOList = new ArrayList<>();
+            for (String cn : cn2SpellVO.getCnList()) {
+                if (StringUtil.isNotBlank(cn)) {
+                    Cn2SpellDetailDTO cn2SpellDetailDTO = new Cn2SpellDetailDTO();
+                    cn2SpellDetailDTO.setCn(cn);
+                    cn2SpellDetailDTO.setSpell(Cn2SpellUtil.converterToFirstSpell(cn));
+                    cn2SpellDetailDTOList.add(cn2SpellDetailDTO);
+                }
+            }
+            cn2SpellDTO.setCn2SpellDetailDTOList(cn2SpellDetailDTOList);
+        }
+        return cn2SpellDTO;
+    }
+}

+ 19 - 0
src/main/java/com/diagbot/vo/Cn2SpellVO.java

@@ -0,0 +1,19 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/9/22 16:03
+ */
+@Getter
+@Setter
+public class Cn2SpellVO {
+    //汉字列表
+    private List<String> cnList = new ArrayList<>();
+}

+ 36 - 0
src/main/java/com/diagbot/web/Cn2SpellController.java

@@ -0,0 +1,36 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.Cn2SpellDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.Cn2SpellFacade;
+import com.diagbot.vo.Cn2SpellVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description: 拼音转化控制层
+ * @author: gaodm
+ * @time: 2020/9/22 16:01
+ */
+@RestController
+@RequestMapping("/trans")
+@Api(value = "拼音转化API", tags = { "拼音转化API" })
+@SuppressWarnings("unchecked")
+public class Cn2SpellController {
+    @Autowired
+    private Cn2SpellFacade cn2SpellFacade;
+
+    @ApiOperation(value = "拼音转化拼音首字母[by:gaodm]",
+            notes = "")
+    @PostMapping("/cn2Spell")
+    @SysLogger("cn2Spell")
+    public RespDTO<Cn2SpellDTO> cn2Spell(@RequestBody Cn2SpellVO cn2SpellVO) {
+        return RespDTO.onSuc(cn2SpellFacade.cn2Spell(cn2SpellVO));
+    }
+}