njy622 / Onnanana_second-Projct

- 휴먼교육센터 2차 프로젝트 (미세먼지 빅데이터 분석)
1 stars 2 forks source link

2023.12.08. 탄소계산시 글삭제후 실시간 카운트 에러해결 #98

Open njy622 opened 7 months ago

njy622 commented 7 months ago

calender.jsp

Image

calender.js

Image

ScheduleController

@GetMapping("/delete/{sid}") public String delete(@PathVariable int sid) { schedService.delete(sid); return "redirect:/schedule/calendar"; }

@PostMapping("/delete/{sid}")
@ResponseBody
public String delete(@PathVariable int sid, HttpSession session) {

    schedService.delete(sid);

///////////////// 캘린더 생성 되었을때 , DB베이스와 웹서버 연동 실시간으로 되도록 설정/////////////////////////// String sessUid = (String) session.getAttribute("sessUid");

    // 전체 유저의 참여인원을 카운트 값 불러오는것
    int count = schedService.getCount();
    // 전체 유저의 참여인원을 카운트 세션값을 다시 불러오는것
    session.setAttribute("sessAllId", count);
    // 탄소배출감소량 전체 유저 카운트 값 불러오는것
    Double countCarbon = schedService.getCarbonCount();
    // 탄소배출감소량 전체 유저 카운트 세션값을 다시 불러오는것
    session.setAttribute("sessAllCarbonId", countCarbon);

    // 유저의 참여 일수를 카운트 값 불러오는것
    int countUser = schedService.getUserCount(sessUid);
    // 유저의 참여 일수를 카운트 세션값을 다시 불러오는것
    session.setAttribute("sessId", countUser);

    // 탄소배출감소량 한 유저 카운트 값 불러오는것
    Double countUserCarbon =  schedService.getCarbonUserCount(sessUid);
    // 탄소배출감소량 한 유저 카운트 세션값을 다시 불러오는것
    session.setAttribute("sessCarbonId", countUserCarbon);

    // count 외에도 여러 변수를 포함한 JSON 객체를 생성합니다.
    Map<String, Object> response = new HashMap<>();
    response.put("count", count);
    response.put("countCarbon", countCarbon);
    response.put("countUser", countUser);
    response.put("countUserCarbon", countUserCarbon);

    // Map을 JSON 문자열로 변환합니다.
    String jsonResponse = new Gson().toJson(response);

    return jsonResponse;

    //return "redirect:/schedule/calendar";
}