demo
public abstract class AvconBaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> extends ServiceImpl<M, T> {

    @Autowired
    protected M baseDao;

    @Autowired
    EmsEsDeviceDao emsEsDeviceDao;

    protected Log log = LogFactory.getLog(getClass());

    protected T initEntity(EmsEsBizDTO emsEsBizDTO) throws Exception {
        // 本类的泛型参数
        ParameterizedType ptype = (ParameterizedType) this.getClass().getGenericSuperclass();
        // 下标1表示第二个参数: T的Class
        Class<T> clazz = (Class<T>) ptype.getActualTypeArguments()[1];
        return this.initEntity(emsEsBizDTO, clazz);
    }
}

 

posted on 2024-04-01 18:04  1161588342  阅读(2)  评论(0编辑  收藏  举报