| 1 | |
package jp.co.y_net.amm.api; |
| 2 | |
|
| 3 | |
import java.io.UnsupportedEncodingException; |
| 4 | |
import java.net.URLDecoder; |
| 5 | |
import java.util.List; |
| 6 | |
|
| 7 | |
import jp.co.y_net.amm.dao.Org; |
| 8 | |
import jp.co.y_net.amm.dao.OrgDao; |
| 9 | |
import jp.co.y_net.amm.dao.Usr; |
| 10 | |
import jp.co.y_net.amm.dao.UsrDao; |
| 11 | |
|
| 12 | |
import org.apache.wicket.request.mapper.parameter.PageParameters; |
| 13 | |
import org.apache.wicket.spring.injection.annot.SpringBean; |
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
public class ApiMember extends ApiPage { |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
@SpringBean(name="usrDao") |
| 26 | |
protected UsrDao usrDao; |
| 27 | |
|
| 28 | |
@SpringBean(name="orgDao") |
| 29 | |
protected OrgDao orgDao; |
| 30 | |
|
| 31 | 0 | public ApiMember(PageParameters pageParams) { |
| 32 | |
|
| 33 | 0 | String loginid = pageParams.get("loginid").toString(); |
| 34 | |
|
| 35 | |
|
| 36 | 0 | Result result = new Result(); |
| 37 | |
|
| 38 | 0 | if(loginid == null) { |
| 39 | 0 | setResponse(result.err("パラメータ loginid が指定されていません。")); |
| 40 | 0 | return; |
| 41 | |
} |
| 42 | |
|
| 43 | |
try { |
| 44 | 0 | loginid = URLDecoder.decode(loginid, "UTF-8"); |
| 45 | 0 | } catch (UnsupportedEncodingException e) { |
| 46 | 0 | throw new RuntimeException(e); |
| 47 | |
} |
| 48 | |
|
| 49 | 0 | Usr usr = usrDao.getByLoginid(loginid); |
| 50 | |
|
| 51 | 0 | if(usr == null) { |
| 52 | 0 | setResponse(result.err("指定された loginid からデータが取得できませんでした。")); |
| 53 | 0 | return; |
| 54 | |
} else { |
| 55 | 0 | result.name = usr.getName(); |
| 56 | |
|
| 57 | 0 | result.usrid = usr.getUsrid(); |
| 58 | |
|
| 59 | 0 | result.kind = usr.getKind(); |
| 60 | 0 | |
| 61 | 0 | Org cnd = new Org(); |
| 62 | 0 | cnd.setOrgid(usr.getOrgid()); |
| 63 | 0 | List<Org> orgs = orgDao.get(cnd); |
| 64 | 0 | |
| 65 | 0 | if(orgs.size() > 0) { |
| 66 | 0 | result.orgid =orgs.get(0).getOrgid(); |
| 67 | 0 | result.orgname = orgs.get(0).getName(); |
| 68 | |
} |
| 69 | |
|
| 70 | |
} |
| 71 | 0 | |
| 72 | 0 | |
| 73 | 0 | setResponse(result); |
| 74 | 0 | } |
| 75 | |
|
| 76 | 0 | |
| 77 | |
|
| 78 | 0 | public static class Result extends ApiResult{ |
| 79 | |
public String name; |
| 80 | |
public Integer usrid; |
| 81 | |
public Integer orgid; |
| 82 | |
public String orgname; |
| 83 | |
public Integer kind; |
| 84 | |
} |
| 85 | |
} |