添加了微信小程序绑定网站账号的接口
This commit is contained in:
		| @@ -11,6 +11,7 @@ import com.xkrs.model.vo.SysUserVo; | ||||
| import com.xkrs.service.SysUserService; | ||||
| import org.springframework.context.i18n.LocaleContextHolder; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.validation.BindingResult; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| @@ -251,4 +252,19 @@ public class SysUserController { | ||||
|         return sysUserService.findUserByOpenId(openId); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 绑定网站账号 | ||||
|      * @param map | ||||
|      * @return | ||||
|      */ | ||||
|     @Transactional(rollbackFor=Exception.class) | ||||
|     @PostMapping("/updateOpenIdByPhone") | ||||
|     public String updateOpenIdByPhone(@RequestBody Map map){ | ||||
|         Locale locale = LocaleContextHolder.getLocale(); | ||||
|         String openId = (String) map.get("openId"); | ||||
|         String phone = (String) map.get("phone"); | ||||
|         sysUserDao.updateOpenIdByPhone(phone,openId); | ||||
|         return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"绑定成功!",locale); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -134,4 +134,13 @@ public interface SysUserDao extends JpaRepository<SysUserEntity,Integer> { | ||||
|      * @return | ||||
|      */ | ||||
|     SysUserEntity findByOpenId(String openId); | ||||
|  | ||||
|     /** | ||||
|      * 根据用户名(手机号),修改openid | ||||
|      * @param userName | ||||
|      * @param openId | ||||
|      */ | ||||
|     @Query(value = "update sys_user set open_id = ?2 where user_name = ?1",nativeQuery = true) | ||||
|     @Modifying(clearAutomatically=true) | ||||
|     void updateOpenIdByPhone(String userName,String openId); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user