| 1 | |
package jp.co.y_net.amm.api; |
| 2 | |
|
| 3 | |
import java.io.UnsupportedEncodingException; |
| 4 | |
import java.net.URLDecoder; |
| 5 | |
|
| 6 | |
import jp.co.y_net.amm.service.Logincheck; |
| 7 | |
import jp.co.y_net.amm.service.Logincheck.LogincheckResult; |
| 8 | |
|
| 9 | |
import org.apache.wicket.request.mapper.parameter.PageParameters; |
| 10 | |
import org.apache.wicket.spring.injection.annot.SpringBean; |
| 11 | |
|
| 12 | |
public class ApiLogincheck extends ApiPage { |
| 13 | |
|
| 14 | |
@SpringBean(name = "logincheck") |
| 15 | |
private Logincheck logincheck; |
| 16 | |
|
| 17 | 0 | public ApiLogincheck(PageParameters pageParams) { |
| 18 | |
|
| 19 | |
|
| 20 | 0 | Result result = new Result(); |
| 21 | |
|
| 22 | 0 | String loginid = pageParams.get("loginid").toString(); |
| 23 | 0 | String cres = pageParams.get("cres").toString(); |
| 24 | 0 | String cstr = pageParams.get("cstr").toString(); |
| 25 | |
|
| 26 | 0 | if (loginid == null) { |
| 27 | 0 | setResponse(result.err("パラメータ loginid が指定されていません。")); |
| 28 | 0 | return; |
| 29 | |
} |
| 30 | 0 | if (cres == null) { |
| 31 | 0 | setResponse(result.err("パラメータ cres が指定されていません。")); |
| 32 | 0 | return; |
| 33 | |
} |
| 34 | 0 | if (cstr == null) { |
| 35 | 0 | setResponse(result.err("パラメータ cstr が指定されていません。")); |
| 36 | 0 | return; |
| 37 | |
} |
| 38 | |
|
| 39 | |
try { |
| 40 | 0 | loginid = URLDecoder.decode(loginid, "UTF-8"); |
| 41 | 0 | } catch (UnsupportedEncodingException e) { |
| 42 | 0 | throw new RuntimeException(e); |
| 43 | |
} |
| 44 | |
|
| 45 | |
|
| 46 | 0 | LogincheckResult logincheckResult = logincheck.executeFromApi(loginid, cres, cstr); |
| 47 | 0 | if(0 == logincheckResult.errorCode) { |
| 48 | |
|
| 49 | |
|
| 50 | 0 | result.value = true; |
| 51 | 0 | result.errorCode = logincheckResult.errorCode; |
| 52 | 0 | result.usrid = logincheckResult.usrid; |
| 53 | 0 | } else { |
| 54 | |
|
| 55 | |
|
| 56 | 0 | result.value = false; |
| 57 | 0 | result.errorCode = logincheckResult.errorCode; |
| 58 | 0 | result.rmsg = Logincheck.errorMemo.get(logincheckResult.errorCode); |
| 59 | |
} |
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | 0 | setResponse(result); |
| 64 | 0 | } |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | 0 | public static class Result extends ApiResult { |
| 72 | |
public boolean value; |
| 73 | |
public Integer errorCode; |
| 74 | |
public Integer usrid; |
| 75 | |
} |
| 76 | |
|
| 77 | |
} |