首页 > 代码库 > MySQL案例分享之系统消息
MySQL案例分享之系统消息
1 2 3 4 5 6 7 | List<FavUser> userList = favUserService.getAllUser(); for (FavUser favUser : userList){ SysMessage sysMessage = new SysMessage(); ... sysMessage.setReceiveUserId(favUser.getUserId()); sysMessageService.addSysMessage(sysMessage); } |
1 2 3 4 5 6 7 | List<Integer> userIdsList = favUserService.getAllUserIds(); for (Integer userId : userIdsList ){ SysMessage sysMessage = new SysMessage(); ... sysMessage.setReceiveUserId(userId); sysMessageService.addSysMessage(sysMessage); } |
1 2 3 4 5 6 7 8 9 | < insert id= "addBatchSysMessage" parameterType= "com.favccxx.favsoft.SysMessage" > insert into sys_message (MESSAGE_TITLE, MESSAGE_CONTENT, MESSAGE_STATUS, RECEIVE_USER_ID, RECEIVE_TIME, CREATE_TIME ) values <foreach collection= "list" item= "item" index = "index" separator= "," > ( #{item.messageTitle,jdbcType= VARCHAR },#{item.messageContent,jdbcType= VARCHAR }, #{item.messageStatus,jdbcType= CHAR }, #{item.receiveUserId,jdbcType= INTEGER },#{item.receiveTime,jdbcType= TIMESTAMP }, #{item.createTime,jdbcType= TIMESTAMP } ) </foreach> </ insert > |
1 2 3 4 5 6 7 8 | List<FavUser> userList = favUserService.getAllUser(); List<SysMessage> dataList = new ArrayList<SysMessage>(); for (FavUser favUser : userList){ sysMessage.setReceiveUserId(favUser.getUserId()); dataList.add(sysMessage); } List<SysMessage> subList = dataList.subList( 0 , 1000 ); sysMessageService.addBatchSysMessage(subList); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | < insert id= "addAllSysMessage" parameterType= "com.favccxx.favsoft.SysMessage" > insert into sys_message ( MESSAGE_TITLE, MESSAGE_CONTENT, MESSAGE_STATUS, RECEIVE_USER_ID, RECEIVE_TIME, CREATE_USER_ID, CREATE_TIME ) select a.MESSAGE_TITLE as MESSAGE_TITLE, a.MESSAGE_CONTENT as MESSAGE_CONTENT, 0 as MESSAGE_STATUS, b.user_id AS RECEIVE_USER_ID, now() as RECEIVE_TIME, now() as CREATE_TIME from sys_message_send_info a, ( select user_id FROM auth_user ) b where sendInfoId=#{sendInfoId} </ insert > |
1 | int insertCount = sysMessageService.addAllSysMessage(sendInfoId); |
MySQL案例分享之系统消息
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。