##### Coverage Report - jp.co.y_net.amm.api.ApiMembergroup

Classes in this File | Line Coverage | Branch Coverage | Complexity

ApiMembergroup

0% | 0/26

0% | 0/6

0.0;0

ApiMembergroup$Result

0% | 0/1

N/A | N/A

0.0;0

1

     package jp.co.y_net.amm.api;

2

3

     import java.io.UnsupportedEncodingException;

4

     import java.net.URLDecoder;

5

     import java.util.ArrayList;

6

     import java.util.List;

7

8

     import jp.co.y_net.amm.dao.Grp;

9

     import jp.co.y_net.amm.dao.GrpDao;

10

     import jp.co.y_net.amm.dao.Grpusr;

11

     import jp.co.y_net.amm.dao.GrpusrDao;

12

     import jp.co.y_net.amm.dao.Usr;

13

     import jp.co.y_net.amm.dao.UsrDao;

14

15

     import org.apache.wicket.request.mapper.parameter.PageParameters;

16

     import org.apache.wicket.spring.injection.annot.SpringBean;

17

18

     public class ApiMembergroup extends ApiPage {

19

20

         @SpringBean(name="usrDao")

21

         protected UsrDao usrDao;

22

23

         @SpringBean(name="grpDao")

24

         protected GrpDao grpDao;

25

26

         @SpringBean(name="grpusrDao")

27

         protected GrpusrDao grpusrDao;

28

29

0

         public ApiMembergroup(PageParameters pageParams) {

30

31

0

             String loginid = pageParams.get("loginid").toString();

32

0

             List<Result> listResult = new ArrayList<Result>();

33

34

0

             if(loginid == null) {

35

0

                 setResponse(new Result().err("パラメータ loginid が指定されていません。"));

36

0

                 return;

37

             } else {

38

                 try {

39

0

                     loginid = URLDecoder.decode(loginid, "UTF-8"); // URLデコード

40

0

                 } catch (UnsupportedEncodingException e) {

41

0

                     throw new RuntimeException(e);

42

                 }

43

0

                 Usr usr = usrDao.getByLoginid(loginid);

44

45

0

                 if(usr == null) {

46

0

                     setResponse(new Result().err("指定された loginid からデータが取得できませんでした。"));

47

0

                     return;

48

                 } else {

49

50

0

                     Grpusr cndGrpusr = new Grpusr();

51

0

                     cndGrpusr.setUsrid(usr.getUsrid());

52

0

                     cndGrpusr.setStatus(Grpusr.STATUS_参加中);

53

0

                     List<Grpusr> list = grpusrDao.get(cndGrpusr);

54

55

                     /* 戻り値作成 */

56

0

                     for(Grpusr gu: list) {

57

0

                         Integer grpid = gu.getGrpid();

58

0

                         Grp g = grpDao.getByGrpid(gu.getGrpid());

59

0

                         Result r = new Result();

60

0

                         r.grpid = grpid;

61

0

                         r.grpname = g.getName();

62

63

0

                         listResult.add(r);

64

                     }

65

                 }

66

             }

67

68

             /* JSONのレスポンスを設定 */

69

0

             setResponse(listResult);

70

0

         }

71

         /**

72

          * 処理結果

73

          */

74

0

         public static class Result extends ApiResult{

75

             public Integer grpid;

76

             public String grpname;

77

         }

78

     }