-
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
6 changed files
with
363 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,43 @@ | ||
/** | ||
* 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.type; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* The annotation that specify java types to map {@link TypeHandler}. | ||
* | ||
* <p><br> | ||
* <b>How to use:</b> | ||
* <pre> | ||
* @MappedTypes(String.class) | ||
* public class StringTrimmingTypeHandler implements TypeHandler<String> { | ||
* // ... | ||
* } | ||
* </pre> | ||
* @author Eduardo Macarron | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface MappedTypes { | ||
/** | ||
* Returns java types to map {@link TypeHandler}. | ||
* | ||
* @return java types | ||
*/ | ||
Class<?>[] 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,19 @@ | ||
package com.huifer.aop.advisor; | ||
|
||
/** | ||
* 描述: | ||
* | ||
* @author huifer | ||
* @date 2019-03-02 | ||
*/ | ||
public class WoMan implements BaseAopPointCut { | ||
@Override | ||
public void eat() { | ||
System.out.println("吃饭了"); | ||
} | ||
|
||
@Override | ||
public void wc() { | ||
System.out.println("上厕所"); | ||
} | ||
} |
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,74 @@ | ||
/** | ||
* 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.jdbc; | ||
|
||
import org.apache.ibatis.type.*; | ||
|
||
/** | ||
* 对于 null 不同类型的描述, {类型处理器,jdbc类型} | ||
* @author Clinton Begin | ||
* @author Adam Gent | ||
*/ | ||
public enum Null { | ||
BOOLEAN(new BooleanTypeHandler(), JdbcType.BOOLEAN), | ||
|
||
BYTE(new ByteTypeHandler(), JdbcType.TINYINT), | ||
SHORT(new ShortTypeHandler(), JdbcType.SMALLINT), | ||
INTEGER(new IntegerTypeHandler(), JdbcType.INTEGER), | ||
LONG(new LongTypeHandler(), JdbcType.BIGINT), | ||
FLOAT(new FloatTypeHandler(), JdbcType.FLOAT), | ||
DOUBLE(new DoubleTypeHandler(), JdbcType.DOUBLE), | ||
BIGDECIMAL(new BigDecimalTypeHandler(), JdbcType.DECIMAL), | ||
|
||
STRING(new StringTypeHandler(), JdbcType.VARCHAR), | ||
CLOB(new ClobTypeHandler(), JdbcType.CLOB), | ||
LONGVARCHAR(new ClobTypeHandler(), JdbcType.LONGVARCHAR), | ||
|
||
BYTEARRAY(new ByteArrayTypeHandler(), JdbcType.LONGVARBINARY), | ||
BLOB(new BlobTypeHandler(), JdbcType.BLOB), | ||
LONGVARBINARY(new BlobTypeHandler(), JdbcType.LONGVARBINARY), | ||
|
||
OBJECT(new ObjectTypeHandler(), JdbcType.OTHER), | ||
OTHER(new ObjectTypeHandler(), JdbcType.OTHER), | ||
TIMESTAMP(new DateTypeHandler(), JdbcType.TIMESTAMP), | ||
DATE(new DateOnlyTypeHandler(), JdbcType.DATE), | ||
TIME(new TimeOnlyTypeHandler(), JdbcType.TIME), | ||
SQLTIMESTAMP(new SqlTimestampTypeHandler(), JdbcType.TIMESTAMP), | ||
SQLDATE(new SqlDateTypeHandler(), JdbcType.DATE), | ||
SQLTIME(new SqlTimeTypeHandler(), JdbcType.TIME); | ||
|
||
/** | ||
* 类型处理器 | ||
*/ | ||
private TypeHandler<?> typeHandler; | ||
/** | ||
* jdbc 类型 | ||
*/ | ||
private JdbcType jdbcType; | ||
|
||
Null(TypeHandler<?> typeHandler, JdbcType jdbcType) { | ||
this.typeHandler = typeHandler; | ||
this.jdbcType = jdbcType; | ||
} | ||
|
||
public TypeHandler<?> getTypeHandler() { | ||
return typeHandler; | ||
} | ||
|
||
public JdbcType getJdbcType() { | ||
return jdbcType; | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
docs/spring/cs11073006-7f9b-11ef-af4c-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,110 @@ | ||
package com.github.huifer.full.shiro.entity; | ||
|
||
import com.baomidou.mybatisplus.annotation.TableField; | ||
import com.baomidou.mybatisplus.annotation.Version; | ||
import java.util.Date; | ||
import com.baomidou.mybatisplus.extension.activerecord.Model; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* 岗位表(ShiroPost)表实体类 | ||
* | ||
* @author huifer | ||
* @since 2021-04-18 10:08:19 | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class ShiroPost extends Model<ShiroPost> { | ||
|
||
private Integer id; | ||
//岗位名称 | ||
private String name; | ||
|
||
private Date createTime; | ||
|
||
private Integer createUser; | ||
|
||
private Integer updateUser; | ||
|
||
private Date updateTime; | ||
|
||
@Version | ||
private Integer version; | ||
|
||
@TableField | ||
private Integer deleted; | ||
|
||
|
||
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 Date getCreateTime() { | ||
return createTime; | ||
} | ||
|
||
public void setCreateTime(Date createTime) { | ||
this.createTime = createTime; | ||
} | ||
|
||
public Integer getCreateUser() { | ||
return createUser; | ||
} | ||
|
||
public void setCreateUser(Integer createUser) { | ||
this.createUser = createUser; | ||
} | ||
|
||
public Integer getUpdateUser() { | ||
return updateUser; | ||
} | ||
|
||
public void setUpdateUser(Integer updateUser) { | ||
this.updateUser = updateUser; | ||
} | ||
|
||
public Date getUpdateTime() { | ||
return updateTime; | ||
} | ||
|
||
public void setUpdateTime(Date updateTime) { | ||
this.updateTime = updateTime; | ||
} | ||
|
||
public Integer getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(Integer version) { | ||
this.version = version; | ||
} | ||
|
||
public Integer getDeleted() { | ||
return deleted; | ||
} | ||
|
||
public void setDeleted(Integer deleted) { | ||
this.deleted = deleted; | ||
} | ||
|
||
/** | ||
* 获取主键值 | ||
* | ||
* @return 主键值 | ||
*/ | ||
@Override | ||
protected Serializable pkVal() { | ||
return this.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,38 @@ | ||
/** | ||
* 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.primitive_result_type; | ||
|
||
public class Product { | ||
int productCod; | ||
Integer productType; | ||
|
||
public int getProductCod() { | ||
return productCod; | ||
} | ||
|
||
public void setProductCod(int productCod) { | ||
this.productCod = productCod; | ||
} | ||
|
||
public Integer getProductType() { | ||
return productType; | ||
} | ||
|
||
public void setProductType(Integer productType) { | ||
this.productType = productType; | ||
} | ||
|
||
} |
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,79 @@ | ||
/** | ||
* 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.ancestor_ref; | ||
|
||
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.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.Reader; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class AncestorRefTest { | ||
private static SqlSessionFactory sqlSessionFactory; | ||
|
||
@BeforeAll | ||
static void setUp() throws Exception { | ||
// create an SqlSessionFactory | ||
try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/ancestor_ref/mybatis-config.xml")) { | ||
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); | ||
} | ||
|
||
// populate in-memory database | ||
BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(), | ||
"org/apache/ibatis/submitted/ancestor_ref/CreateDB.sql"); | ||
} | ||
|
||
@Test | ||
void testCircularAssociation() { | ||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) { | ||
Mapper mapper = sqlSession.getMapper(Mapper.class); | ||
User user = mapper.getUserAssociation(1); | ||
assertEquals("User2", user.getFriend().getName()); | ||
} | ||
} | ||
|
||
@Test | ||
void testCircularCollection() { | ||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) { | ||
Mapper mapper = sqlSession.getMapper(Mapper.class); | ||
User user = mapper.getUserCollection(2); | ||
assertEquals("User2", user.getFriends().get(0).getName()); | ||
assertEquals("User3", user.getFriends().get(1).getName()); | ||
} | ||
} | ||
|
||
@Test | ||
void testAncestorRef() { | ||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) { | ||
Mapper mapper = sqlSession.getMapper(Mapper.class); | ||
Blog blog = mapper.selectBlog(1); | ||
assertEquals("Author1", blog.getAuthor().getName()); | ||
assertEquals("Author2", blog.getCoAuthor().getName()); | ||
// author and coauthor should have a ref to blog | ||
assertEquals(blog, blog.getAuthor().getBlog()); | ||
assertEquals(blog, blog.getCoAuthor().getBlog()); | ||
// reputation should point to it author? or fail but do not point to a random one | ||
assertEquals(blog.getAuthor(), blog.getAuthor().getReputation().getAuthor()); | ||
assertEquals(blog.getCoAuthor(), blog.getCoAuthor().getReputation().getAuthor()); | ||
} | ||
} | ||
} |