-
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
4 changed files
with
150 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,17 @@ | ||
package com.github.huifer.full.shiro.service; | ||
|
||
import com.github.huifer.full.shiro.entity.ShiroCompany; | ||
import com.github.huifer.full.shiro.entity.ShiroPost; | ||
import com.github.huifer.full.shiro.model.req.company.CompanyCreateParam; | ||
import com.github.huifer.full.shiro.model.req.post.PostCreateParam; | ||
|
||
public interface PostService { | ||
|
||
boolean create(PostCreateParam param); | ||
|
||
boolean update(PostCreateParam param, int id); | ||
|
||
boolean delete(int id); | ||
|
||
ShiroPost byId(int id); | ||
} |
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,59 @@ | ||
package com.huifer.kafka.partition; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerConfig; | ||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.consumer.ConsumerRecords; | ||
import org.apache.kafka.clients.consumer.KafkaConsumer; | ||
|
||
import java.util.Collections; | ||
import java.util.Properties; | ||
|
||
/** | ||
* <p>Title : KafkaConsumerDemo </p> | ||
* <p>Description : </p> | ||
* | ||
* @author huifer | ||
* @date 2019-06-10 | ||
*/ | ||
public class KafkaConsumerPartition02 extends Thread { | ||
|
||
private final KafkaConsumer kafkaConsumer; | ||
private final String topic; | ||
|
||
public KafkaConsumerPartition02(String topic) { | ||
Properties properties = new Properties(); | ||
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, | ||
"192.168.1.108:9092,192.168.1.106:9092,192.168.1.106:9092"); | ||
properties.put(ConsumerConfig.GROUP_ID_CONFIG, "KafkaConsumerDemo-java"); | ||
properties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true"); | ||
properties.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "1000"); | ||
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, | ||
"org.apache.kafka.common.serialization.IntegerDeserializer"); | ||
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, | ||
"org.apache.kafka.common.serialization.StringDeserializer"); | ||
|
||
properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); | ||
|
||
kafkaConsumer = new KafkaConsumer<>(properties); | ||
kafkaConsumer.subscribe(Collections.singletonList(topic)); | ||
|
||
this.topic = topic; | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
new KafkaConsumerPartition02("partitions-test").start(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
while (true) { | ||
ConsumerRecords<Integer, String> poll = kafkaConsumer.poll(1000); | ||
for (ConsumerRecord<Integer, String> record : poll) { | ||
System.out.println("partition:" + record.partition() + "接收消息:" + record.value()); | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
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,57 @@ | ||
/** | ||
* Copyright 2009-2019 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.resolution.cacherefs; | ||
|
||
import org.apache.ibatis.BaseDataTest; | ||
import org.apache.ibatis.io.Resources; | ||
import org.apache.ibatis.session.SqlSession; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.apache.ibatis.session.SqlSessionFactoryBuilder; | ||
import org.apache.ibatis.submitted.resolution.User; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.Reader; | ||
|
||
class CacheRefsTest { | ||
|
||
private static SqlSessionFactory sqlSessionFactory; | ||
|
||
@BeforeAll | ||
static void setUp() throws Exception { | ||
// create an SqlSessionFactory | ||
try (Reader reader = Resources | ||
.getResourceAsReader("org/apache/ibatis/submitted/resolution/cacherefs/mybatis-config.xml")) { | ||
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); | ||
} | ||
|
||
// populate in-memory database | ||
BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(), | ||
"org/apache/ibatis/submitted/resolution/CreateDB.sql"); | ||
} | ||
|
||
@Test | ||
void shouldGetAUser() { | ||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) { | ||
MapperB mapper = sqlSession.getMapper(MapperB.class); | ||
User user = mapper.getUser(1); | ||
Assertions.assertEquals(Integer.valueOf(1), user.getId()); | ||
Assertions.assertEquals("User1", user.getName()); | ||
} | ||
} | ||
|
||
} |
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,17 @@ | ||
package com.huifer.struts.action; | ||
|
||
import com.opensymphony.xwork2.ActionSupport; | ||
|
||
/** | ||
* 描述: | ||
* | ||
* @author huifer | ||
* @date 2019-02-21 | ||
*/ | ||
public class ActionThree extends ActionSupport { | ||
@Override | ||
public String execute() throws Exception { | ||
System.out.println("action three"); | ||
return null; | ||
} | ||
} |