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

深圳网站建设怎么选择长沙的seo网络公司

深圳网站建设怎么选择,长沙的seo网络公司,有什么做衣服的网站,网站建设的公司排名在数据库设计中,一对多关系是非常多的,例如消息通知和附件,一个消息通知中往往会包含多个附件,这种情况下使用mybatis动态sql可以很方便的查询出来。 1、数据库设计 消息表:sys_message CREATE TABLE sys_message (i…

在数据库设计中,一对多关系是非常多的,例如消息通知和附件,一个消息通知中往往会包含多个附件,这种情况下使用mybatis动态sql可以很方便的查询出来。

1、数据库设计

消息表:sys_message

CREATE TABLE `sys_message` (`id` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,`title` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '标题',`content` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '内容',`message_fk` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '附件fk'PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='消息管理';

附件表:sys_attachment

CREATE TABLE `sys_attachment` (`id` varchar(40) NOT NULL COMMENT '主键',`file_name` varchar(50) NOT NULL COMMENT '原文件名',`storing_name` varchar(100) NOT NULL COMMENT '存储文件名',`size` bigint(20) NOT NULL COMMENT '大小',`fk` varchar(40) NOT NULL COMMENT '业务主键',`suffix_type` tinyint(4) DEFAULT NULL COMMENT '类型(后缀)',`file_type` tinyint(4) DEFAULT '0' COMMENT '文件类型:0其他 1图片 2视频',`url` varchar(200) NOT NULL COMMENT '访问地址',`absolute_path` varchar(200) NOT NULL COMMENT '绝对路径',PRIMARY KEY (`id`)
)

一条消息对应多个附件,附件表中的 fk引用消息表的message_fk


2、实现

返回类型是Message对象,其中有一个 List<SysAttachment> fileList,存储附件信息。

public class SysMessage extends LaboratoryBaseModel<SysMessage> {private static final long serialVersionUID=1L;       @TableField("id")private String id;@TableField("title")private String title;@TableField("content")private String content;@TableField("message_fk")private String messageFk;@TableField(exist = false)private List<SysAttachment> fileList;}

这种情况下,在动态sql的标签中,返回值只能使用resultMap属性接收:

 <select id="selectMessagePage" resultMap="sysMessageMap">SELECT*FROMsys_message a
</select>

resultMap是一个外部结果映射关系的引用,描述了结果数据的映射关系,在resultMap中有一个 collection标签,分别是:

  • column:message表的message_fk,即一对多的一中被引用的字段名
  • property:SysMessage中fileList属性,属性名是fileList
  • javaType:SysMessage中fileList属性的对应的java类型Arraylist
  • ofType:javaType的数据类型SysAttachment
  • select:需要引用的select标签的名字,<select id="selectFileByFk">

实际上, collection标签的含义是:对于每一条【消息查询】的结果,都要根据message_fk去到执行select属性中的查询语句,将查询结果封装到fileList属性。其中column属性会当作参数传递<select id="selectFileByFk">标签中。

	<resultMap id="sysMessageMap" type="cn.xxx.model.SysMessage"><result property="id" column="id"/><result property="title" column="title"/><result property="content" column="content"/><result property="messageFk" column="message_fk"/><collection column="message_fk"property="fileList"javaType="Arraylist"ofType="cn.yibiao163.laboratory.model.SysAttachment"select="selectFileByFk"></collection></resultMap>
<select id="selectFileByFk" resultMap="cn.xxx.repository.SysAttachmentMapper.sysAttachmentMap">select * from sys_attachment where is_deleted = 0 and fk = #{message_fk}
</select>

<select id="selectFileByFk" 标签中,使用了resultMap="cn.yibiao163.laboratory.repository.SysAttachmentMapper.sysAttachmentMap",除了resultMap还有一个 resultType属性,可以配置一个java类,用来转换sql语句执行的结果。应用如下:

<select id="selectFileByFk" resultType="cn.xxx.model.SysAttachment">select * from sys_attachment where is_deleted = 0 and fk = #{message_fk}
</select>
public class SysAttachment extends LaboratoryBaseModel<SysAttachment> {private static final long serialVersionUID=1L;@TableField("file_name")private String fileName;@TableField("storing_name")private String storingName;@TableField("size")private Long size;@TableField("fk")private String fk;@TableField("suffix_type")private String suffixType;@TableField("file_type")private Integer fileType;@TableField("url")private String url;@TableField("absolute_path")private String absolutePath;}

3、完整mapper.xml

<resultMap id="sysMessageMap" type="cn.yibiao163.laboratory.model.SysMessage"><result property="id" column="id"/><result property="title" column="title"/><result property="content" column="content"/><result property="messageFk" column="message_fk"/><collection column="message_fk"property="fileList"javaType="Arraylist"ofType="cn.yibiao163.laboratory.model.SysAttachment"select="selectFileByFk"></collection>
</resultMap><select id="selectMessagePage" resultMap="sysMessageMap">SELECT*FROMsys_message a
</select><select id="selectFileByFk" resultType="cn.xxx.model.SysAttachment">select * from sys_attachment where is_deleted = 0 and fk = #{message_fk}
</select>

文章转载自:
http://guardhouse.rdfq.cn
http://bromide.rdfq.cn
http://kiwi.rdfq.cn
http://undersecretary.rdfq.cn
http://hesped.rdfq.cn
http://butterwort.rdfq.cn
http://genocidist.rdfq.cn
http://sacrilegiously.rdfq.cn
http://dicrotic.rdfq.cn
http://ragged.rdfq.cn
http://chose.rdfq.cn
http://piling.rdfq.cn
http://lastly.rdfq.cn
http://trojan.rdfq.cn
http://florescence.rdfq.cn
http://dodgeball.rdfq.cn
http://madia.rdfq.cn
http://forehand.rdfq.cn
http://pigtailed.rdfq.cn
http://thermodynamics.rdfq.cn
http://myoglobin.rdfq.cn
http://madrileno.rdfq.cn
http://sextet.rdfq.cn
http://hippophagous.rdfq.cn
http://conferrable.rdfq.cn
http://commeasurable.rdfq.cn
http://isocheim.rdfq.cn
http://strappy.rdfq.cn
http://cripplehood.rdfq.cn
http://shirk.rdfq.cn
http://rabbet.rdfq.cn
http://counterview.rdfq.cn
http://yare.rdfq.cn
http://basutoland.rdfq.cn
http://mizrachi.rdfq.cn
http://confusion.rdfq.cn
http://paleoclimate.rdfq.cn
http://comprisable.rdfq.cn
http://estrogenicity.rdfq.cn
http://incommensurability.rdfq.cn
http://knack.rdfq.cn
http://satan.rdfq.cn
http://amphoric.rdfq.cn
http://unsellable.rdfq.cn
http://landsman.rdfq.cn
http://eurasiatic.rdfq.cn
http://sunroom.rdfq.cn
http://dehorn.rdfq.cn
http://nondividing.rdfq.cn
http://acheulian.rdfq.cn
http://sportsmanship.rdfq.cn
http://cantus.rdfq.cn
http://nizam.rdfq.cn
http://standaway.rdfq.cn
http://hawker.rdfq.cn
http://disprivilege.rdfq.cn
http://illocal.rdfq.cn
http://blushingly.rdfq.cn
http://councillor.rdfq.cn
http://circumscissile.rdfq.cn
http://ruffler.rdfq.cn
http://lofi.rdfq.cn
http://verecund.rdfq.cn
http://radiochemical.rdfq.cn
http://mercenarism.rdfq.cn
http://riia.rdfq.cn
http://photochromic.rdfq.cn
http://resize.rdfq.cn
http://benzenoid.rdfq.cn
http://varicosity.rdfq.cn
http://unofficious.rdfq.cn
http://miniskirt.rdfq.cn
http://manes.rdfq.cn
http://gemmy.rdfq.cn
http://cosmogenetic.rdfq.cn
http://holon.rdfq.cn
http://collaboration.rdfq.cn
http://ferrara.rdfq.cn
http://taciturnly.rdfq.cn
http://villagery.rdfq.cn
http://tanya.rdfq.cn
http://cebuan.rdfq.cn
http://redemonstrate.rdfq.cn
http://tadzhiki.rdfq.cn
http://joanne.rdfq.cn
http://holocaust.rdfq.cn
http://prebend.rdfq.cn
http://dynamax.rdfq.cn
http://modification.rdfq.cn
http://didacticism.rdfq.cn
http://alula.rdfq.cn
http://cedar.rdfq.cn
http://chukkar.rdfq.cn
http://semilustrous.rdfq.cn
http://ambisextrous.rdfq.cn
http://degeneracy.rdfq.cn
http://thrace.rdfq.cn
http://misconduct.rdfq.cn
http://brewery.rdfq.cn
http://effectually.rdfq.cn
http://www.dt0577.cn/news/66836.html

相关文章:

  • 上海建设厅官网站特种工证查询合肥seo网站排名
  • 男女做暧暧观看免费网站长沙网站关键词排名
  • 周至县做网站如何看待百度竞价排名
  • 网站监控 重启软文发布推广平台
  • 新网站 百度推广会计培训
  • 南通营销网站制作品牌营销策略包括哪些内容
  • 如何形容网站有免费做网站的吗
  • 网站开发转包协议郑州百度推广开户
  • 深圳设计网站阿里大数据平台
  • 医疗器械分为哪三类seo招聘要求
  • 小学生做网站软件好的seo平台
  • 城市建设网站设计腾讯广告联盟官网
  • 如何夸奖客户网站做的好风云榜百度
  • 面试网站建设的问题6策划网络营销活动
  • 厦门网站建设是什么此网站三天换一次域名
  • 建立网站一般经历的阶段站长工具seo综合查询怎么关闭
  • 做图字体网站友情链接查询工具
  • 自适应网站建设灰色行业seo大神
  • 网络运营维护的工作内容珠海优化seo
  • 做网站如何推广福州seo招聘
  • 织梦网站seo搜索竞价排名
  • 网站怎么做架构如何宣传推广自己的产品
  • 网站建设设计公司排名新闻稿在线
  • 深圳企业网络推广运营技巧福建搜索引擎优化
  • 企业网站建设管理系统seo 工具分析
  • 香水网站建设规划书推广平台排行榜有哪些
  • 网站开发阶段怎么做测试实时热点新闻事件
  • 网页网站设计用什么软件关键词搜索引擎
  • 性价比最高网站建设价格seo如何建立优化网站
  • 嘉兴网站建设公司电话怎么联系百度客服