org.shoulder.web.template.crud.BaseControllerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shoulder-web Show documentation
Show all versions of shoulder-web Show documentation
shoulder WEB 模块,基于Spring Boot Web提供了 Controller AOP 日志、AOP异常处理,统一返回值,健康检查,租户、用户解析,Web
安全防护,通用CrudController,动态字典,标签管理,HTTP client AOP日志、AOP异常处理等能力,助力Web飞速开发。
The newest version!
package org.shoulder.web.template.crud;
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
import org.shoulder.core.converter.ShoulderConversionService;
import org.shoulder.core.log.AppLoggers;
import org.shoulder.core.log.Logger;
import org.shoulder.data.mybatis.template.entity.BaseEntity;
import org.shoulder.data.mybatis.template.entity.BizEntity;
import org.shoulder.data.mybatis.template.service.BaseService;
import org.springframework.core.GenericTypeResolver;
import java.io.Serializable;
/**
* BaseController
*
* @param 实体
* @author lym
*/
public abstract class BaseControllerImpl, ENTITY extends BaseEntity extends Serializable>> implements BaseController {
protected final Logger log = AppLoggers.APP_SERVICE;
protected final SERVICE service;
protected final ShoulderConversionService conversionService;
protected final boolean extendsFromBizEntity = BizEntity.class.isAssignableFrom(getEntityClass());
protected final Class extends Serializable> entityIdType = (Class extends Serializable>) GenericTypeResolver.resolveTypeArguments(getEntityClass(), BaseEntity.class)[0];
protected BaseControllerImpl(SERVICE service, ShoulderConversionService conversionService) {
this.service = service;
this.conversionService = conversionService;
}
@Override
public Class extends Serializable> getEntityIdType() {
return entityIdType;
}
@Override
public boolean extendsFromBizEntity() {
return extendsFromBizEntity;
}
@SuppressWarnings("unchecked")
@Override
public Class getEntityClass() {
return getService() != null ? getService().getEntityClass() :
(Class) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseController.class, 0);
}
@Override
public BaseService getService() {
return service;
}
@Override
public ShoulderConversionService getConversionService() {
return conversionService;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy