コードアノテーション仕様

3613 ワード

コードアノテーション仕様
一、バックエンドコード注釈
1.クラス(インタフェース)コメント
(1)swaggerを用いた項目
@Controller
@RequestMapping("/testController")
@Api(value="Controller   ")
public class TestController {
	...
	...
}

/**
 * 
* @TODO: ( service       ) 
* @author: Administrator 
* @date: date{time} (  )
 */
public interface TestService {
	...
	...
}
(2)swaggerを使用しない項目
/**
 * 
* @TODO: ( Controller       ) 
* @author: Administrator 
* @date: date{time} (  )
 */
@Controller
@RequestMapping("/testController")
public class TestController {
	...
	...
}
/**
 * 
* @TODO: ( Service       ) 
* @author: Administrator 
* @date: date{time} (  )
 */
public interface TestService {
	...
	...
}
2.メソッドコメント
(1)swaggerの使用
1)1個のパラメータ
	@ResponseBody
   	@ApiOperation(value="    ", notes="          ")
   	@ApiImplicitParam(name = "param1", value = "  1", required = false, dataType = "String")
   	@RequestMapping(value = "/testFunction", method = RequestMethod.POST)
   	public Result testFunction(String param1) {
		...
		...
	}
2)複数のパラメータ
	@ResponseBody
   	@ApiOperation(value="    ", notes="          ")
   	@ApiImplicitParams({
    	@ApiImplicitParam(name = "param1", value = "  1", required = false, dataType = "String")
	    @ApiImplicitParam(name = "param2", value = "  2", required = false, dataType = "String")
    	@ApiImplicitParam(name = "param3", value = "  3", required = false, dataType = "String")
		@ApiImplicitParam(name = "param4", value = "  4", required = false, dataType = "String") })
   	@RequestMapping(value = "/testFunction", method = RequestMethod.POST)
   	public Result testFunction(String param1, String param2,String param3,String param4) {
		...
		...    
}
(2)swaggerを使用しない
/**
	 * 
	* @TODO:(      ) 
	* @param param1
	* @param param2
	* @return(          )
	 */
@ResponseBody
@RequestMapping("/testFunction")
	public String testfunction(String param1,String param2) {
			....
}
3.グローバル変数コメント
	/**          . */
	private final static Logger log = LoggerFactory.getLogger(WechatDownload.class);
4.フィールド/属性コメント
(1)swaggerの使用
@ApiModel(value = "    ")
public class Test {

	@ApiModelProperty(value = "id")
	private String id ;

	@ApiModelProperty(value = "  ")
	private String name;

	@ApiModelProperty(value = "  ")
	private Integer type;
   	……
}
(2)swaggerを使用しない
/**
 * 
* @TODO: Test    
* @author: Administrator 
* @date: 2018-11-7 15:53:37 
 */
public class Test {

	private String id ; 			//id

	private String name;			//  

	private Integer type;			//   

	……
}
SwaggerコメントAPIの詳細:
https://blog.csdn.net/xupeng874395012/article/details/68946676/
二、フロントエンドコード注釈
1.HTMLコメント




2.JavaScript、CSSコメント
(1)1行コメント
/*   16     */ 
.dreamdublack16px 
{ 
	color:black; 
	font-size:16px; 
} 
//     : 
document.getElementById("myH1").innerHTML="        "; 
(2)複数行コメント
/* 
           
          
          
*/ 
document.getElementById("myH1").innerHTML="        ";
document.getElementById("myP").innerHTML="         。";
(3)行末コメント
var x=5; //    x    5      
var y=x+2; //    y    x+2