File: //home2/yenicep/garantili-kasko/core/util/query/kaskolu-cihazlar-queries.js
const kaskoluCihazlarQueries = {
GET_AUTH: getAuth,
GET_ALL: 'select * from kaskolu_cihazlar',
GET_BY_ID: getById,
GET_BY_POLICE_NO: getByPoliceNo,
GET_BY_CITY: getByCity,
GET_CITY_CODES: 'select id, il as city from il',
GET_BY_PRICE: getByPrice,
GET_BRANDS: 'select id, marka as brand from markalar where goster=1',
GET_BRANDS_BY_ID: getBrandById,
GET_MODEL_BY_ID: getModelsById,
GET_STORAGE: 'select id, hafiza as storage, tip as type from hafiza',
GET_BY_TAKIPNO: getByTakipNo,
GET_BY_DATE: getByDate,
GET_BETWEEN_DATE: getBetweenDate,
GET_BETWEEN_ACTIVATE_DATE: getBetweenActivateDate,
GET_BETWEEN_BIRTH_DATE: getBetweenBirthDate,
GET_BY_GENDER: getByGender,
GET_BY_CUSTOMER_TYPE: getByCustomerType,
GET_BY_NATIONALITY: getByNationality,
}
function getAuth(username) {
return 'select * from kasko_users where username="' + username + '"';
}
function getById(id) {
return 'select * from kaskolu_cihazlar where id=' + id;
}
function getByPoliceNo(policeNo) {
return 'select * from kaskolu_cihazlar where hdi_policeNo=' + policeNo;
}
function getByCity(city) {
return 'select * from kaskolu_cihazlar where IlKod=' + city;
}
function getByPrice(price) {
return 'select * from kaskolu_cihazlar where tutar=' + price;
}
function getByTakipNo(value) {
return 'select * from kaskolu_cihazlar where kasko_takipno like "%' + value + '%"';
}
function getByDate(basTar) {
return "select * from kaskolu_cihazlar where basTar like '%" + basTar + "%'";
}
function getBetweenDate(startDate, endDate) {
return "SELECT * FROM kaskolu_cihazlar WHERE baslangic_tarih >= '" + startDate + "' and baslangic_tarih <= '" + endDate + " 23:59:59'";
}
function getBetweenActivateDate(startDate, endDate) {
return "SELECT * FROM kaskolu_cihazlar WHERE policeno_aktiflik_tarih >= '" + startDate + "' and policeno_aktiflik_tarih <= '" + endDate + " 23:59:59'";
}
function getBetweenBirthDate(startDate, endDate) {
return "SELECT * FROM kaskolu_cihazlar WHERE MSDogYL >= '" + startDate + "' and MSDogYL <= '" + endDate + " 23:59:59'";
}
function getBrandById(id) {
return "select id, marka as brand from markalar where id=" + id;
}
function getModelsById(id) {
return "select id, marka as brand, model_id as modelId, model from markamodel_eslesme where model_id=" + id;
}
function getByGender(gender) {
return "select * from kaskolu_cihazlar where MSCnsTp='" + gender + "'";
}
function getByCustomerType(type) {
return "select * from kaskolu_cihazlar where OzelTuzel='" + type + "'";
}
function getByNationality(nationality) {
return "select * from kaskolu_cihazlar where Uyruk='" + nationality + "'";
}
module.exports = kaskoluCihazlarQueries;