Search in sources :

Example 91 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotReportController method getFamiliesByOrganization.

@GetMapping(path = "/family/organizations", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<OrganizationFamilyDTO>> getFamiliesByOrganization(@RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "family_id", required = false) Long familyId, @RequestParam(value = "date_from", required = true) String dateFrom, @RequestParam(value = "date_to", required = true) String dateTo) {
    SnapshotFilterDTO filters = new SnapshotFilterDTO(applicationId, organizationId, familyId, dateFrom, dateTo);
    List<OrganizationFamilyDTO> families = familyReportService.listFamilyByOrganizationAndCreatedDate(filters);
    return ResponseEntity.ok(families);
}
Also used : OrganizationFamilyDTO(py.org.fundacionparaguaya.pspserver.reports.dtos.OrganizationFamilyDTO) SnapshotFilterDTO(py.org.fundacionparaguaya.pspserver.reports.dtos.SnapshotFilterDTO) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 92 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotReportController method getSnapshotsIndicatorsByFamily.

@GetMapping(path = "/family/indicators", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<FamilySnapshotDTO>> getSnapshotsIndicatorsByFamily(@RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "family_id", required = true) Long familyId, @RequestParam(value = "date_from", required = true) String dateFrom, @RequestParam(value = "date_to", required = true) String dateTo) {
    SnapshotFilterDTO filters = new SnapshotFilterDTO(applicationId, organizationId, familyId, dateFrom, dateTo);
    List<FamilySnapshotDTO> snapshots = familyReportService.listSnapshotByFamily(filters);
    return ResponseEntity.ok(snapshots);
}
Also used : FamilySnapshotDTO(py.org.fundacionparaguaya.pspserver.reports.dtos.FamilySnapshotDTO) SnapshotFilterDTO(py.org.fundacionparaguaya.pspserver.reports.dtos.SnapshotFilterDTO) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 93 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotReportController method generateCSVSnapshotByOrganizationAndCreatedDate.

@GetMapping(path = "/family/indicators/csv", produces = "application/octet-stream")
public void generateCSVSnapshotByOrganizationAndCreatedDate(@RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "family_id", required = true) Long familyId, @RequestParam(value = "date_from", required = true) String dateFrom, @RequestParam(value = "date_to", required = true) String dateTo, HttpServletResponse response) throws IOException {
    SnapshotFilterDTO filters = new SnapshotFilterDTO(applicationId, organizationId, familyId, dateFrom, dateTo);
    String csv = familyReportService.generateCSVSnapshotByOrganizationAndCreatedDate(filters);
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"snapshots.csv\"");
    response.getWriter().write(csv);
    response.getWriter().close();
}
Also used : SnapshotFilterDTO(py.org.fundacionparaguaya.pspserver.reports.dtos.SnapshotFilterDTO) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 94 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project halo by ruibaby.

the class BackupController method backupDatabase.

/**
 * 备份数据库
 *
 * @return return
 */
@GetMapping(value = "/backupDb")
public String backupDatabase() {
    String fileName = "db_backup_" + HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss") + ".sql";
    try {
        File path = new File(ResourceUtils.getURL("classpath:").getPath());
        String savePath = path.getAbsolutePath() + "/backup/database";
        HaloUtil.exportDatabase("localhost", "root", "123456", savePath, fileName, "testdb");
    } catch (Exception e) {
        log.error("未知错误:" + e.getMessage());
    }
    return "redirect:/admin/backup";
}
Also used : File(java.io.File) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 95 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project halo by ruibaby.

the class BackupController method backupPosts.

/**
 * 备份文章,导出markdown文件
 *
 * @return return
 */
@GetMapping(value = "/backupPost")
public String backupPosts() {
    List<Post> posts = postService.findAllPosts();
    try {
        File path = new File(ResourceUtils.getURL("classpath:").getPath());
        String savePath = path.getAbsolutePath() + "/backup/posts/posts_backup_" + HaloUtil.getStringDate("yyyy_MM_dd_HH_mm_ss");
        for (Post post : posts) {
            HaloUtil.dbToFile(post.getPostContentMd(), savePath, post.getPostTitle() + ".md");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "redirect:/admin/backup";
}
Also used : Post(cc.ryanc.halo.model.domain.Post) File(java.io.File) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)756 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)114 ResponseEntity (org.springframework.http.ResponseEntity)80 ArrayList (java.util.ArrayList)52 List (java.util.List)49 ModelAndView (org.springframework.web.servlet.ModelAndView)48 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)45 HttpHeaders (org.springframework.http.HttpHeaders)41 Map (java.util.Map)40 HashMap (java.util.HashMap)38 lombok.val (lombok.val)38 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)36 Grid (org.hisp.dhis.common.Grid)35 IOException (java.io.IOException)34 RequestParam (org.springframework.web.bind.annotation.RequestParam)34 ApiOperation (io.swagger.annotations.ApiOperation)31 RootNode (org.hisp.dhis.node.types.RootNode)31 PathVariable (org.springframework.web.bind.annotation.PathVariable)31 HttpServletRequest (javax.servlet.http.HttpServletRequest)30 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)28