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

湖北省建设厅官方网站电话网站开发需要哪些技术

湖北省建设厅官方网站电话,网站开发需要哪些技术,wordpress菜单设计,wordpress directory数据库关系有父子id的, 作为菜单栏展示时需要用前端需要用到懒加载, 所谓懒加载就是接口有一个标志位isLeaf, 前端请求后通过该字段判断该节点是否还有子节点数据 创建数据库表 t_company_info结构有id和parentId标识, 用来表示父子关系 /*Navicat Premium Data TransferSourc…

数据库关系有父子id的, 作为菜单栏展示时需要用前端需要用到懒加载, 所谓懒加载就是接口有一个标志位isLeaf, 前端请求后通过该字段判断该节点是否还有子节点数据

创建数据库表 t_company_info结构有id和parentId标识, 用来表示父子关系

/*Navicat Premium Data TransferSource Server         : mysql8.0Source Server Type    : MySQLSource Server Version : 80029 (8.0.29)Source Host           : localhost:3307Source Schema         : springboot_mybatisTarget Server Type    : MySQLTarget Server Version : 80029 (8.0.29)File Encoding         : 65001*/SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for t_company_info
-- ----------------------------
DROP TABLE IF EXISTS `t_company_info`;
CREATE TABLE `t_company_info`  (`id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'id',`company_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '公司名',`parent_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '父节点id',PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of t_company_info
-- ----------------------------
INSERT INTO `t_company_info` VALUES ('1', '旺旺集团', '0');
INSERT INTO `t_company_info` VALUES ('2', '广州分部', '1');
INSERT INTO `t_company_info` VALUES ('3', '深圳分部', '1');
INSERT INTO `t_company_info` VALUES ('4', '福田区分公司', '3');
INSERT INTO `t_company_info` VALUES ('5', '南山区分公司', '3');SET FOREIGN_KEY_CHECKS = 1;

有需要的配置文件 application.yml 可参考

spring:datasource:username: #填写账号password: #填写密码url: jdbc:mysql://localhost:3307/springboot_mybatis?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true#&allowPublicKeyRetrieval=true这一部分设置是mysql8里面的, 不设置验证会报错driver-class-name: com.mysql.cj.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSourcedruid:stat-view-servlet:enabled: truelogin-username: login-password: web-stat-filter:enabled: true#  sql:
#    init:
#      schema-locations: classpath:sql/schema.sql
#      mode: always
server:port: 8089logging:level:root: info  #日志等级com.example.mybatis_plus: info
mybatis-plus:configuration:map-underscore-to-camel-case: true  #下划线转驼峰global-config:db-config:logic-not-delete-value: 0  #逻辑删除logic-delete-field: 1
#  type-enums-package: com.example.mybatis_plus.enums.statusEnum
1.创建实体类
package com.example.mybatis_plus.entity;import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;import java.io.Serializable;/*** <p>* * </p>** @author * @since 2023-04-01*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_company_info")
@ApiModel(value="CompanyInfo对象", description="")
public class CompanyInfo implements Serializable {private static final long serialVersionUID = 1L;@ApiModelProperty(value = "id")@TableId(value = "id", type = IdType.ASSIGN_UUID)private String id;@ApiModelProperty(value = "公司名")private String companyName;@ApiModelProperty(value = "父节点id")private String parentId;}
2.创建service接口
package com.example.mybatis_plus.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.example.mybatis_plus.entity.CompanyInfo;import java.util.List;/*** <p>*  服务类* </p>** @author * @since 2023-04-01*/
public interface CompanyInfoService extends IService<CompanyInfo> {/*** 获得指定父节点的子节点列表* @param parentId 父节点ID* @return 子节点列表*/List<CompanyInfo> getChildNodes(String parentId);
}
3.完成其实现类
package com.example.mybatis_plus.service.impl;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mybatis_plus.entity.CompanyInfo;
import com.example.mybatis_plus.mapper.CompanyInfoMapper;
import com.example.mybatis_plus.service.CompanyInfoService;
import org.springframework.stereotype.Service;import java.util.List;/*** <p>*  服务实现类* </p>** @author * @since 2023-04-01*/
@Service
public class CompanyInfoServiceImpl extends ServiceImpl<CompanyInfoMapper, CompanyInfo> implements CompanyInfoService {@Overridepublic List<CompanyInfo> getChildNodes(String parentId) {List<CompanyInfo> list=list(new QueryWrapper<CompanyInfo>().eq("parent_id",parentId));return list;}
}
4.mapper接口
package com.example.mybatis_plus.mapper;import com.example.mybatis_plus.entity.CompanyInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;/*** <p>*  Mapper 接口* </p>** @author * @since 2023-04-01*/
public interface CompanyInfoMapper extends BaseMapper<CompanyInfo> {}
5.mapper文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.mybatis_plus.mapper.CompanyInfoMapper"><!-- 通用查询映射结果 --><resultMap id="BaseResultMap" type="com.example.mybatis_plus.entity.CompanyInfo"><id column="id" property="id" /><result column="company_name" property="companyName" /><result column="parent_id" property="parentId" /></resultMap><!-- 通用查询结果列 --><sql id="Base_Column_List">id, company_name, parent_id</sql></mapper>
6.result统一结果封装类
@Data
public class Result implements Serializable {private int code;private String msg;private Object data;public static Result success(Object data) {return success(200, "操作成功", data);}public static Result success() {return success(200, "操作成功", null);}public static Result success(int code, String msg, Object data) {Result r = new Result();r.setCode(code);r.setMsg(msg);r.setData(data);return r;}public static Result fail(String msg) {return fail(400, msg, null);}public static Result fail(int code, String msg, Object data) {Result r = new Result();r.setCode(code);r.setMsg(msg);r.setData(data);return r;}}
6.创建树形结构实体类TreeNode
package com.example.mybatis_plus.entity;import lombok.Data;/*** @author * @description TODO* @date 2023-04-01*/
@Data
public class TreeNode {private String id;private String companyName;private String parentId;private Boolean isLeaf;public TreeNode(String id, String companyName, String parentId, Boolean isLeaf) {this.id = id;this.companyName = companyName;this.parentId = parentId;this.isLeaf = isLeaf;}
}
7.CompanyInfoController控制层
package com.example.mybatis_plus.controller;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatis_plus.common.Result;
import com.example.mybatis_plus.entity.CompanyInfo;
import com.example.mybatis_plus.entity.TreeNode;
import com.example.mybatis_plus.service.CompanyInfoService;
import com.example.mybatis_plus.utils.ParamUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;/*** <p>* * </p>** @author * @since 2023-04-01*/
@Api(value = "", tags = "")
@RestController
@RequestMapping("/companyInfo")
//@Slf4j
public class CompanyInfoController {@Autowiredprivate CompanyInfoService companyInfoService;@ApiOperation(value = "查询分页数据")@PostMapping(value = "/list")public Result list(@RequestBody(required = false) Map<String, Object> object) {Page<CompanyInfo> page = ParamUtils.toPage(CompanyInfo.class, object);CompanyInfo entity = ParamUtils.toEntity(CompanyInfo.class, object);QueryWrapper<CompanyInfo> qw = new QueryWrapper<>();if (null != entity) {qw.setEntity(entity);}// qw.orderByAsc("");page = companyInfoService.page(page, qw);return Result.success(page);}@ApiOperation(value = "根据id查询数据")@GetMapping(value = "/get")public Result get(String id) {if (null == id || id.equals("")) {return Result.fail("ID不能为空!");}CompanyInfo entity = companyInfoService.getById(id);return Result.success(entity);}/*** 输入 parentId** @param map* @return*/@ApiOperation(value = "获得指定父节点的子节点列表")@PostMapping(value = "/getChildNodes")public Result getChildNodes(@RequestBody Map<String, Object> map) {if (map.isEmpty()) {return Result.fail("输入格式错误");}String parentId = ParamUtils.toString(map, "parentId");
//        List<CompanyInfo> ngPowerTransformerInfoList = CompanyInfoService.getChildNodes(parentId);List<CompanyInfo> ngPowerTransformerInfoList = companyInfoService.getChildNodes(parentId);ArrayList<TreeNode> treeNodes = new ArrayList<>();for (CompanyInfo CompanyInfo : ngPowerTransformerInfoList) {String CompanyId = CompanyInfo.getId();String CompanyParentId = CompanyInfo.getParentId();String companyName = CompanyInfo.getCompanyName();boolean isLeaf = true;List<CompanyInfo> childNodes = companyInfoService.getChildNodes(CompanyId);if (childNodes.size() > 0) {isLeaf = false;}TreeNode treeNode = new TreeNode(CompanyId, companyName, CompanyParentId, isLeaf);treeNodes.add(treeNode);}return Result.success(treeNodes);}@ApiOperation(value = "新增/修改数据")@PostMapping(value = "/save")public Result save(HttpServletRequest request, @RequestBody CompanyInfo entity) {if (null == entity) {return Result.fail("对象不能为空!");}companyInfoService.saveOrUpdate(entity);return Result.success(entity);}@ApiOperation(value = "批量删除数据")@PostMapping(value = "/delete")public Result delete(HttpServletRequest request, @RequestBody List<String> idList) {if (null == idList || idList.isEmpty()) {return Result.fail("对象不能为空!");}companyInfoService.removeByIds(idList);return Result.success();}}

ps

String parentId = ParamUtils.toString(map, "parentId");
ParamUtils工具类有点多, 就不做展示了
就是将map里面的parentId取出来
8.结果演示
8.1请求父节点为0的数据, 只有集团总部, 并且还有子节点所以isLeaf为false

image-20230401222423508

8.2请求父id为1的数据,广州分部没有子节点, isLeaf为true,深圳有子节点,isLeaf为false

image-20230401222606121

8.3请求父id为3的数据, 同理

image-20230401222935783


文章转载自:
http://dinncokirn.tqpr.cn
http://dinncounwit.tqpr.cn
http://dinncopunk.tqpr.cn
http://dinncoinviable.tqpr.cn
http://dinncogildhall.tqpr.cn
http://dinncolanac.tqpr.cn
http://dinncohexapodic.tqpr.cn
http://dinncodayside.tqpr.cn
http://dinncocuculliform.tqpr.cn
http://dinncoredistribution.tqpr.cn
http://dinncounavenged.tqpr.cn
http://dinncouterine.tqpr.cn
http://dinnconondistinctive.tqpr.cn
http://dinncowheelset.tqpr.cn
http://dinncofrangipane.tqpr.cn
http://dinncoorthopaedic.tqpr.cn
http://dinncothymocyte.tqpr.cn
http://dinncojumbly.tqpr.cn
http://dinncobieerhaus.tqpr.cn
http://dinncodiamante.tqpr.cn
http://dinncosouthwest.tqpr.cn
http://dinncofairish.tqpr.cn
http://dinncorevival.tqpr.cn
http://dinncoexoelectron.tqpr.cn
http://dinnconullipore.tqpr.cn
http://dinncoenwomb.tqpr.cn
http://dinncopharisaism.tqpr.cn
http://dinncotwirler.tqpr.cn
http://dinncoloire.tqpr.cn
http://dinncobrilliancy.tqpr.cn
http://dinncostrychnine.tqpr.cn
http://dinnconebbish.tqpr.cn
http://dinncogoldleaf.tqpr.cn
http://dinncopartly.tqpr.cn
http://dinncofertilise.tqpr.cn
http://dinncofaeces.tqpr.cn
http://dinncolifesome.tqpr.cn
http://dinncojerk.tqpr.cn
http://dinncomaternal.tqpr.cn
http://dinncotops.tqpr.cn
http://dinncovl.tqpr.cn
http://dinncotag.tqpr.cn
http://dinncolacerna.tqpr.cn
http://dinncoelectrosurgical.tqpr.cn
http://dinncodowngrade.tqpr.cn
http://dinncolanceolar.tqpr.cn
http://dinncotrainload.tqpr.cn
http://dinncoamvets.tqpr.cn
http://dinncosabbath.tqpr.cn
http://dinncoreleasor.tqpr.cn
http://dinncomenstruate.tqpr.cn
http://dinncoxylylene.tqpr.cn
http://dinncofrancophile.tqpr.cn
http://dinncobiggest.tqpr.cn
http://dinncoacronymous.tqpr.cn
http://dinncoberbera.tqpr.cn
http://dinncohayfield.tqpr.cn
http://dinncoius.tqpr.cn
http://dinncobreakneck.tqpr.cn
http://dinncobelfried.tqpr.cn
http://dinncoelementoid.tqpr.cn
http://dinncoveterinarian.tqpr.cn
http://dinncoprovident.tqpr.cn
http://dinncoendosmotic.tqpr.cn
http://dinncosmeech.tqpr.cn
http://dinncoshinsplints.tqpr.cn
http://dinncoblazonry.tqpr.cn
http://dinncosuperfluorescence.tqpr.cn
http://dinncoplacing.tqpr.cn
http://dinncoforbore.tqpr.cn
http://dinncoultrafine.tqpr.cn
http://dinncoheroicomic.tqpr.cn
http://dinncorisotto.tqpr.cn
http://dinncoherbartian.tqpr.cn
http://dinncofluctuant.tqpr.cn
http://dinncoredline.tqpr.cn
http://dinncopb.tqpr.cn
http://dinncotripersonal.tqpr.cn
http://dinncocaliga.tqpr.cn
http://dinncoprojectual.tqpr.cn
http://dinncoskinniness.tqpr.cn
http://dinncoxerography.tqpr.cn
http://dinncomeniscocytosis.tqpr.cn
http://dinncomussalman.tqpr.cn
http://dinncostoniness.tqpr.cn
http://dinncolimbless.tqpr.cn
http://dinncomistful.tqpr.cn
http://dinncoiconolater.tqpr.cn
http://dinncosouthwestern.tqpr.cn
http://dinncoqum.tqpr.cn
http://dinncobrs.tqpr.cn
http://dinncoglycol.tqpr.cn
http://dinncothurification.tqpr.cn
http://dinncochunderous.tqpr.cn
http://dinncoserialisation.tqpr.cn
http://dinncoridgeboard.tqpr.cn
http://dinncorumbustious.tqpr.cn
http://dinncomuscoid.tqpr.cn
http://dinncokatyusha.tqpr.cn
http://dinncogeocentrism.tqpr.cn
http://www.dinnco.com/news/137819.html

相关文章:

  • 网站语言切换功能如何做无锡百度推广代理公司
  • 电商网站建设日程表网络优化排名培训
  • 常山做网站全网营销渠道
  • 设计师个人作品集网站seo是什么意思 职业
  • 可以注销的网站全世界足球排名前十位
  • 做网站哪家服务器好产品网络营销推广方案
  • 金银饰品那家网站做的好视频网站建设
  • 网站开发新功能注册城乡规划师报考条件
  • 同一个阿里云可以做两个网站吗营销推广外包
  • tq网站建设工具刷网站排刷排名软件
  • 微信网站建设新闻seo优化培训班
  • mobi域名网站郑州见效果付费优化公司
  • golang 做网站重庆网站制作
  • 日文网站设计网易企业邮箱
  • 四川泸州做网站的公司seo快速排名服务
  • 网站开发gbk电商引流推广方法
  • nba网站制作南宁今日头条最新消息
  • 网站建设平台方案设计seo推广优化培训
  • wordpress chess廊坊关键词优化报价
  • 真空设备 东莞网站建设seo资源网站排名
  • 35互联做网站垃圾西安百度公司
  • 海淀教育人才网站徐州seo推广优化
  • 网站建设建站知识国际网站平台有哪些
  • 单页式网站免费二级域名分发
  • 网站上的地图代码googleseo服务公司
  • 网站开发工具的功能包括html推广普通话手抄报文字内容
  • 手机怎么进入国外网站做网站好的网站建设公司
  • wordpress找回删除插件百度关键词搜索引擎排名优化
  • 免费ui网站百度搜索引擎网址
  • 企业应该做几个网站电子营销主要做什么