Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
select att1.Value as Health, att2.Value as Energy, att3.Value as Cheerfulness,
att4.Value as Intelligence, att5.Value as Money,
att19.Value as TKomfort,
c.Name as CityName,
CONCAT(' (', c.TemperatureAir, ' °C)') as TemperatureAir,
a.CityID, c.X as CityX, c.Y as CityY, c.AllowPort as AgentCityIsPort,
a.ArrivalTime,
IF (a.CityIDDestination <> 0, c2.Name, '') as CityNameDestination,
IF(a.ArrivalTime > SYSDATE(),
TIME_TO_SEC(TIME(SUBTIME(a.ArrivalTime, SYSDATE()))), 0) as RemainingTime,
GetGameSec() as GameSec, GetGameDate() as GameDate,
a.OrganizationID as OrgID, a.ProfessionID as ProfID, p.Name as ProfName,
IF (a.ProfessionID IN (2, 4), g.Name, IF (a.ProfessionID IN (3, 5), o.Name,
IF (a.ProfessionID IN (6, 7), m.Name, '')) ) as OrgName,
a.AccessType, a.VoteForAgentID, a2.Name as VoteForAgentName,
IF (a.ProfessionID = 5, o.Tax, 0) as GuildTax,
IFNULL(pm.Mode, 0) as PlanMode, a.IsDead,
a.FightID, a.FightStep,
IF (exists (select * from Stock where AgentID = locAgentID and CityID = a.CityID), 1, 0) as IsStock,
IFNULL(t1.Level, 1) as HouseL, IFNULL(t2.Level, 1) as WorkshopL,
IFNULL(t3.Level, 1) as FarmL, IFNULL(t4.Level, 1) as ClinicL,
IFNULL(t5.Level, 1) as TrafficL, IFNULL(t6.Level, 1) as ArmoryL,
IFNULL(t7.Level, 1) as ForestL, IFNULL(t8.Level, 1) as RiverL,
IFNULL(t9.Level, 1) as FieldL, IFNULL(t10.Level, 1) as HillL,
ca.ImageName as CoatsOfArmsName, a.AgentType, a.Name as AgentName
from Agents as a
join Cities as c on c.ID = a.CityID
left join Cities as c2 on c2.ID = a.CityIDDestination
join Professions as p on p.ID = a.ProfessionID
left join GuildOfMerchants as g on g.ID = a.OrganizationID
left join OrderOfKnights as o on o.ID = a.OrganizationID
left join Manufactory as m on m.ID = a.OrganizationID
left join Agents as a2 on a2.ID = a.VoteForAgentID
join AgentAttribute as att1 on att1.AttributeID = 1 and att1.AgentID = locAgentID
join AgentAttribute as att2 on att2.AttributeID = 2 and att2.AgentID = locAgentID
join AgentAttribute as att3 on att3.AttributeID = 3 and att3.AgentID = locAgentID
join AgentAttribute as att4 on att4.AttributeID = 4 and att4.AgentID = locAgentID
join AgentAttribute as att5 on att5.AttributeID = 5 and att5.AgentID = locAgentID
join AgentAttribute as att19 on att19.AttributeID = 19 and att19.AgentID = locAgentID
left join PlansMode as pm on pm.AgentID = a.ID
left join coats_of_arms as ca on ca.ID = a.CoatsOfArmsID
left join AgentTerritory as t1 on t1.AgentID = a.ID and t1.CityID = a.CityID and t1.TerritoryID = 8
left join AgentTerritory as t2 on t2.AgentID = a.ID and t2.CityID = a.CityID and t2.TerritoryID = 6
left join AgentTerritory as t3 on t3.AgentID = a.ID and t3.CityID = a.CityID and t3.TerritoryID = 5
left join AgentTerritory as t4 on t4.AgentID = a.ID and t4.CityID = a.CityID and t4.TerritoryID = 7
left join AgentTerritory as t5 on t5.AgentID = a.ID and t5.CityID = a.CityID and t5.TerritoryID = 25
left join AgentTerritory as t6 on t6.AgentID = a.ID and t6.CityID = a.CityID and t6.TerritoryID = 9
left join AgentTerritory as t7 on t7.AgentID = a.ID and t7.CityID = a.CityID and t7.TerritoryID = 1
left join AgentTerritory as t8 on t8.AgentID = a.ID and t8.CityID = a.CityID and t8.TerritoryID = 4
left join AgentTerritory as t9 on t9.AgentID = a.ID and t9.CityID = a.CityID and t9.TerritoryID = 3
left join AgentTerritory as t10 on t10.AgentID = a.ID and t10.CityID = a.CityID and t10.TerritoryID = 2
where a.ID = locAgentID;
CONCAT(' (', c.TemperatureAir, ' °C)') — ерунда, потому что отображение около числа надписи "°C" или «в градусах Цельсия» (и уж тем более заключение значения в скобки) — задача только представления и ничья больше. Даже бизнес-логика оперирует данными, такими, как «5» или «значение в градусах Цельсия» (последнее скорее как абстрактная идея, значение enum, отвечающего за шкалу, нежели как конкретное высказывание).Вот и получается, что для веб приложений практически вся бизнес-логика находится в базе данных
А задача сервера сводится к формированию HTML страниц для клиента.
Где наша бизнес-логика для идеалиста?