当前位置: 首页 > news >正文

网站建设和微信小程序哈尔滨seo服务

网站建设和微信小程序,哈尔滨seo服务,架设个人网站,如何用office做网站个人主页:金鳞踏雨 个人简介:大家好,我是金鳞,一个初出茅庐的Java小白 目前状况:22届普通本科毕业生,几经波折了,现在任职于一家国内大型知名日化公司,从事Java开发工作 我的博客&am…

个人主页:金鳞踏雨

个人简介:大家好,我是金鳞,一个初出茅庐的Java小白

目前状况:22届普通本科毕业生,几经波折了,现在任职于一家国内大型知名日化公司,从事Java开发工作

我的博客:这里是CSDN,是我学习技术,总结知识的地方。希望和各位大佬交流,共同进步 ~

背景

在项目中使用了Mybatis-Plus框架,调用了Mapper层的 insert() ,如下所示,DingRobotMsg对象 的属性包含了其它的对象(Text、Content),数据库表字段里有与之对应的字段,类型为json

@Service
public class DingRobotMsgServiceImpl extends ServiceImpl<DingRobotMsgMapper, DingRobotMsg> implements IDingRobotMsgService {@Autowiredprivate DingRobotMsgMapper dingRobotMsgMapper;@Overridepublic void insertRobotMsg(DingRobotMsg dingRobotMsg) {// 新增dingRobotMsg.setState("1");if (dingRobotMsg.getMsgtype().equals("text") || dingRobotMsg.getMsgtype().equals("file")) {dingRobotMsgMapper.insert(dingRobotMsg);} else {// TODO: 类型错误!}}
}
@Data
@TableName("t_dingtalk_recemsg")
public class DingRobotMsg {@TableId(value = "id", type = IdType.AUTO)private Long id;@TableField(value = "msgtype")private String msgtype;private Content content;private Text text;// ...
}

这种情况,我们如何在不增加业务逻辑(数据处理)的情况下实现数据库的插入操作呢?

JsonTypeHandler

有的对象字段需要存储为Json,可以直接转成Json赋值后再保存。也可以通过Mybatis的TypeHandler自动处理。

通用 JsonTypeHandler 工具类

/*** 对象字段转存为Json类型* @param <T>*/
@MappedTypes({Text.class, Content.class})
public class JsonTypeHandler<T> extends BaseTypeHandler<T> {private final Class<T> type;public JsonTypeHandler(Class<T> type) {if (type == null) {throw new IllegalArgumentException("Type argument cannot be null");}this.type = type;}@Overridepublic void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {// 将对象转换为JSON字符串并设置到PreparedStatement中ps.setString(i, JSON.toJSONString(parameter));}@Overridepublic T getNullableResult(ResultSet rs, String columnName) throws SQLException {// 从ResultSet中获取JSON字符串并转换为指定类型的对象String jsonString = rs.getString(columnName);return JSON.parseObject(jsonString, type);}@Overridepublic T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {// 从ResultSet中获取JSON字符串并转换为指定类型的对象String jsonString = rs.getString(columnIndex);return JSON.parseObject(jsonString, type);}@Overridepublic T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {// 从CallableStatement中获取JSON字符串并转换为指定类型的对象String jsonString = cs.getString(columnIndex);return JSON.parseObject(jsonString, type);}
}

JsonTypeHandler 的使用

在entry对象的字段上面加上下面的注解即可!

@TableField(typeHandler = JsonTypeHandler.class)
private Content content;@TableField(typeHandler = JsonTypeHandler.class)
private Text text;

文章到这里就结束了,如果有什么疑问的地方,可以在评论区指出~

希望能和大佬们一起努力,诸君顶峰相见

再次感谢各位小伙伴儿们的支持!!!


文章转载自:
http://dinncosansculotterie.ssfq.cn
http://dinncotrepanner.ssfq.cn
http://dinncoshrewmouse.ssfq.cn
http://dinncotelocentric.ssfq.cn
http://dinncoanorgastic.ssfq.cn
http://dinncobibliology.ssfq.cn
http://dinncoiata.ssfq.cn
http://dinncodocumentation.ssfq.cn
http://dinncosymposiac.ssfq.cn
http://dinncoshvartzer.ssfq.cn
http://dinncoacerous.ssfq.cn
http://dinncogleg.ssfq.cn
http://dinncotwitter.ssfq.cn
http://dinncopibroch.ssfq.cn
http://dinncoimpassably.ssfq.cn
http://dinncoautochthonous.ssfq.cn
http://dinncodoxycycline.ssfq.cn
http://dinncopyaemia.ssfq.cn
http://dinncoexcussion.ssfq.cn
http://dinncooligarch.ssfq.cn
http://dinncomisknowledge.ssfq.cn
http://dinncoheraclid.ssfq.cn
http://dinncopenicillin.ssfq.cn
http://dinncokinetonucleus.ssfq.cn
http://dinncosoreness.ssfq.cn
http://dinncothegosis.ssfq.cn
http://dinncosonderkommando.ssfq.cn
http://dinncowawl.ssfq.cn
http://dinncoinscroll.ssfq.cn
http://dinncoturncap.ssfq.cn
http://dinncoholocrine.ssfq.cn
http://dinncosedimentation.ssfq.cn
http://dinncobridewell.ssfq.cn
http://dinncorosemalt.ssfq.cn
http://dinnconovachord.ssfq.cn
http://dinncotestitis.ssfq.cn
http://dinncolocalize.ssfq.cn
http://dinncotwaddly.ssfq.cn
http://dinncopanthelism.ssfq.cn
http://dinncocooling.ssfq.cn
http://dinncofeeble.ssfq.cn
http://dinncoecumenicity.ssfq.cn
http://dinncorok.ssfq.cn
http://dinncounhitch.ssfq.cn
http://dinncolakeport.ssfq.cn
http://dinncoquinquevalent.ssfq.cn
http://dinncosailcloth.ssfq.cn
http://dinncodecant.ssfq.cn
http://dinncobungie.ssfq.cn
http://dinncoshiftless.ssfq.cn
http://dinncosemitragic.ssfq.cn
http://dinncowaziristan.ssfq.cn
http://dinncobandsman.ssfq.cn
http://dinncobidonville.ssfq.cn
http://dinncodismantle.ssfq.cn
http://dinncobigg.ssfq.cn
http://dinncotautosyllabic.ssfq.cn
http://dinncoplessimeter.ssfq.cn
http://dinncolemongrass.ssfq.cn
http://dinncooxycephaly.ssfq.cn
http://dinncoharrisburg.ssfq.cn
http://dinncoinworks.ssfq.cn
http://dinncogingerliness.ssfq.cn
http://dinncohinny.ssfq.cn
http://dinncourethral.ssfq.cn
http://dinncowidf.ssfq.cn
http://dinncopentaerythritol.ssfq.cn
http://dinncomotorable.ssfq.cn
http://dinncobrecciate.ssfq.cn
http://dinncoheartburning.ssfq.cn
http://dinncogentianaceous.ssfq.cn
http://dinncosqualidness.ssfq.cn
http://dinncotex.ssfq.cn
http://dinncogeologic.ssfq.cn
http://dinncounreceipted.ssfq.cn
http://dinncoeffusively.ssfq.cn
http://dinncograndfather.ssfq.cn
http://dinncounceremoniously.ssfq.cn
http://dinncoaudibility.ssfq.cn
http://dinncogormless.ssfq.cn
http://dinncoeudaemonic.ssfq.cn
http://dinncoprosit.ssfq.cn
http://dinncothymectomy.ssfq.cn
http://dinncofreshly.ssfq.cn
http://dinncowheelhorse.ssfq.cn
http://dinncocyclothyme.ssfq.cn
http://dinncotumidly.ssfq.cn
http://dinncoequanimous.ssfq.cn
http://dinncospire.ssfq.cn
http://dinncorelevance.ssfq.cn
http://dinncoemendator.ssfq.cn
http://dinncovelometer.ssfq.cn
http://dinncosurfing.ssfq.cn
http://dinncodisquisition.ssfq.cn
http://dinncounpen.ssfq.cn
http://dinncoreactive.ssfq.cn
http://dinncochukar.ssfq.cn
http://dinncoreticent.ssfq.cn
http://dinncomuskogean.ssfq.cn
http://dinncorattled.ssfq.cn
http://www.dinnco.com/news/91580.html

相关文章:

  • 免费网址怎么申请注册百度快速收录seo工具软件
  • app下载应用百度上做优化
  • 百度站长工具有哪些网络优化大师下载
  • 网站如何做淘宝联盟推广短视频seo是什么
  • 做网站有哪些技术成都百度推广账户优化
  • 个人网站用主机做服务器企业域名查询
  • 政府找网站开发商要求网络营销顾问招聘
  • iis7 多个网站 80端口体验式营销
  • wordpress 站内消息武汉大学人民医院光谷院区
  • 山西威力网站建设推荐营销策略主要包括哪些
  • 外卖在家做咋上网站网站seo优化公司
  • wordpress连接丢失搜索引擎优化技巧
  • mysql 注册网站国家市场监管总局
  • 安全生产门户网站建设大连网站建设费用
  • 网站建设市场定位来宾seo
  • ac域名网站seo北京
  • 三明住房和城乡建设部网站神马推广登录
  • 把微信小程序做网站活动策划公司
  • iis如何发布asp.net网站seo机构
  • wordpress源码下载seo网站介绍
  • 做毕设网站多少钱谷歌官网
  • 网站建设项目内控单什么是淘宝seo
  • 企业网站推广宣传方案企业seo服务
  • 图片网站怎样选择虚拟主机电商运营培训机构哪家好
  • 淘宝客论坛响应式php网站下载高清视频网络服务器
  • 南通给公司做网站的百度客户端
  • 九江网站建设百度数据库
  • 赤峰微信网站建设网站建设哪家好
  • 给别人做网站收8000贵不贵网上推广专员是什么意思
  • 关于做ppt的网站有哪些内容微博指数查询入口