-- Create Test Mobile User for Android App
-- Run this in your ROOT database (not project database)

-- First, check if user already exists
SELECT login_id, member_id, name, treelogy_id, status 
FROM login 
WHERE member_id = 'mobileuser' AND treelogy_id = 1;

-- If user doesn't exist, create one
-- Password: test123 (bcrypt hashed)
INSERT INTO login (
  treelogy_id,
  client_id,
  member_id,
  password,
  name,
  mobile_number,
  fbcode,
  role_id,
  status,
  security_no,
  com_id,
  created_at,
  updated_at
)
VALUES (
  1,  -- treelogy_id: Change this to your project ID
  1,  -- client_id: Change this to your client ID
  'mobileuser',  -- member_id: This is the "email" for mobile login
  '$2a$10$rqZ9vY5J5vY5J5vY5J5vY.K9vY5J5vY5J5vY5J5vY5J5vY5J5vY5K',  -- Password: test123
  'Mobile Test User',  -- name
  '9876543210',  -- mobile_number
  'MTU001',  -- fbcode
  3,  -- role_id: 3 is typically PROJECT_USER (check your user_master table)
  'Y',  -- status: Y = active
  '0',  -- security_no
  10,  -- com_id
  NOW(),
  NOW()
)
RETURNING login_id, member_id, name;

-- Verify the user was created
SELECT 
  l.login_id,
  l.member_id,
  l.name,
  l.mobile_number,
  l.treelogy_id,
  t.treelogy_name,
  l.status
FROM login l
LEFT JOIN treelogy t ON l.treelogy_id = t.treelogy_id
WHERE l.member_id = 'mobileuser';

-- Test login credentials:
-- URL: POST http://172.17.46.11:63318/api/mobile/project/1/login
-- Body (x-www-form-urlencoded):
--   email: mobileuser
--   password: test123

