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

专业做网站推广的公司如何分析网站关键词

专业做网站推广的公司,如何分析网站关键词,低代码平台,仿站源码之前项目组有个需求#xff0c;定时同步机构的信息。已知三方接口由于返回数据量很大#xff0c;所以最后需要三方提供一个可根据机构编号获取当前机构及子机构信息的接口。而不是一次性返回全部机构信息#xff01; 由于这次需求也用到了递归#xff0c;所以记录下#…之前项目组有个需求定时同步机构的信息。已知三方接口由于返回数据量很大所以最后需要三方提供一个可根据机构编号获取当前机构及子机构信息的接口。而不是一次性返回全部机构信息 由于这次需求也用到了递归所以记录下 Java程序递归查询 pom.xml文件 dependencygroupIdcom.alibaba/groupIdartifactIdfastjson/artifactIdversion1.2.73/version /dependency 数据库  organization机构表 表结构sql DROP TABLE IF EXISTS organization; CREATE TABLE organization (id int(20) NOT NULL AUTO_INCREMENT COMMENT 自增id,org_code varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 机构编号,org_name varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 机构名称,parent_id int(20) NULL DEFAULT NULL COMMENT 父级机构id,parent_code varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 父级机构编码,parent_all_code varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 所有父级code,PRIMARY KEY (id) USING BTREE ) ENGINE InnoDB AUTO_INCREMENT 50 CHARACTER SET utf8 COLLATE utf8_unicode_ci ROW_FORMAT Dynamic;organization_record 机构记录表 将机构表数据及原始三方接口数据以子节点形式存储到记录表中 CREATE TABLE organization_record (id int(4) NOT NULL AUTO_INCREMENT COMMENT 主键,organization_info mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 机构数据的json串存储,organization_source_info mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 原始机构数据的json串存储,PRIMARY KEY (id) USING BTREE ) ENGINE InnoDB AUTO_INCREMENT 18 CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT Dynamic; 机构实体类 Organization package com.example.demo.entity;import lombok.Data; import java.io.Serializable; import java.util.List;Data public class Organization implements Serializable {private int id;//机构编号private String orgCode;//机构名称private String orgName;//父级idprivate int parentId;//父级机构编号private String parentCode;//所有父级codeprivate String parentAllCode;private ListOrganization children; }mapper 机构mapper package com.example.demo.mapper;import com.example.demo.entity.Organization; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List;Mapper public interface OrganizationMapper {//添加组织机构int insertOrganization(Organization organization);//根据组织编号查询信息Organization queryOrganizationByCode(String code);//修改组织机构信息int updateOrganization(Organization organization);//根据code查询对应的组织机构ListOrganization queryOrganizationByParentId(Param(parentId) String parentId); }机构记录mapper package com.example.demo.mapper;import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param;Mapper public interface OrganizationRecordMapper {//添加void insertOrganizationRecord(Param(organizationInfo) String organizationInfo,Param(organizationSourceInfo) String organizationSourceInfo);}SQL 机构sql ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.example.demo.mapper.OrganizationMapperresultMap idorganizationMap typecom.example.demo.entity.Organizationresult propertyid columnid/result propertyorgCode columnorg_code/result propertyorgName columnorg_name/result propertyparentId columnparent_id/result propertyparentCode columnparent_code/result propertyparentAllCode columnparent_all_code//resultMap!--新增--insert idinsertOrganization parameterTypecom.example.demo.entity.OrganizationINSERT INTO organization (org_code,org_name,parent_id,parent_code,parent_all_code)VALUE (#{orgCode},#{orgName},#{parentId},#{parentCode},#{parentAllCode})/insert!--根据code查询对应的组织机构--select idqueryOrganizationByParentId resultMaporganizationMapselect * from organizationwhereif testparentId!-1and parent_id#{parentId}/if/where/select!--根据组织编号查询机构信息--select idqueryOrganizationByCode parameterTypestring resultMaporganizationMapselect * from organization where org_code#{code} limit 0,1/select!--修改--update idupdateOrganization parameterTypecom.example.demo.entity.OrganizationUPDATE organizationSET org_name #{orgName},parent_id #{parentId},parent_code #{parentCode},parent_all_code #{parentAllCode}WHERE org_code #{orgCode}/update /mapper 机构记录sql ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.example.demo.mapper.OrganizationRecordMapper!--添加--insert idinsertOrganizationRecord insert into organization_record(organization_info,organization_source_info)VALUES(#{organizationInfo},#{organizationSourceInfo})/insert /mapper 业务逻辑service package com.example.demo.service;import com.alibaba.fastjson.JSONArray; import com.example.demo.entity.Organization; import com.example.demo.mapper.OrganizationMapper; import com.example.demo.mapper.OrganizationRecordMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors;Slf4j Service public class TestDiGuiService {Autowiredprivate OrganizationMapper organizationMapper;Autowiredprivate OrganizationRecordMapper organizationRecordMapper;public HashMapString, Object syncOrganization() {HashMapString, Object resultMap new HashMap();ListHashMapString, Object sourceList new ArrayList(); //原始机构信息集合//1.模拟请求三方接口获取信息 TODOMap emp new HashMap();ListHashMapString, Object mapList new ArrayList();HashMapString, Object hashMap new HashMap();hashMap.put(ORG_CODE, 0001);hashMap.put(ORG_NAME, 中国工商银行);mapList.add(hashMap);hashMap new HashMap();hashMap.put(ORG_CODE, 0002);hashMap.put(ORG_NAME, 北京银行);mapList.add(hashMap);emp.put(result, mapList);emp.put(status, 200);String code (String) emp.get(status);if (!200.equals(code)) {resultMap.put(code, 500);return resultMap;}ListHashMapString, Object list (ListHashMapString, Object) emp.get(result);sourceList.addAll(list);//2.对数据进行逻辑处理if (list.size() ! 0) {for (HashMapString, Object object : list) {//2.1 对信息封装为组织机构代码对象Organization organization conversionOrg(0, object);//2.2 新增/修改机构信息disposeOrg(organization);//2.3 递归遍历recursive(organization, sourceList);}}resultMap.put(code, 200);//3.查询出全部机构信息整理为json串queryOrganization(sourceList);return resultMap;}//封装成对象public Organization conversionOrg(String orgCode, HashMapString, Object map) {Organization o new Organization();String code (String) map.get(ORG_CODE);String name (String) map.get(ORG_NAME);log.info(组织机构名称{},机构编号{}, name, code);o.setOrgCode(code);o.setOrgName(name);Organization organization organizationMapper.queryOrganizationByCode(orgCode);if (organization null) {o.setParentAllCode(0,);} else {String parentAllCode StringUtils.isEmpty(organization.getParentAllCode()) ? 0, : organization.getParentAllCode() orgCode ,;o.setParentAllCode(parentAllCode);o.setParentId(organization.getId());o.setParentCode(organization.getOrgCode());}return o;}//逻辑处理 机构若存在该机构代码则进行修改否则进行新增public void disposeOrg(Organization organization) {Organization org organizationMapper.queryOrganizationByCode(organization.getOrgCode());if (org null || .equals(org.getOrgCode()) || !organization.getOrgCode().equals(org.getOrgCode())) {organizationMapper.insertOrganization(organization);log.info(新增完成!机构编号{},组织机构名称{}, organization.getOrgCode(), organization.getOrgName());} else {organizationMapper.updateOrganization(organization);log.info(修改完成!机构编号{},组织机构名称{}, organization.getOrgCode(), organization.getOrgName());}}//递归遍历机构下面的子机构信息public void recursive(Organization organization, ListHashMapString, Object sourceList) {try {Thread.currentThread().sleep(2000);} catch (Exception e) {e.printStackTrace();}//模拟请求三方接口中二级机构及其子机构的信息 TODOMap emp new HashMap();ListHashMapString, Object mapList new ArrayList();HashMapString, Object hashMap new HashMap();if (0001.equals(organization.getOrgCode())) {hashMap new HashMap();hashMap.put(ORG_CODE, 0011);hashMap.put(ORG_NAME, 丰台区);mapList.add(hashMap);hashMap new HashMap();hashMap.put(ORG_CODE, 0021);hashMap.put(ORG_NAME, 海淀区);mapList.add(hashMap);}if (0002.equals(organization.getOrgCode())) {hashMap new HashMap();hashMap.put(ORG_CODE, 0012);hashMap.put(ORG_NAME, 丰台区);mapList.add(hashMap);hashMap new HashMap();hashMap.put(ORG_CODE, 0022);hashMap.put(ORG_NAME, 大兴区);mapList.add(hashMap);}if (0011.equals(organization.getOrgCode())) {hashMap new HashMap();hashMap.put(ORG_CODE, 0031);hashMap.put(ORG_NAME, 马家堡);mapList.add(hashMap);hashMap new HashMap();hashMap.put(ORG_CODE, 0041);hashMap.put(ORG_NAME, 角门西);mapList.add(hashMap);}if (0021.equals(organization.getOrgCode())) {hashMap new HashMap();hashMap.put(ORG_CODE, 0051);hashMap.put(ORG_NAME, 白堆子);mapList.add(hashMap);}if (0012.equals(organization.getOrgCode())) {hashMap new HashMap();hashMap.put(ORG_CODE, 0032);hashMap.put(ORG_NAME, 岳各庄);mapList.add(hashMap);hashMap new HashMap();hashMap.put(ORG_CODE, 0042);hashMap.put(ORG_NAME, 大红门);mapList.add(hashMap);}if (0022.equals(organization.getOrgCode())) {hashMap new HashMap();hashMap.put(ORG_CODE, 0052);hashMap.put(ORG_NAME, 圆明园);mapList.add(hashMap);}emp.put(result, mapList);emp.put(status, 200);String code (String) emp.get(status);if (!200.equals(code)) {return;}ListHashMapString, Object list (ListHashMapString, Object) emp.get(result);sourceList.addAll(list);if (list.size() ! 0) {for (HashMapString, Object object : list) {Organization conversionOrg conversionOrg(organization.getOrgCode(), object);disposeOrg(conversionOrg);recursive(conversionOrg, sourceList);}}}public ListOrganization queryOrganization(ListHashMapString, Object sourceList) {ListOrganization organizationList organizationMapper.queryOrganizationByParentId(-1);ListOrganization parentList organizationList.stream().filter(item - item.getParentId() 0).collect(Collectors.toList());for (Organization organization : parentList) {ListOrganization children getChildren(organization, organizationList);organization.setChildren(children);}String json JSONArray.toJSONString(parentList);String sourceJson JSONArray.toJSONString(sourceList);organizationRecordMapper.insertOrganizationRecord(json,sourceJson);return parentList;}//获取当前节点的所有子节点public ListOrganization getChildren(Organization organization, ListOrganization organizationList) {ListOrganization list organizationList.stream().filter(item - item.getParentId() organization.getId()).collect(Collectors.toList());if (CollectionUtils.isEmpty(list)) {return null;}for (Organization org : list) {org.setChildren(getChildren(org, organizationList));}return list;} } controller类 package com.example.demo.controller;import com.example.demo.service.TestDiGuiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap;RestController RequestMapping(/digui) public class DiGuiController {AutowiredTestDiGuiService testDiGuiService;RequestMapping(syncOrg)public HashMapString, Object synchronousOrganization() {return testDiGuiService.syncOrganization();} }请求结果 postman调用接口 机构表  机构记录表 mybatis递归查询 也可通过mybatis查询属性结构信息一般数据量少的可以通过SQL实现 OrganizationMapper文件 package com.example.demo.mapper;import com.example.demo.entity.Organization; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List;/*** 组织机构mapper*/ Mapper public interface OrganizationMapper {//查询全部数据ListOrganization queryAll(Param(code) String code); }SQL collection propertychildren columnorg_code selectgetChildrenTreeByParentCode/的column设置的是父节点SQL的返回结果的列名。 ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.example.demo.mapper.OrganizationMapperresultMap idorgResultMap typecom.example.demo.entity.Organizationid propertyid columnid/result propertyorgCode columnorg_code/result propertyorgName columnorg_name/result propertyparentCode columnparent_code/result propertyparentId columnparent_id/result propertyparentAllCode columnparent_all_code/collection propertychildren columnorg_code selectgetChildrenTreeByParentCode/collection/resultMap!--级联查询父节点--select idqueryAll resultMaporgResultMap parameterTypeStringselect *from organizationwhere parent_code#{code}/select!--级联查询子节点--select idgetChildrenTreeByParentCode resultMaporgResultMapselect *from organizationwhere parent_code#{org_code}/select /mapper controller package com.example.demo.controller;import com.example.demo.entity.Organization; import com.example.demo.mapper.OrganizationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.List;RestController RequestMapping(/digui) public class DiGuiController {AutowiredOrganizationMapper organizationMapper;RequestMapping(test)public ListOrganization test(RequestParam(code)String code) {ListOrganization organizationList organizationMapper.queryAll(code);return organizationList;} }调用结果 可看出执行顺序先执行父节点SQL后根据每条返回的结果SQL的org_code列作为入参递归查询子节点SQL。 递归能力欠缺请各位大佬提出意见及错误
http://www.hkea.cn/news/14301891/

相关文章:

  • 建设网站是什么职位gif放网站有锯齿
  • 上海网站建设 网站开发滁州网站建设梦天堂
  • 做鞋子有什么好网站申请建设网站的请示
  • 搜狗优化好的网站服务号 wordpress
  • 线上平台运营方案西安网站建设推广优化
  • 网站后台忘了公司企业网站免费建设
  • 仿制别人的网站违法吗动漫设计与制作主要学什么
  • 好网站开发公司如何建设网站pdf
  • 网站建设的整体流程有哪些建设网站遇到问题的解决方案
  • 哪个网站做二手叉车回收好网页制作与设计是前端吗
  • 外网建筑设计网站南昌有哪些做网站的公司
  • 常州网站建设企业网站制作wordpress视频教程 电驴
  • 有关网站设计的文章做家具商城网站
  • 网站建设的一般流程网站建站哪个品牌好
  • 力软框架做网站花都手机网站建设
  • 南京微信网站建设个人网站一定要备案吗
  • 苏州网站搜索排名怎么做二维码转到网站
  • 中国建设银行购物网站怎么让百度收录网站
  • 小公司网站模版做微网站平台
  • 怎么做黑客攻击网站asp mysql做网站
  • 北京网页设计制作网站厦门启明星网站建设
  • 做现货值得关注的财经网站软文营销的定义
  • 云南seo整站优化报价做网站用的是什么语言
  • 中山网站建设文化如何网页游戏服务端
  • 汕头市做网站优化天眼查入口
  • 网站等级保护测评必须做吗富阳网站建站公司哪家好
  • 手机网站好还是h5好咸阳公司做网站
  • 外贸营销网站建设公司排名东莞网站建设是什么
  • 郑州网站设计费用成都住建局官网全生命周期
  • 建网站非要做外链吗网站开发文本模版