| package com.xzx.gc.user.service;  | 
|   | 
| import cn.hutool.core.convert.Convert;  | 
| import cn.hutool.core.date.DateUtil;  | 
| import com.xzx.gc.common.constant.Constants;  | 
| import com.xzx.gc.entity.UserHomePage;  | 
| import com.xzx.gc.user.mapper.UserHomePageMapper;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.stereotype.Service;  | 
| import org.springframework.transaction.annotation.Transactional;  | 
|   | 
| @Service  | 
| @Transactional  | 
| public class UserHomePageService {  | 
|   | 
|     @Autowired  | 
|     private UserHomePageMapper userHomePageMapper;  | 
|   | 
|   | 
|     /**  | 
|      * 根据用户查询绑定信息  | 
|      * @param userId  | 
|      * @return  | 
|      */  | 
|     public UserHomePage findByUserId(String userId){  | 
|         UserHomePage userHomePage=new UserHomePage();  | 
|         userHomePage.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));  | 
|         userHomePage.setUserId(userId);  | 
|         return userHomePageMapper.selectOne(userHomePage);  | 
|     }  | 
|   | 
|     /**  | 
|      * 绑定首页  | 
|      * @param userId  | 
|      * @param authCode  | 
|      */  | 
|     public void bind(String userId,String authCode){  | 
|         UserHomePage byUserId = findByUserId(userId);  | 
|         if(byUserId==null){  | 
|             UserHomePage userHomePage=new UserHomePage();  | 
|             userHomePage.setUserId(userId);  | 
|             userHomePage.setAuthCode(authCode);  | 
|             userHomePage.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));  | 
|             userHomePage.setCreateTime(DateUtil.date());  | 
|             userHomePage.setUpdateTime(DateUtil.date());  | 
|             userHomePageMapper.insertSelective(userHomePage);  | 
|         }else {  | 
|             byUserId.setAuthCode(authCode);  | 
|             byUserId.setUpdateTime(DateUtil.date());  | 
|             userHomePageMapper.updateByPrimaryKeySelective(byUserId);  | 
|         }  | 
|     }  | 
|   | 
| }  |