로그인 시스템 수정 및 에러 반환값 변경
This commit is contained in:
parent
e71c3c9fb9
commit
c33e0240f6
|
|
@ -10,9 +10,12 @@ namespace Server.Service
|
|||
public override string Process()
|
||||
{
|
||||
UserSQL userSql = new UserSQL();
|
||||
DeckUnitInfoSQL deckUnitInfoSQL = new DeckUnitInfoSQL();
|
||||
LeaderInfoSQL leaderInfoSQL = new LeaderInfoSQL();
|
||||
User user;
|
||||
List<DeckUnitInfo> deckUnitInfoList = null;
|
||||
List<LeaderInfo> leaderInfoList = null;
|
||||
Console.WriteLine(req.uuid);
|
||||
bool isNewUser = false;
|
||||
if (req.uuid == "")
|
||||
{
|
||||
//최초 메일 로그인
|
||||
|
|
@ -23,6 +26,8 @@ namespace Server.Service
|
|||
if (user != null)
|
||||
{
|
||||
user.nickname = "";
|
||||
deckUnitInfoList = deckUnitInfoSQL.Select();
|
||||
leaderInfoList = leaderInfoSQL.Select();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -32,39 +37,87 @@ namespace Server.Service
|
|||
|
||||
//현재 닉네임을 설정하는 곳이 없기에 임시 작업
|
||||
user.nickname = "";
|
||||
|
||||
deckUnitInfoList = deckUnitInfoSQL.Select();
|
||||
leaderInfoList = leaderInfoSQL.Select();
|
||||
}
|
||||
if(user == null)
|
||||
{
|
||||
#region 신규유저 생성
|
||||
if (req.mail == "")
|
||||
{
|
||||
throw new RuntimeException("not User", Error.nodata);
|
||||
throw new RuntimeException("Not User", Error.nodata);
|
||||
}
|
||||
isNewUser = true;
|
||||
#region 신규유저 생성
|
||||
user = new User();
|
||||
user.mail = req.mail;
|
||||
user.uuid = Guid.NewGuid().ToString();
|
||||
user.nickname = "";
|
||||
userSql.Insert(user); //저장하고 유닛의 id를 얻어오기 위함.
|
||||
#endregion
|
||||
#region 신규 덱, 초기 유닛 지급
|
||||
#region 초기 유닛 지급
|
||||
deckUnitInfoList = new List<DeckUnitInfo>();
|
||||
DeckUnitInfo deckUnitInfo;
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100001;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100002;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100003;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100004;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100005;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100006;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100007;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100008;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = 100009;
|
||||
deckUnitInfoList.Add(deckUnitInfo);
|
||||
deckUnitInfoSQL.Insert(deckUnitInfoList);
|
||||
#endregion
|
||||
#region 신규 덱 추가
|
||||
leaderInfoList = new List<LeaderInfo>();
|
||||
LeaderInfo leaderInfo;
|
||||
leaderInfo = new LeaderInfo();
|
||||
leaderInfo.user_id= user.id;
|
||||
leaderInfo.leader_id = 1;
|
||||
leaderInfo.deck_unit0_id = deckUnitInfoList[0].id;
|
||||
leaderInfo.deck_unit1_id = deckUnitInfoList[1].id;
|
||||
leaderInfo.deck_unit2_id = deckUnitInfoList[2].id;
|
||||
leaderInfo.deck_unit3_id = deckUnitInfoList[3].id;
|
||||
leaderInfo.deck_unit4_id = deckUnitInfoList[4].id;
|
||||
leaderInfo.deck_unit5_id = deckUnitInfoList[5].id;
|
||||
leaderInfo.deck_unit6_id = deckUnitInfoList[6].id;
|
||||
leaderInfo.deck_unit7_id = deckUnitInfoList[7].id;
|
||||
leaderInfo.deck_unit8_id = deckUnitInfoList[8].id;
|
||||
leaderInfoList.Add(leaderInfo);
|
||||
leaderInfoSQL.Insert(leaderInfoList);
|
||||
#endregion
|
||||
}
|
||||
|
||||
SaveQurry(userSql, user, isNewUser);
|
||||
|
||||
return makeResp(user);
|
||||
}
|
||||
|
||||
public void SaveQurry(UserSQL userSql, User user, bool isNewUser)
|
||||
{
|
||||
if (isNewUser)
|
||||
{
|
||||
userSql.Insert(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
userSql.Update(user);
|
||||
}
|
||||
return makeResp(user, deckUnitInfoList, leaderInfoList);
|
||||
}
|
||||
|
||||
public override Protocol ProtocolValue() => Protocol.Login;
|
||||
|
|
@ -75,11 +128,13 @@ namespace Server.Service
|
|||
return req;
|
||||
}
|
||||
|
||||
private string makeResp(User user)
|
||||
private string makeResp(User user, List<DeckUnitInfo> deck_unit, List<LeaderInfo> leader)
|
||||
{
|
||||
LoginResp resp = new LoginResp();
|
||||
resp.nickname = user.nickname;
|
||||
resp.uuid = user.uuid;
|
||||
resp.deck_unit = deck_unit;
|
||||
resp.leader = leader;
|
||||
resp.status = 200;
|
||||
return resp.ToJson();
|
||||
}
|
||||
|
|
@ -103,5 +158,7 @@ namespace Server.Service
|
|||
{
|
||||
public string uuid;
|
||||
public string nickname;
|
||||
public List<DeckUnitInfo> deck_unit;
|
||||
public List<LeaderInfo> leader;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
public ErrorResp(RuntimeException ex)
|
||||
{
|
||||
this.status = (int)ex.status;
|
||||
this.message = ex.Message;
|
||||
this.message = "error : " + ex.Message;
|
||||
}
|
||||
public ErrorResp()
|
||||
{
|
||||
this.status = -1;
|
||||
this.message = "Unknown Error";
|
||||
this.message = "error : Unknown Error";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue