Pages

2014년 2월 18일 화요일

[SPRING] Spring mvc에서 Quartz 적용하기 - (5)

5. Service 수정하기
- DAO가 수정된 관계로 Manager 클래스들도 변경을 하도록 하겠다.
- DAO에서 데이터를 조회할때, 파라메터를 넘겨주는 부분이 추가되었고, update 하는 부분이 변경되었다.
01package kr.kangwoo.postman.service;
02 
03import java.util.Date;
04import java.util.HashMap;
05import java.util.List;
06import java.util.Map;
07 
08import kr.kangwoo.postman.core.MailStatusCode;
09import kr.kangwoo.postman.domain.Mail;
10import kr.kangwoo.postman.repository.MailDao;
11 
12import org.slf4j.Logger;
13import org.slf4j.LoggerFactory;
14 
15public class SimpleMailManager implements MailManager {
16 
17    private Logger logger = LoggerFactory.getLogger(getClass());
18     
19    private MailDao mailDao;
20 
21    public void setMailDao(MailDao mailDao) {
22        this.mailDao = mailDao;
23    }
24 
25    public List<Mail> getSendList(String daemonName) {
26        Map<String, Object> parameterMap = new HashMap<String, Object>();
27        parameterMap.put("statusCode", MailStatusCode.CREATED);
28        parameterMap.put("listSize"2);
29        parameterMap.put("orderBy""MAIL_NO");
30        List<Mail> list = mailDao.getList(parameterMap);
31        if (list != null) {
32            // 상태값 변경
33            Date updatedDate = new Date();
34            for (Mail mail : list) {
35                mail.setStatusCode(MailStatusCode.ACCEPTED);
36                mail.setSentBy(daemonName);
37                mail.setUpdatedBy(daemonName);
38                mail.setUpdatedDate(updatedDate);
39                 
40                Mail uMail = new Mail();
41                uMail.setMailNo(mail.getMailNo());
42                uMail.setStatusCode(mail.getStatusCode());
43                uMail.setSentBy(mail.getSentBy());
44                uMail.setUpdatedBy(mail.getUpdatedBy());
45                uMail.setUpdatedDate(mail.getUpdatedDate());
46                 
47                mailDao.updateSelective(uMail);
48                 
49                uMail = null;
50            }
51        }
52        return list;
53    }
54 
55    public int updateMail(Mail mail) {
56        return mailDao.updateSelective(mail);
57    }
58 
59}

댓글 없음:

댓글 쓰기