# Description This pull request includes several changes aimed at improving the code structure and removing redundant code. The most significant changes involve reordering methods, removing unnecessary annotations, and refactoring constructors to use dependency injection. Autowired now comes via constructor (which also doesn't need autowired annotation as its done by default for configuration) ## Checklist - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have performed a self-review of my own code - [ ] I have attached images of the change if it is UI based - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] If my code has heavily changed functionality I have updated relevant docs on [Stirling-PDFs doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) - [ ] My changes generate no new warnings - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only)
33 lines
1.1 KiB
Java
33 lines
1.1 KiB
Java
package stirling.software.SPDF.config;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Scope;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import stirling.software.SPDF.config.interfaces.ShowAdminInterface;
|
|
import stirling.software.SPDF.model.ApplicationProperties;
|
|
|
|
@Service
|
|
class AppUpdateService {
|
|
|
|
private final ApplicationProperties applicationProperties;
|
|
|
|
private final ShowAdminInterface showAdmin;
|
|
|
|
public AppUpdateService(
|
|
ApplicationProperties applicationProperties,
|
|
@Autowired(required = false) ShowAdminInterface showAdmin) {
|
|
this.applicationProperties = applicationProperties;
|
|
this.showAdmin = showAdmin;
|
|
}
|
|
|
|
@Bean(name = "shouldShow")
|
|
@Scope("request")
|
|
public boolean shouldShow() {
|
|
boolean showUpdate = applicationProperties.getSystem().isShowUpdate();
|
|
boolean showAdminResult = (showAdmin != null) ? showAdmin.getShowUpdateOnlyAdmins() : true;
|
|
return showUpdate && showAdminResult;
|
|
}
|
|
}
|