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

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

ApiGroupmember

0% | 0/26

0% | 0/6

0.0;0

ApiGroupmember$Result

0% | 0/1

N/A | N/A

0.0;0

1

     package jp.co.y_net.amm.api;

2

3

     import java.util.ArrayList;

4

     import java.util.List;

5

6

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

7

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

8

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

9

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

10

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

11

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

12

13

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

14

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

15

16

     public class ApiGroupmember extends ApiPage {

17

18

         @SpringBean(name="usrDao")

19

         protected UsrDao usrDao;

20

21

         @SpringBean(name="grpDao")

22

         protected GrpDao grpDao;

23

24

         @SpringBean(name="grpusrDao")

25

         protected GrpusrDao grpusrDao;

26

27

0

         public ApiGroupmember(PageParameters pageParams) {

28

29

0

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

30

0

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

31

32

33

0

             if(grpid == null) {

34

0

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

35

0

                 return;

36

37

             } else {

38

                 try {

39

0

                     Integer iGrpid = Integer.parseInt(grpid);

40

0

                     Grp grp = grpDao.getByGrpid(iGrpid);

41

42

0

                     if(grp == null) {

43

0

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

44

0

                         return;

45

46

                     } else {

47

48

0

                         Grpusr cndGrpusr = new Grpusr();

49

0

                         cndGrpusr.setGrpid(iGrpid);

50

0

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

51

0

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

52

53

                         /* 戻り値作成 */

54

0

                         for(Grpusr gu: list) {

55

0

                             Usr u = usrDao.getByUsrid(gu.getUsrid());

56

0

                             Result r = new Result();

57

                             //r.usrloginid = URLEncoder.encode(u.getLoginid(), "UTF-8"); // URLエンコード;

58

0

                             r.usrloginid = u.getLoginid();

59

0

                             r.usrname = u.getName();

60

61

0

                             listResult.add(r);

62

                         }

63

                     }

64

0

                 } catch (NumberFormatException e) {

65

0

                     setResponse(new Result().err("パラメータ grpid は不正です。"));

66

0

                     return;

67

                 }

68

             }

69

70

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

71

0

             setResponse(listResult);

72

0

         }

73

         /**

74

          * 処理結果

75

          */

76

0

         public static class Result extends ApiResult{

77

             public String usrloginid;

78

             public String usrname;

79

         }

80

     }