mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
64e471e2b0
Adds 92 new tests (178 → 270 total) with zero source-file modifications: - packages/finder: 13 new test files covering all reporters, subscribers, validators, hooks, utils, options, cloneFound, getFilesToDetect, and InFilesDetector; shared buildClone() factory helper - apps/jscpd: 3 new test files (options-unit, print, store) plus extensions to formats, modes, and options integration tests - vitest.config.ts added to both packages to restrict coverage.include to src/** only, eliminating bin/ and prism.js noise - Fixes 3 tokenizer bugs (trailing space in format lookup, tokenization edge cases) uncovered by the new format fixture suite - Adds fixture files for 40+ language formats to support formats.test.ts
36 lines
1.4 KiB
Plaintext
36 lines
1.4 KiB
Plaintext
component accessName="UserService" {
|
|
property name="dataSource" type="string" default="userdb";
|
|
property name="cacheTTL" type="numeric" default="300";
|
|
|
|
public query function getUsersByRole(required string role) {
|
|
var sql = "SELECT id, username, email, created_at
|
|
FROM users
|
|
WHERE role = :role
|
|
AND active = 1
|
|
ORDER BY username ASC";
|
|
|
|
var params = {
|
|
role: { value: arguments.role, cfsqltype: "varchar" }
|
|
};
|
|
return queryExecute(sql, params, { datasource: dataSource });
|
|
}
|
|
|
|
public boolean function updateUserEmail(required numeric userId, required string email) {
|
|
var sql = "UPDATE users SET email = :email, updated_at = NOW() WHERE id = :id";
|
|
var params = {
|
|
email: { value: arguments.email, cfsqltype: "varchar" },
|
|
id: { value: arguments.userId, cfsqltype: "integer" }
|
|
};
|
|
queryExecute(sql, params, { datasource: dataSource });
|
|
return true;
|
|
}
|
|
|
|
public query function searchUsers(required string searchTerm) {
|
|
var sql = "SELECT id, username, email FROM users
|
|
WHERE username LIKE :term OR email LIKE :term
|
|
AND active = 1 ORDER BY username";
|
|
var params = { term: { value: "%#arguments.searchTerm#%", cfsqltype: "varchar" } };
|
|
return queryExecute(sql, params, { datasource: dataSource });
|
|
}
|
|
}
|