package com.elab.spring.anno;

import com.elab.annotation.Author;
import com.elab.annotation.Description;
import com.elab.core.aop.annotations.ExceptionHandle;
import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.*;

/**
 * 作者注解描述
 *
 * @author liukx
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Author
@ExceptionHandle
@Description
public @interface AuthorDescription {

    /**
     * 负责人
     *
     * @return
     */
    @AliasFor(annotation = Author.class, attribute = "nickname") String[] nickname() default {};

    /**
     * 功能描述
     *
     * @return
     */
    @AliasFor(annotation = Description.class, attribute = "describe") String describe();

    /**
     * 模块名称
     *
     * @return
     */
    @AliasFor(annotation = Description.class, attribute = "modulesName") String modulesName();

    /**
     * 查找索引，可以通过参数中的内容来定义，方便通过控制台来搜索内容
     *
     * <code>
     * // 下面是根据第一个参数的id和第二个参数的username组成的searchKey
     *
     * @AuthorDescription(modulesName = "user", describe = "这是一个测试", nickname = {"liukx","jay"}, searchKey = "${request[0].id}-${request[1].username}")
     * public String test(Map<String, String> request, UserModel userModel) {
     * return "OK";
     * }
     *
     * <p>
     * Map<String, String> request = new HashMap<>();
     * request.put("id", "1314");
     * request.put("username", "jayzhou");
     * request.put("sex", "MAN");
     * request.put("age", "13");
     * <p>
     * UserModel userModel = new UserModel();
     * userModel.setUserId("5555");
     * userModel.setUsername("liukx");
     * <p>
     * String test = testAnnotation.test(request, userModel);
     *
     * 得到结果: 1314-liukx
     *
     * </code>
     */
    @AliasFor(annotation = Description.class, attribute = "searchKey") String searchKey();

}
