mybatis-plus动态表名
却是平流无石处,时时闻说有沉沦。——唐•杜荀鹤 配置 123456789101112131415161718@Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new DynamicTableNameInnerInterceptor(); HashMap<String, TableNameHandler> map = new HashMap<String, TableNameHandler>(2) {{ put("user", (sql, tableName) -> { St...
在线yaml和properties互转
人生有些关口非狠狠地斗一下不可,不能为了混口饭吃而蹉跎了幸福。——巴尔扎克 网址:https://www.toyaml.com/index.html 可以实现yaml和properties文件互转 虽然不支持注释一并互转,总之还是挺实用的
cursor
生命是一个说故事的人,而每一刻间的故事都是新鲜的。——朱光潜 我们有时候会在页面上定义鼠标移入某个元素时的效果 请把鼠标移动到单词上,可以看到鼠标指针发生变化: auto crosshair default e-resize help move n-resize ne-resize nw-resize pointer progress s-resize se-resize sw-resize text w-resize wait 123456789101112131415161718<p>请把鼠标移动到单词上,可以看到鼠标指针发生变化:</p><span style="cursor:auto">auto</span><br><span style="cursor:crosshair">crosshair</span><br><span style="cursor:default">default</sp...
springboot建站脚手架
往者不谏,来者可追——《 论语·微子》 地址:https://gitee.com/VampireAchao/simple-scaffold.git 目录结构: 可以用于搭建一些小型项目,注释齐全 已通过阿里代码审查工具扫描
mybatis-plus防止全表更新与删除
宁要好梨一个,不要烂梨一筐。积极肯干和忠心耿耿的人即使只有两三个,也比十个朝气沉沉的人强。——列宁 我们可以如下配置 12345678910111213@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL); // 阻止全表更新与删除 BlockAttackInnerInterceptor blockAttackInnerInterceptor = new BlockAttackInnerInterceptor(); // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false paginatio...
手动回滚、提交事务
再小的个子,也能给沙漠留下长长的身影;再小的人物,也能让历史吐出重重的叹息。——余秋雨《文化苦旅》 我们可以手动管理事务 首先需要引用两个Bean 1234@Resourceprivate TransactionDefinition transactionDefinition;@Resourceprivate IArticleEnclosureService articleEnclosureService; 然后是使用 1234567891011 PlatformTransactionManager transactionManager = Objects.requireNonNull(transactionTemplate.getTransactionManager()); TransactionStatus transactionStatus = transactionManager.getTransaction(transactionDefinition);if (逻辑执行正确) { //提交事务 transactionManager.c...
自用模板sql
真正的伟人,能在愚昧和喧嚣的物质世界中,静心倾听荒漠的声音。——深泉学院(美国) 自用sql,我建站时每张表必备如下字段: 12345678DROP TABLE IF EXISTS `common_template`;CREATE TABLE `common_template` ( `id` bigint(0) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', `gmt_deleted`datetime(0) DEFAULT NULL COMMENT '逻辑删除字段 NULL未删除 有值表示已删除,值为删除时间', `gmt_create` datetime(0) NOT NULL COMMENT '现在时表示主动式创建', `gmt_modified` datetime(0) NOT NULL COMMENT '过去分词表示被动式更新', PRIMARY KEY (`id`) USING BTREE) ENGINE = InnoDB CH...
thymeleaf调用springBean
没有经过战斗的舍弃,是虚伪的;没有经过苦难的超脱,是轻佻的。——傅雷 昨天写了一篇关于前端精度丢失的博客 今天发现还有个问题,如果我们需要使用thymeleaf在js中使用获取的数据是一个对象 并且里面的属性还是超出16位的Long类型的话,仍然会导致精度丢失 这里我们可以直接写一个JsonManager 12345678910111213141516171819/** * Json转换管理层 * * @author <achao1441470436@gmail.com> * @since 2021/7/7 11:12 */public interface JsonManager { /** * 序列化处理精度丢失 * * @param serializeObj 将要序列化的对象 * @return java.lang.Object * @author <achao1441470436@gmail.com> * @since 2021/7/7 11:16 */ Object ...
js精度丢失坑
飞蛾扑火时一定是极快乐幸福的。——三毛 我们在进行开发时可能会遇到这样一个坑,那就是js代码的精度丢失 可以看到16位以后就会出现精度丢失的问题 我们定义一个简单接口,这里用com.baomidou.mybatisplus.core.toolkit.IdWorker.getId()生成19位为Long类型的id 12345@GetMapping("json")@ResponseBodypublic Ruben json() { return new Ruben(IdWorker.getId());} 返回的Ruben对象 1234567891011121314151617181920/** * @author <achao1441470436@gmail.com> * @since 2021/7/6 0006 21:37 */public class Ruben { private Long id; public Ruben(Long id) { this.id = i...
在js中获取thymeleaf变量(二)
所谓天才,只不过是把别人喝咖啡的功夫都用在工作上了。——鲁迅 上回写过在js中获取thymeleaf变量 但比较繁琐 这次用简单的写法 1234<script> var id = [[${id}]] console.log(id)</script> 非常简单~ 不过要注意一点,如果是对象格式的数据,需要在script标签上加th:inline="javascript" 1234<script th:inline="javascript"> var id = [[${id}]] console.log(id)</script> 在页面中也可以直接使用,可以代替th:text 123<div> [[${id}]]</div> 效果如下 如果是字符串也支持的 1234<div> [[${id}]] [['id']...
