-
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
10 changed files
with
492 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,16 @@ | ||
package com.huifer.utils; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class UtilsApplicationTests { | ||
|
||
@Test | ||
public void contextLoads() { | ||
} | ||
|
||
} |
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,44 @@ | ||
/** | ||
* Copyright 2009-2018 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.complex_property; | ||
|
||
public class EncryptedString { | ||
private String encrypted; | ||
|
||
public EncryptedString() { | ||
setEncrypted(null); | ||
} | ||
|
||
public EncryptedString(String message) { | ||
this(); | ||
|
||
// encrypt the message. | ||
setEncrypted(message); | ||
} | ||
|
||
public String decrypt() { | ||
return encrypted; | ||
} | ||
|
||
public String getEncrypted() { | ||
return encrypted; | ||
} | ||
|
||
public void setEncrypted(String arg) { | ||
this.encrypted = arg; | ||
} | ||
|
||
} |
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,24 @@ | ||
package com.huifer.springboot.mysql.repo.two; | ||
|
||
import com.huifer.springboot.mysql.pojo.two.StudentTwo; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* <p>Title : StudentTwoRepoServiceImpl </p> | ||
* <p>Description : </p> | ||
* | ||
* @author huifer | ||
* @date 2019-06-28 | ||
*/ | ||
@Service | ||
public class StudentTwoRepoServiceImpl implements StudentTwoRepoService { | ||
|
||
@Autowired | ||
private StudentTwoRepo studentTwoRepo; | ||
|
||
@Override | ||
public StudentTwo ins() { | ||
return studentTwoRepo.save(StudentTwo.builder().address("beijing").build()); | ||
} | ||
} |
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,22 @@ | ||
/** | ||
* Copyright 2009-2015 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. | ||
* <p> | ||
* Contains all the annotation that are used in mapper interfaces | ||
*/ | ||
/** | ||
* Contains all the annotation that are used in mapper interfaces | ||
*/ | ||
package org.apache.ibatis.annotations; | ||
|
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,29 @@ | ||
package com.huifer.kafka.core.bean; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class TranversorContext<C, K, V> { | ||
|
||
private Map<C, Map<K, V>> data = new HashMap<C, Map<K, V>>(); | ||
|
||
public void addEntry(C cat, K key, V value) { | ||
Map<K, V> map = data.get(cat); | ||
if (map == null) { | ||
map = new HashMap<K, V>(); | ||
data.put(cat, map); | ||
} | ||
|
||
if (map.containsKey(key)) { | ||
throw new IllegalArgumentException(String.format( | ||
"Duplicated Annotation {} in a single handler method {}.", | ||
value.getClass(), key)); | ||
} | ||
|
||
map.put(key, value); | ||
} | ||
|
||
public Map<C, Map<K, V>> getData() { | ||
return data; | ||
} | ||
} |
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,52 @@ | ||
/** | ||
* 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.plugin; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* The annotation that specify target methods to intercept. | ||
* | ||
* <b>How to use:</b> | ||
* <pre> | ||
* @Intercepts({@Signature( | ||
* type= Executor.class, | ||
* method = "update", | ||
* args = {MappedStatement.class ,Object.class})}) | ||
* public class ExamplePlugin implements Interceptor { | ||
* @Override | ||
* public Object intercept(Invocation invocation) throws Throwable { | ||
* // implement pre-processing if needed | ||
* Object returnObject = invocation.proceed(); | ||
* // implement post-processing if needed | ||
* return returnObject; | ||
* } | ||
* } | ||
* </pre> | ||
* @author Clinton Begin | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface Intercepts { | ||
/** | ||
* Returns method signatures to intercept. | ||
* | ||
* @return method signatures | ||
*/ | ||
Signature[] 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,27 @@ | ||
/** | ||
* Copyright 2009-2017 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.lazy_deserialize; | ||
|
||
import org.apache.ibatis.annotations.Param; | ||
|
||
/** | ||
* @since 2011-04-06T11:00:30+0200 | ||
* @author Franta Mejta | ||
*/ | ||
public interface Mapper { | ||
|
||
LazyObjectFoo loadFoo(@Param("fooId") int fooId); | ||
} |
146 changes: 146 additions & 0 deletions
146
docs/spring/cs0db1c27c-6f15-11ef-9b3d-acde48001122.java
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,146 @@ | ||
package com.huifer.idgen.my.service; | ||
|
||
import com.huifer.idgen.my.service.bean.Id; | ||
import com.huifer.idgen.my.service.bean.IdMeta; | ||
import com.huifer.idgen.my.service.bean.enums.IdType; | ||
import com.huifer.idgen.my.service.conv.IdConverter; | ||
import com.huifer.idgen.my.service.conv.IdConverterImpl; | ||
import com.huifer.idgen.my.service.factory.IdMetaFactory; | ||
import com.huifer.idgen.my.service.provider.MachineIdProvider; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @author: wang | ||
* @description: Id生产策略父类 | ||
*/ | ||
@Slf4j | ||
public abstract class AbstractIdService implements GenIdService { | ||
|
||
|
||
protected long machineId = -1; | ||
protected long genMethod = 0; | ||
protected long type = 0; | ||
protected long version = 0; | ||
|
||
protected IdMeta idMeta; | ||
protected IdType idType; | ||
protected IdConverter idConverter; | ||
protected MachineIdProvider machineIdProvider; | ||
|
||
public AbstractIdService() { | ||
this.idType = IdType.TYPE_ONE; | ||
} | ||
|
||
public AbstractIdService(String type) { | ||
this.idType = IdType.parse(type); | ||
} | ||
|
||
public AbstractIdService(IdType type) { | ||
this.idType = type; | ||
} | ||
|
||
|
||
public void init() { | ||
this.machineId = machineIdProvider.getMachineId(); | ||
if (this.machineId < 0) { | ||
throw new IllegalArgumentException("machinId > 0 "); | ||
} | ||
if (this.idMeta == null) { | ||
this.idMeta = IdMetaFactory.getIdMeta(this.idType); | ||
this.type = this.idType.value(); | ||
} else { | ||
if (this.idMeta.getTimeBits() == 30) { | ||
this.type = 1L; | ||
} else if (this.idMeta.getTimeBits() == 40) { | ||
this.type = 0L; | ||
} else { | ||
throw new IdGenException("时间位在30-40之间"); | ||
} | ||
} | ||
this.idConverter = new IdConverterImpl(this.idMeta); | ||
} | ||
|
||
protected abstract void populateId(Id id); | ||
|
||
public long genId() { | ||
Id id = new Id(); | ||
id.setMachine(machineId); | ||
id.setGenMethod(genMethod); | ||
id.setType(type); | ||
id.setVersion(version); | ||
populateId(id); | ||
long res = idConverter.converter(id); | ||
log.info("id={}-->{}", id, res); | ||
return res; | ||
} | ||
|
||
public Id expId(long id) { | ||
return idConverter.converter(id); | ||
} | ||
|
||
public long makeId(long time, long seq) { | ||
return makeId(time, seq, machineId); | ||
} | ||
|
||
public long makeId(long time, long seq, long machine) { | ||
return makeId(genMethod, time, seq, machine); | ||
} | ||
|
||
public long makeId(long genMethod, long time, long seq, long machine) { | ||
return makeId(type, genMethod, time, seq, machine); | ||
} | ||
|
||
public long makeId(long type, long genMethod, long time, long seq, long machine) { | ||
return makeId(version, type, genMethod, time, seq, machine); | ||
} | ||
|
||
public long makeId(long version, long type, long genMethod, long time, long seq, long machine) { | ||
IdType _idType = IdType.parse(type); | ||
Id _id = new Id(machine, seq, time, genMethod, type, version); | ||
IdConverter _idConverter = new IdConverterImpl(_idType); | ||
return _idConverter.converter(_id); | ||
} | ||
|
||
public Date transTime(long time) { | ||
if (idType == IdType.TYPE_ONE) { | ||
return new Date(time * 1000 + 1420041600000L); | ||
} else if (idType == IdType.TYPE_TWO) { | ||
return new Date(time + 1420041600000L); | ||
} | ||
return null; | ||
} | ||
|
||
public void setMachineId(long machineId) { | ||
this.machineId = machineId; | ||
} | ||
|
||
public void setGenMethod(long genMethod) { | ||
this.genMethod = genMethod; | ||
} | ||
|
||
public void setType(long type) { | ||
this.type = type; | ||
} | ||
|
||
public void setVersion(long version) { | ||
this.version = version; | ||
} | ||
|
||
public void setIdMeta(IdMeta idMeta) { | ||
this.idMeta = idMeta; | ||
} | ||
|
||
public void setIdType(IdType idType) { | ||
this.idType = idType; | ||
} | ||
|
||
public void setIdConverter(IdConverter idConverter) { | ||
this.idConverter = idConverter; | ||
} | ||
|
||
public void setMachineIdProvider(MachineIdProvider machineIdProvider) { | ||
this.machineIdProvider = machineIdProvider; | ||
} | ||
} |
Oops, something went wrong.