cicada.demo.control.Chinese2PinYinController Maven / Gradle / Ivy
package cicada.demo.control;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
//import net.sourceforge.pinyin4j.PinyinHelper;
@RestController
@RequestMapping("sample_rest")
@Api(value = "测试cicada.boot_restcontrol相关框架", description = "测试cicada.boot_restcontrol相关框架")
public class Chinese2PinYinController
{
private Logger log = LoggerFactory.getLogger(Chinese2PinYinController.class);
@RequestMapping(value = "test1", method = RequestMethod.GET)
@ApiOperation("测试中文转拼音")
@ApiImplicitParam(name = "word", value = "参数:中文字符", required = true, paramType = "query", dataType = "String")
public String test1(char word)
{
// String[] cha = PinyinHelper.toHanyuPinyinStringArray(word);
// StringBuffer sBuffer = new StringBuffer();
// for (String string : cha)
// {
// sBuffer.append("_");
// sBuffer.append(string);
// }
// return "转成的拼音:" + sBuffer.toString();
return null;
}
}