Commit bcf37b52 authored by shiyu's avatar shiyu

保存玩物得志登录用户

parent 8587d14c
......@@ -5,6 +5,16 @@ import com.wwdz.ch.db.domain.User;
import java.util.List;
public interface UserDao {
/**
* 保存通过玩物得志登录接口登录的用户
* 无则插入
* @param user
* @return
*/
int insertByMapper(User user);
/**
* 通过oid查询未删除的记录
*
......
......@@ -164,7 +164,7 @@ public class User implements Entity {
if (!ObjectUtils.isEmpty(wuser.getBirthday())) {
user.setBirthday(new Date(wuser.getBirthday() * 1000L));
}
user.setAddTime(new Date(wuser.getCreated() * 1000L));
user.setUserLevel(wuser.getLevel());
if (!ObjectUtils.isEmpty(wuser.getLastLoginTime())) {
user.setLastLoginTime(new Date(wuser.getLastLoginTime() * 1000L));
......
......@@ -26,6 +26,18 @@ public class UserDaoImpl implements UserDao {
UserWriteService userWriteService;
@Override
public int insertByMapper(User user) {
UserExample example = new UserExample();
UserExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(user.getId());
List<User> userList = userMapper.selectByExample(example);
if (CollectionUtils.isEmpty(userList)) {
return userMapper.insertBySelfId(user);
}
return 0;
}
@Override
public User queryByOid(String openId) {
CloudServerResponse<com.wwdz.user.api.model.user.User> cloudServerResponse = userReadService.getUserByOpenIdOrUnionId(null, openId);
......
......@@ -20,6 +20,8 @@ public interface UserMapper {
int insertSelective(User record);
int insertBySelfId(User record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
......
......@@ -214,6 +214,27 @@
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT},
#{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertBySelfId" parameterType="com.wwdz.ch.db.domain.User">
insert into user (id, username, `password`, gender,
birthday, last_login_time, last_login_ip,
user_level, nickname, mobile,
avatar, profile, background,
weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time,
update_time, deleted, share_user_id,
remark)
values (#{id,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
#{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR},
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{weixinOpenid,jdbcType=VARCHAR}, #{weixinUnionid,jdbcType=VARCHAR}, #{alipayUserId,jdbcType=VARCHAR},
#{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT},
#{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.User">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
......
......@@ -144,6 +144,9 @@ public class UserServiceImpl implements UserService {
result.put("isInvited", true);
User user = userDao.queryById(dto.getUserId());
logger.info("登录用户的信息:{}", JsonUtils.from(user));
//保存新登录的用户信息
userDao.insertByMapper(user);
String phone = user.getMobile();
//如果用户手机号为空,则调用微信接口查询出手机号进行保存
if (org.springframework.util.StringUtils.isEmpty(user.getMobile())) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment