diff --git a/src/main/config/findbugs-filter.xml b/src/main/config/findbugs-filter.xml
index c938e71341..dc336becda 100644
--- a/src/main/config/findbugs-filter.xml
+++ b/src/main/config/findbugs-filter.xml
@@ -10,6 +10,18 @@
+
+
+
+
+
diff --git a/src/main/java/ru/mystamps/web/Url.java b/src/main/java/ru/mystamps/web/Url.java
index beda726feb..1ccf61b213 100644
--- a/src/main/java/ru/mystamps/web/Url.java
+++ b/src/main/java/ru/mystamps/web/Url.java
@@ -37,7 +37,8 @@ public final class Url {
public static final String INDEX_PAGE = "/";
public static final String ROBOTS_TXT = "/robots.txt";
public static final String SITEMAP_XML = "/sitemap.xml";
-
+
+ public static final String DAILY_STATISTICS = "/report/daily";
public static final String SITE_EVENTS_PAGE = "/site/events";
public static final String REGISTRATION_PAGE = "/account/register";
@@ -141,6 +142,7 @@ public static Map asMap(boolean serveContentFromSingleHost) {
map.put("INFO_COLLECTION_PAGE", INFO_COLLECTION_PAGE);
map.put("SITE_EVENTS_PAGE", SITE_EVENTS_PAGE);
map.put("BOOTSTRAP_LANGUAGE", BOOTSTRAP_LANGUAGE);
+ map.put("DAILY_STATISTICS", DAILY_STATISTICS);
if (serveContentFromSingleHost) {
map.put("BOOTSTRAP_CSS", BOOTSTRAP_CSS);
diff --git a/src/main/java/ru/mystamps/web/config/ControllersConfig.java b/src/main/java/ru/mystamps/web/config/ControllersConfig.java
index 297d9a6b5c..d09e7a4d22 100644
--- a/src/main/java/ru/mystamps/web/config/ControllersConfig.java
+++ b/src/main/java/ru/mystamps/web/config/ControllersConfig.java
@@ -88,6 +88,14 @@ public RobotsTxtController getRobotsTxtController() {
return new RobotsTxtController();
}
+ @Bean
+ public ReportController getReportController() {
+ return new ReportController(
+ servicesConfig.getMailService(),
+ servicesConfig.getCronService()
+ );
+ }
+
@Bean
public SeriesController getSeriesController() {
return new SeriesController(
diff --git a/src/main/java/ru/mystamps/web/controller/ReportController.java b/src/main/java/ru/mystamps/web/controller/ReportController.java
new file mode 100644
index 0000000000..9908b4d953
--- /dev/null
+++ b/src/main/java/ru/mystamps/web/controller/ReportController.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009-2016 Slava Semushin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package ru.mystamps.web.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import lombok.RequiredArgsConstructor;
+
+import ru.mystamps.web.Url;
+import ru.mystamps.web.service.CronService;
+import ru.mystamps.web.service.MailService;
+
+/**
+ * @author Maxim Shestakov
+ */
+@Controller
+@RequiredArgsConstructor
+public class ReportController {
+
+ private final MailService mailService;
+ private final CronService cronService;
+
+ @GetMapping(path = Url.DAILY_STATISTICS, produces = "text/plain; charset=UTF-8")
+ @ResponseBody
+ public String showDailyReport() {
+ return mailService.getTextOfDailyStatisticsMail(
+ cronService.getDailyStatistics()
+ );
+ }
+
+}
diff --git a/src/main/java/ru/mystamps/web/model/AddSeriesSalesForm.java b/src/main/java/ru/mystamps/web/model/AddSeriesSalesForm.java
new file mode 100644
index 0000000000..da2bbbb61e
--- /dev/null
+++ b/src/main/java/ru/mystamps/web/model/AddSeriesSalesForm.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009-2017 Slava Semushin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package ru.mystamps.web.model;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import javax.validation.constraints.NotNull;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import ru.mystamps.web.dao.dto.Currency;
+import ru.mystamps.web.service.dto.AddSeriesSalesDto;
+
+@Getter
+@Setter
+public class AddSeriesSalesForm implements AddSeriesSalesDto {
+
+ @DateTimeFormat(pattern = "dd.MM.yyyy")
+ private Date date;
+
+ @NotNull
+ private Integer sellerId;
+
+ private String url;
+
+ @NotNull
+ private BigDecimal price;
+
+ @NotNull
+ private Currency currency;
+
+ private BigDecimal altPrice;
+
+ private Currency altCurrency;
+
+ private Integer buyerId;
+
+}
diff --git a/src/main/java/ru/mystamps/web/model/package-info.java b/src/main/java/ru/mystamps/web/model/package-info.java
new file mode 100644
index 0000000000..7b4107e0ff
--- /dev/null
+++ b/src/main/java/ru/mystamps/web/model/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * DTO
+ * classes that are representing values from site forms and being used by
+ * controllers as input values.
+ */
+package ru.mystamps.web.model;
diff --git a/src/main/java/ru/mystamps/web/service/CronService.java b/src/main/java/ru/mystamps/web/service/CronService.java
index 795c75d015..181053521d 100644
--- a/src/main/java/ru/mystamps/web/service/CronService.java
+++ b/src/main/java/ru/mystamps/web/service/CronService.java
@@ -17,9 +17,12 @@
*/
package ru.mystamps.web.service;
+import ru.mystamps.web.service.dto.AdminDailyReport;
+
public interface CronService {
int PURGE_AFTER_DAYS = 3;
void sendDailyStatistics();
+ AdminDailyReport getDailyStatistics();
void purgeUsersActivations();
}
diff --git a/src/main/java/ru/mystamps/web/service/CronServiceImpl.java b/src/main/java/ru/mystamps/web/service/CronServiceImpl.java
index 729cbc501c..6e25b63ce7 100644
--- a/src/main/java/ru/mystamps/web/service/CronServiceImpl.java
+++ b/src/main/java/ru/mystamps/web/service/CronServiceImpl.java
@@ -55,6 +55,11 @@ public class CronServiceImpl implements CronService {
@Scheduled(cron = EVERY_DAY_AT_00_00)
@Transactional(readOnly = true)
public void sendDailyStatistics() {
+ mailService.sendDailyStatisticsToAdmin(getDailyStatistics());
+ }
+
+ @Override
+ public AdminDailyReport getDailyStatistics() {
Date today = DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
Date yesterday = DateUtils.addDays(today, -1);
@@ -100,7 +105,7 @@ public void sendDailyStatistics() {
);
report.setInvalidCsrfCounter(invalidCsrfCounter);
- mailService.sendDailyStatisticsToAdmin(report);
+ return report;
}
@Override
diff --git a/src/main/java/ru/mystamps/web/service/MailService.java b/src/main/java/ru/mystamps/web/service/MailService.java
index 10b90db247..5ff39a849e 100644
--- a/src/main/java/ru/mystamps/web/service/MailService.java
+++ b/src/main/java/ru/mystamps/web/service/MailService.java
@@ -23,4 +23,5 @@
public interface MailService {
void sendActivationKeyToUser(SendUsersActivationDto activation);
void sendDailyStatisticsToAdmin(AdminDailyReport report);
+ String getTextOfDailyStatisticsMail(AdminDailyReport report);
}
diff --git a/src/main/java/ru/mystamps/web/service/MailServiceImpl.java b/src/main/java/ru/mystamps/web/service/MailServiceImpl.java
index cdf95f9594..b70f9b3489 100644
--- a/src/main/java/ru/mystamps/web/service/MailServiceImpl.java
+++ b/src/main/java/ru/mystamps/web/service/MailServiceImpl.java
@@ -114,7 +114,36 @@ public void sendDailyStatisticsToAdmin(AdminDailyReport report) {
adminLang
);
}
+
+ @Override
+ public String getTextOfDailyStatisticsMail(AdminDailyReport report) {
+ String template = messageSource.getMessage("daily_stat.text", null, adminLang);
+ String fromDate = shortDatePrinter.format(report.getStartDate());
+ String tillDate = shortDatePrinter.format(report.getEndDate());
+
+ Map ctx = new HashMap<>();
+ ctx.put("from_date", fromDate);
+ ctx.put("to_date", tillDate);
+
+ put(ctx, "added_countries_cnt", report.getAddedCountriesCounter());
+ put(ctx, "untranslated_countries_cnt", report.getUntranslatedCountriesCounter());
+ put(ctx, "added_categories_cnt", report.getAddedCategoriesCounter());
+ put(ctx, "untranslated_categories_cnt", report.getUntranslatedCategoriesCounter());
+ put(ctx, "added_series_cnt", report.getAddedSeriesCounter());
+ put(ctx, "updated_series_cnt", report.getUpdatedSeriesCounter());
+ put(ctx, "updated_collections_cnt", report.getUpdatedCollectionsCounter());
+ put(ctx, "registration_requests_cnt", report.getRegistrationRequestsCounter());
+ put(ctx, "registered_users_cnt", report.getRegisteredUsersCounter());
+ put(ctx, "events_cnt", report.countEvents());
+ put(ctx, "not_found_cnt", report.getNotFoundCounter());
+ put(ctx, "failed_auth_cnt", report.getFailedAuthCounter());
+ put(ctx, "missing_csrf_cnt", report.getMissingCsrfCounter());
+ put(ctx, "invalid_csrf_cnt", report.getInvalidCsrfCounter());
+ put(ctx, "bad_request_cnt", -1L); // TODO: #122
+ return new StrSubstitutor(ctx).replace(template);
+ }
+
@SuppressWarnings("PMD.UseObjectForClearerAPI")
private void sendMail(
final String email,
@@ -183,34 +212,6 @@ private String getSubjectOfDailyStatisticsMail(AdminDailyReport report) {
StrSubstitutor substitutor = new StrSubstitutor(ctx);
return substitutor.replace(template);
}
-
- private String getTextOfDailyStatisticsMail(AdminDailyReport report) {
- String template = messageSource.getMessage("daily_stat.text", null, adminLang);
- String fromDate = shortDatePrinter.format(report.getStartDate());
- String tillDate = shortDatePrinter.format(report.getEndDate());
-
- Map ctx = new HashMap<>();
- ctx.put("from_date", fromDate);
- ctx.put("to_date", tillDate);
-
- put(ctx, "added_countries_cnt", report.getAddedCountriesCounter());
- put(ctx, "untranslated_countries_cnt", report.getUntranslatedCountriesCounter());
- put(ctx, "added_categories_cnt", report.getAddedCategoriesCounter());
- put(ctx, "untranslated_categories_cnt", report.getUntranslatedCategoriesCounter());
- put(ctx, "added_series_cnt", report.getAddedSeriesCounter());
- put(ctx, "updated_series_cnt", report.getUpdatedSeriesCounter());
- put(ctx, "updated_collections_cnt", report.getUpdatedCollectionsCounter());
- put(ctx, "registration_requests_cnt", report.getRegistrationRequestsCounter());
- put(ctx, "registered_users_cnt", report.getRegisteredUsersCounter());
- put(ctx, "events_cnt", report.countEvents());
- put(ctx, "not_found_cnt", report.getNotFoundCounter());
- put(ctx, "failed_auth_cnt", report.getFailedAuthCounter());
- put(ctx, "missing_csrf_cnt", report.getMissingCsrfCounter());
- put(ctx, "invalid_csrf_cnt", report.getInvalidCsrfCounter());
- put(ctx, "bad_request_cnt", -1L); // TODO: #122
-
- return new StrSubstitutor(ctx).replace(template);
- }
private static void put(Map ctx, String key, long value) {
ctx.put(key, String.valueOf(value));
diff --git a/src/main/java/ru/mystamps/web/support/spring/security/Authority.java b/src/main/java/ru/mystamps/web/support/spring/security/Authority.java
index b96ef0eede..f3313a7c09 100644
--- a/src/main/java/ru/mystamps/web/support/spring/security/Authority.java
+++ b/src/main/java/ru/mystamps/web/support/spring/security/Authority.java
@@ -33,6 +33,7 @@ public final class Authority {
public static final GrantedAuthority UPDATE_COLLECTION = new SimpleGrantedAuthority(StringAuthority.UPDATE_COLLECTION);
public static final GrantedAuthority VIEW_SITE_EVENTS = new SimpleGrantedAuthority(StringAuthority.VIEW_SITE_EVENTS);
public static final GrantedAuthority VIEW_SERIES_SALES = new SimpleGrantedAuthority(StringAuthority.VIEW_SERIES_SALES);
+ public static final GrantedAuthority VIEW_DAILY_STATS = new SimpleGrantedAuthority(StringAuthority.VIEW_DAILY_STATS);
private Authority() {
}
diff --git a/src/main/java/ru/mystamps/web/support/spring/security/CustomUserDetailsService.java b/src/main/java/ru/mystamps/web/support/spring/security/CustomUserDetailsService.java
index 6faca3e817..cf72ec4551 100644
--- a/src/main/java/ru/mystamps/web/support/spring/security/CustomUserDetailsService.java
+++ b/src/main/java/ru/mystamps/web/support/spring/security/CustomUserDetailsService.java
@@ -81,6 +81,7 @@ private static Collection extends GrantedAuthority> getAuthorities(UserDetails
authorities.add(Authority.ADD_SERIES_SALES);
authorities.add(Authority.VIEW_SERIES_SALES);
authorities.add(Authority.MANAGE_TOGGLZ);
+ authorities.add(Authority.VIEW_DAILY_STATS);
}
return authorities;
diff --git a/src/main/java/ru/mystamps/web/support/spring/security/HasAuthority.java b/src/main/java/ru/mystamps/web/support/spring/security/HasAuthority.java
index 9bae50010f..a6f54248eb 100644
--- a/src/main/java/ru/mystamps/web/support/spring/security/HasAuthority.java
+++ b/src/main/java/ru/mystamps/web/support/spring/security/HasAuthority.java
@@ -24,6 +24,7 @@ public final class HasAuthority {
public static final String CREATE_SERIES = "hasAuthority('" + StringAuthority.CREATE_SERIES + "')";
public static final String CREATE_CATEGORY = "hasAuthority('" + StringAuthority.CREATE_CATEGORY + "')";
public static final String CREATE_COUNTRY = "hasAuthority('" + StringAuthority.CREATE_COUNTRY + "')";
+ public static final String VIEW_DAILY_STATS = "hasAuthority('" + StringAuthority.VIEW_DAILY_STATS + "')";
public static final String UPDATE_COLLECTION = "hasAuthority('" + StringAuthority.UPDATE_COLLECTION + "')";
public static final String VIEW_SITE_EVENTS = "hasAuthority('" + StringAuthority.VIEW_SITE_EVENTS + "')";
public static final String VIEW_SERIES_SALES = "hasAuthority('" + StringAuthority.VIEW_SERIES_SALES + "')";
diff --git a/src/main/java/ru/mystamps/web/support/spring/security/SecurityConfig.java b/src/main/java/ru/mystamps/web/support/spring/security/SecurityConfig.java
index 36a024dddd..88ef4296ca 100644
--- a/src/main/java/ru/mystamps/web/support/spring/security/SecurityConfig.java
+++ b/src/main/java/ru/mystamps/web/support/spring/security/SecurityConfig.java
@@ -77,6 +77,7 @@ protected void configure(HttpSecurity http) throws Exception {
.mvcMatchers(Url.ADD_SERIES_PAGE).hasAuthority(StringAuthority.CREATE_SERIES)
.mvcMatchers(Url.SITE_EVENTS_PAGE).hasAuthority(StringAuthority.VIEW_SITE_EVENTS)
.mvcMatchers(Url.SUGGEST_SERIES_COUNTRY).hasAuthority(StringAuthority.CREATE_SERIES)
+ .mvcMatchers(Url.DAILY_STATISTICS).hasAuthority(StringAuthority.VIEW_DAILY_STATS)
.regexMatchers(HttpMethod.POST, "/series/[0-9]+")
.hasAnyAuthority(
StringAuthority.UPDATE_COLLECTION,
diff --git a/src/main/java/ru/mystamps/web/support/spring/security/StringAuthority.java b/src/main/java/ru/mystamps/web/support/spring/security/StringAuthority.java
index c049f38206..3c1f4be77b 100644
--- a/src/main/java/ru/mystamps/web/support/spring/security/StringAuthority.java
+++ b/src/main/java/ru/mystamps/web/support/spring/security/StringAuthority.java
@@ -29,6 +29,7 @@ public final class StringAuthority {
public static final String UPDATE_COLLECTION = "UPDATE_COLLECTION";
public static final String VIEW_SITE_EVENTS = "VIEW_SITE_EVENTS";
public static final String VIEW_SERIES_SALES = "VIEW_SERIES_SALES";
+ public static final String VIEW_DAILY_STATS = "VIEW_DAILY_STATS";
private StringAuthority() {
}
diff --git a/src/main/resources/ru/mystamps/i18n/Messages.properties b/src/main/resources/ru/mystamps/i18n/Messages.properties
index 19466ab226..29f3eb62a5 100644
--- a/src/main/resources/ru/mystamps/i18n/Messages.properties
+++ b/src/main/resources/ru/mystamps/i18n/Messages.properties
@@ -67,6 +67,7 @@ t_example = Example
t_catalog = Catalog
t_search = Search
t_view_suspicious_activities = view suspicious activities
+t_daily_statistics = view daily statistics
# account/register.html
t_registration_on_site = Register on site
@@ -146,6 +147,7 @@ t_price = Price
t_alternative_price = Alternative price
t_buyer = Buyer
t_add_buyer_hint = You can also add a new buyer
+>>>>>>> upstream/master
t_add_info = Add info
t_was_selling_for = was selling for
t_sold_to = sold to
diff --git a/src/main/resources/ru/mystamps/i18n/Messages_ru.properties b/src/main/resources/ru/mystamps/i18n/Messages_ru.properties
index 86a12b7378..5753d3673a 100644
--- a/src/main/resources/ru/mystamps/i18n/Messages_ru.properties
+++ b/src/main/resources/ru/mystamps/i18n/Messages_ru.properties
@@ -67,6 +67,7 @@ t_example = Пример
t_catalog = Каталог
t_search = Найти
t_view_suspicious_activities = посмотреть подозрительные события
+t_daily_statistics = посмотреть дневную статистику
# account/register.html
t_registration_on_site = Регистрация на сайте
diff --git a/src/main/resources/sql/transaction_participants_dao_queries.properties b/src/main/resources/sql/transaction_participants_dao_queries.properties
index 138fa254de..87b375bd78 100644
--- a/src/main/resources/sql/transaction_participants_dao_queries.properties
+++ b/src/main/resources/sql/transaction_participants_dao_queries.properties
@@ -8,7 +8,7 @@ VALUES \
( :name \
, :url \
)
-
+
transaction_participants.find_all = \
SELECT id \
, name \
diff --git a/src/main/webapp/WEB-INF/views/site/index.html b/src/main/webapp/WEB-INF/views/site/index.html
index 7955ca06b8..8868c57b50 100644
--- a/src/main/webapp/WEB-INF/views/site/index.html
+++ b/src/main/webapp/WEB-INF/views/site/index.html
@@ -117,6 +117,9 @@
view suspicious activities
+
+ view daily statistics
+