zoukankan      html  css  js  c++  java
  • 地理信息网络态势数据服务接口设计

    项目内容:

    地理信息网络态势数据服务接口设计。

    数据库设计:

    三个字典表:

    1. 国家地区:(数字编码、中文编码、中文简称、英文简称、中文全称、英文全称)
    2. 各表中字段的属性字典表:(所属表名、所属表中的字段名、字典值、实际表示的值)
    3. 各种元素的类型编码:(类型编码、类型名称、上级类型编码、类型的深度、优先等级<优先等级越高,值越小,排序越靠前>0表示禁用,1表示可用)

    四个基本表:

    1. 网络的基本属性:1编号2名称3类型编码4父节点编号5描述信息6控制程度7所属单位编号
    2. 网络节点基本属性:1编号2名称3目标类型编码4是否为桥接点5父节点编号6重要程度7所属物理平台编号8所属网络编号9节点描述10首报时间11信息更新时间12控守状态13在线状态
    3. 雷达(网络节点扩展表):1.编号2探测距离3旋转周期4雷达体制5雷达半径6雷达朝向7雷达内角
    4. 物理平台基本属性表:(1.编号2.名称3.类型编码4.经度5.纬度6.高深度7所属单位编号8父节点编号9所属国建编号10驻扎单位11综合价值12描述信息13首报时间14信息更新时间15军事部署情况)

    (1)其中各种元素的类型编码表采用无极限分类的方式实现   查询:select   where parentId=?and depth=?(实现就是点击功能的时候显示分类情况)

    (2)查询每个单表的时候是采用基本表和字典表一起联合查询的方式实现(内连接),优点,反复使用的数据存在了字典表中,节约了基本表的空间,提高了查询的速度。

    Select *from A as a ,B as where a.id=b.id.

    (3)考虑频繁查询的效率问题,为了给服务器减轻压力,开启了mysql缓存

    (4)考虑多线程查询过程中出现的一致性问题,通过在mybatis中采用乐观锁

        <update id="updateUser" >
            update t_user set username=#{username},password=#{password},account=#{account} ,version=version+1 where id=#{id} and version =#{version}
        </update>

    springmvc代码:

    package com.test.ball.Controller;
    
    import com.test.ball.entity.Country;
    import com.test.ball.service.CountryService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.*;
    
    import javax.servlet.http.HttpServletRequest;
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * Created by nick on 2018/8/8.
     */
    @Controller
    public class CountryController {
        //请求的路径,方式
        @Autowired
        private CountryService countryService;
        @RequestMapping(value = "/get", method = RequestMethod.GET)
        @ResponseBody// 比如异步获取 json 数据,加上 @ResponseBody 后,会直接返回 json 数据。
      //@RequestBody是作用在形参列表上,用于将前台发送过来固定格式的数据【xml 格式或者 json等】封装为对应的 JavaBean 对象,
      //封装时使用到的一个对象是系统默认配置的 HttpMessageConverter进行解析,然后封装到形参上。
    //查询所有结果 public List<Country> foo1(HttpServletRequest request) { List<Country> list = new ArrayList<Country>(); list=countryService.getAll(); return list; } //查询某一国家 @RequestMapping(value="/get/{id}",method = RequestMethod.GET) @ResponseBody public Country getById(@PathVariable(value = "id") String id,HttpServletRequest request) { Country temp= countryService.getbySZBM(id); return temp; } //增加某一国家 @RequestMapping(value="/add",method = RequestMethod.POST) @ResponseBody public String add(HttpServletRequest request){ String SZBM = request.getParameter("SZBM"); String ZMBM2 = request.getParameter("ZMBM2"); String ZMBM3 = request.getParameter("ZMBM3"); String ZWJC = request.getParameter("ZWJC"); String YWJC = request.getParameter("YWJC"); String ZWQC = request.getParameter("ZWQC"); String YWQC = request.getParameter("YWQC"); Country temp = new Country(SZBM,ZMBM2,ZMBM3,ZWJC,YWJC,ZWQC,YWQC); System.out.println(temp.getSZBM()); countryService.add(temp); return "redirect:/get"; } //删除某一国家,delete请求 @DeleteMapping(value = "/delete/{id}") @ResponseBody public String delete(@PathVariable(value = "id") String id){ countryService.deletebySZBM(id); return "redirect:/get"; } //修改某一国家数据,update /**修改课程 * */ @PutMapping(value = "/update") @ResponseBody public String update(Country temp){ countryService.update(temp); return "redirect:/get"; } }

     5.实现了restful风格的接口:

    通过请求类型不同来确定不同的操作:

    • GET(SELECT):从服务器取出资源(一项或多项)。
    • POST(CREATE):在服务器新建一个资源。
    • PUT(UPDATE):在服务器更新资源(客户端提供改变后的完整资源)。
    • DELETE(DELETE):从服务器删除资源。
    常规的接口为了区分不同增删改查的url,需要在url后面添加add、delete等标志
    但有了restful风格之后就不需要了,可以通过请求类型的不同来区别是增加资源还是删除资源。
     

    --------------------- 作者:王啸tr1912 来源:CSDN 原文:https://blog.csdn.net/tr1912/article/details/73065663?utm_source=copy 版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    Working with WordprocessingML documents (Open XML SDK)
    How to Choose the Best Way to Pass Multiple Models in ASP.NET MVC
    Azure:Manage anonymous read access to containers and blobs
    Convert HTML to PDF with New Plugin
    location.replace() keeps the history under control
    On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API
    HTTP Modules versus ASP.NET MVC Action Filters
    解读ASP.NET 5 & MVC6系列(6):Middleware详解
    Content Negotiation in ASP.NET Web API
    Action Results in Web API 2
  • 原文地址:https://www.cnblogs.com/nickup/p/9767590.html
Copyright © 2011-2022 走看看