Skip to content

Commit a7b4f2b

Browse files
committed
update
1 parent b67f945 commit a7b4f2b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ WORKDIR /service
66
COPY package*.json ./
77
COPY . .
88

9-
# DEVELOPMENT
9+
# DEVELOPMENT - Enable Volume in docker-compose.yml
1010
#ENV NODE_ENV development
11-
## Enable Volume in docker-compose.yml
1211
#RUN npm install
1312
#CMD ["npx", "nodemon", "npm", "start"]
1413

src/model/ServiceProxy.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class ServiceProxy extends Proxy {
4646
try {
4747
await this.mySQL.beginTransaction(connection);
4848
const result = await this.user.add(connection, user);
49-
if (user.roles)
49+
if (user.roles && user.roles.length > 0)
5050
await this.role.updateRolesById(connection, result.body.id, user.roles);
5151
await this.mySQL.commit(connection);
5252
return result;
@@ -65,7 +65,8 @@ export class ServiceProxy extends Proxy {
6565
const result = await this.user.update(connection, user);
6666
if (user.roles) {
6767
await this.role.deleteRolesById(connection, user.id);
68-
await this.role.updateRolesById(connection, user.id, user.roles)
68+
if (user.roles.length > 0)
69+
await this.role.updateRolesById(connection, user.id, user.roles)
6970
}
7071
await this.mySQL.commit(connection);
7172
result.body = user;

src/model/data/Role.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Role {
4646
let sql = "INSERT INTO user_role(user_id, role_id) VALUES ?;"
4747
let values = roles.map(({id, name}) => [userId, id]);
4848
connection.query(sql, [values], (error, result) => {
49-
error ? reject({status: 500, body: error}) : resolve({status: 200, body: roles});
49+
error ? reject({status: 500, body: error.sqlMessage}) : resolve({status: 200, body: roles});
5050
});
5151
});
5252
}

0 commit comments

Comments
 (0)