notes
8, save the user module development of micro-channel user information
profile: User data access layer development, micro-channel user information stored
questions:
micro-channel distortion correction Nickname
solution:
Nickname = new new String (nickname.getBytes ( "the ISO-8859-1"), " . 8-UTF ");
. 1, the user object package
2, is inserted into the database
after obtaining openid, queries whether the user, if the user is not requesting to acquire information
method: save the user according to the user query id, user query according openid
3 , attention MyBatis parameters
values with # {}, do not risk using injection $ {}, because there sql
Start
sex is of type double. nickName garbled
Chinese transcoding, try catch it
nickName transcoding
sex first with the Double type to receive, and then converted to int type
to run the program for testing
Package user, store user information
Creating UserMapper
Copied is insert sql statement
here openId according to query, if the query to, then directly back to the user object, because from the first user to scan landing, rarely to modify a user's information. Here you can direct inquiries within openid according to the local database.
After saving the data. Get information on the primary key
to start the test application. Scan code landing
user id is null before saving the
id with a value after saving
inside look at the database, data has been saved came in
remaining a small problem in Chinese cities and provinces in question
to see the document. It should be a lang argument
behind the parameter address plus the Chinese
test again, just need to put the database that record deleted. Breakpoints here
the last string splicing million for transcoding
to just piece of data is also deleted. Because also garbled
test again
before the conversion or distortion
after converted. Become Chinese.
Head out to copy the address of the test
and then test again. Users will no longer have to save the saved again. Enter breakpoints, step by step to go down
to find the data that already exists in the database according to openId
this user User object is not null we can generate jwt returned to the front end of
the follow-up See the next lesson!