-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
606 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.huifer.kafka; | ||
|
||
import org.apache.kafka.clients.producer.KafkaProducer; | ||
import org.apache.kafka.clients.producer.ProducerConfig; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* <p>Title : KafkaProducerDemo </p> | ||
* <p>Description : </p> | ||
* | ||
* @author huifer | ||
* @date 2019-06-10 | ||
*/ | ||
public class KafkaProducerDemo extends Thread { | ||
|
||
private final KafkaProducer<Integer, String> producer; | ||
private final String topic; | ||
|
||
public KafkaProducerDemo(String topic) { | ||
Properties properties = new Properties(); | ||
// 连接到那一台kafka 可以填写多个用","分割 | ||
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, | ||
"192.168.1.108:9092,192.168.1.106:9092,192.168.1.106:9092"); | ||
// | ||
properties.put(ProducerConfig.CLIENT_ID_CONFIG, "KafkaProducerDemo-java"); | ||
properties.put(ProducerConfig.ACKS_CONFIG, "-1"); | ||
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, | ||
"org.apache.kafka.common.serialization.IntegerSerializer");// 序列化手段 | ||
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, | ||
"org.apache.kafka.common.serialization.StringSerializer");// 序列化手段 | ||
this.producer = new KafkaProducer<Integer, String>(properties); | ||
this.topic = topic; | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
KafkaProducerDemo test = new KafkaProducerDemo("test"); | ||
test.start(); | ||
|
||
} | ||
|
||
@Override | ||
public void run() { | ||
int n = 0; | ||
while (n < 50) { | ||
String msg = "msg_" + n; | ||
n++; | ||
System.out.println("发送消息" + msg); | ||
producer.send(new ProducerRecord<Integer, String>(topic, msg)); | ||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.huifer.rbac.mapper; | ||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.huifer.rbac.entity.db.MiddleRoleBtn; | ||
|
||
@Mapper | ||
public interface MiddleRoleBtnMapper extends BaseMapper<MiddleRoleBtn> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.huifer.bilibili.redis.impl; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.huifer.bilibili.redis.JedisFactory; | ||
import com.huifer.bilibili.redis.UserCacheService; | ||
import com.huifer.bilibili.redis.entity.BookEntity; | ||
import com.huifer.bilibili.redis.entity.UserEntity; | ||
import com.huifer.bilibili.redis.entity.bo.UserInfo; | ||
import redis.clients.jedis.Jedis; | ||
|
||
public class UserCacheServiceImpl implements UserCacheService { | ||
public static final String USER_CACHE_KEY = "USER_CACHE_KEY"; | ||
|
||
Jedis conn = JedisFactory.conn(); | ||
|
||
public static void main(String[] args) { | ||
UserCacheServiceImpl userCacheService = new UserCacheServiceImpl(); | ||
UserEntity userEntity = new UserEntity(); | ||
userEntity.setId(1); | ||
userEntity.setName("12"); | ||
|
||
userCacheService.add(userEntity); | ||
|
||
Map<String, String> all = userCacheService.getAll(); | ||
UserInfo user = userCacheService.getUser(1); | ||
System.out.println(); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public UserInfo getUser(int i) { | ||
UserEntity userEntity = JSON.parseObject(this.getAll().get(String.valueOf(i)), UserEntity.class); | ||
BookCacheServiceImpl bookCacheService = new BookCacheServiceImpl(); | ||
List<BookEntity> all = bookCacheService.getAll(); | ||
UserInfo userInfo = new UserInfo(); | ||
userInfo.setUserEntity(userEntity); | ||
userInfo.setBookEntity(all); | ||
|
||
return userInfo; | ||
} | ||
|
||
@Override | ||
public void add(UserEntity userEntity) { | ||
conn.hset(USER_CACHE_KEY, userEntity.getId().toString(), userEntity.toJson()); | ||
} | ||
|
||
@Override | ||
public UserEntity delete(UserEntity userEntity) { | ||
// todo | ||
return null; | ||
} | ||
|
||
@Override | ||
public UserEntity update(UserEntity userEntity) { | ||
// todo | ||
return null; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getAll() { | ||
// todo | ||
Map<String, String> stringStringMap = conn.hgetAll(USER_CACHE_KEY); | ||
return stringStringMap; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright 2009-2016 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ibatis.submitted.empty_row; | ||
|
||
public class Pet { | ||
private Integer id; | ||
private String name; | ||
|
||
private Pet grandchild; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Pet getGrandchild() { | ||
return grandchild; | ||
} | ||
|
||
public void setGrandchild(Pet grandchild) { | ||
this.grandchild = grandchild; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.huifer.security.controller; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.mock.web.MockHttpServletRequest; | ||
import org.springframework.security.test.context.support.WithUserDetails; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.MvcResult; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class RsControllerTest { | ||
|
||
|
||
private MockMvc mockMvc; | ||
|
||
@Autowired | ||
private WebApplicationContext wac; | ||
|
||
@Before // 在测试开始前初始化工作 | ||
public void setup() { | ||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); | ||
} | ||
|
||
@Test | ||
@WithUserDetails(value = "ac", userDetailsServiceBeanName = "userServiceForSecurity") | ||
public void testQ1() throws Exception { | ||
|
||
MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get("/oc/te")) | ||
.andReturn();// 返回执行请求的结果 | ||
MockHttpServletRequest request = result.getRequest(); | ||
System.out.println(); | ||
} | ||
} |
Oops, something went wrong.