Codex Assistant
昨天 c8dffd157cd8b62023b26e62a0b92c152d959423
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const axios = require('axios');
 
async function debugEmployeeSave() {
  try {
    console.log('1. 登录获取token...');
    const loginResponse = await axios.post('http://localhost:8080/api/auth/web-login', {
      phone: '17898163888',
      password: '123456'
    });
    
    const token = loginResponse.data.token;
    console.log('登录成功');
    
    // 2. 尝试保存员工
    console.log('2. 保存员工...');
    const uniquePhone = '139' + Date.now().toString().slice(-8);
    console.log('使用手机号:', uniquePhone);
    
    const employeeData = {
      name: '调试员工' + Date.now(),
      phone: uniquePhone,
      password: '123456',
      roleId: 'EMPLOYEE',
      description: '调试员工描述'
    };
    
    console.log('员工数据:', JSON.stringify(employeeData, null, 2));
    
    const saveResponse = await axios.post('http://localhost:8080/api/graphql', {
      query: `
        mutation SaveEmployee($input: EmployeeInput!) {
          saveEmployee(input: $input) {
            id
            name
            phone
            roleId
            description
          }
        }
      `,
      variables: {
        input: employeeData
      }
    }, {
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
      }
    });
    
    console.log('保存响应状态:', saveResponse.status);
    console.log('保存响应数据:', JSON.stringify(saveResponse.data, null, 2));
    
  } catch (error) {
    console.error('错误:', error.message);
    if (error.response) {
      console.error('响应状态:', error.response.status);
      console.error('响应数据:', JSON.stringify(error.response.data, null, 2));
    }
  }
}
 
debugEmployeeSave();