首页 > 其他分享 >科技政策查询(Springbood)

科技政策查询(Springbood)

时间:2022-11-04 08:56:18浏览次数:48  
标签:name text paopao 查询 科技 Springbood policy import com

    pom.xml:

<!--      mybatisplus依赖-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>
        <!--        mybatisplus依赖-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>

<!--        注解小工具-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.16</version>
        </dependency>

 

PolicyController:

package com.paopao.controller;

import com.paopao.domain.Policy;
import com.paopao.domain.Text;
import com.paopao.service.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController

@RequestMapping("/policy")
public class PolicyController {
    @Autowired
    private PolicyService policyService;

    @GetMapping
    public List<Policy> SelectAll(){
        System.out.println("11111");
        List<Policy> list=policyService.SelectAll();
        return list;
    }
    @PostMapping
    public List<Policy> GetType(@RequestBody Policy policy){
        List<Policy> list=policyService.GetType(policy);
        return list;
    }
    @GetMapping("/{name}")
    public String GetText(@PathVariable String name){
        System.out.println(name+"1111111111111111111111");
        String text= policyService.GetText(name);
        System.out.println(text);
        return text;
    }

}

 

TextDao:

  

package com.paopao.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.paopao.domain.Text;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface TextDao extends BaseMapper<Text> {
}

 

Policy:

package com.paopao.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("policy")
public class Policy {
    private String name;
    private String organ;
    @TableField(value = "pubdata")
    private String date;
    private String type;
}

 

Text:

package com.paopao.domain;


import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("policy")
public class Text {
    @TableField(value = "text")
    private String text;
    private String name;
}

 

 

PolicyService:

package com.paopao.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.paopao.domain.Policy;
import com.paopao.domain.Text;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
public interface PolicyService extends IService<Policy> {


    List<Policy> SelectAll();

    List<Policy> GetType(Policy policy);

    String GetText(String name);

}

 

PolicyServiceImpl:

package com.paopao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.paopao.dao.PolicyDao;
import com.paopao.dao.TextDao;
import com.paopao.domain.Policy;
import com.paopao.domain.Text;
import com.paopao.service.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class PolicyServiceImpl extends ServiceImpl<PolicyDao,Policy> implements PolicyService {
    @Autowired
    private PolicyDao policyDao;

    @Autowired
    private TextDao textDao;
    @Override
    public List<Policy> SelectAll() {
        List<Policy> list=policyDao.selectList(null);
        return list;
    }

    @Override
    public List<Policy> GetType(Policy policy) {
        LambdaQueryWrapper<Policy> lam=new LambdaQueryWrapper<Policy>();
        lam.eq(!policy.getName().equals(""),Policy::getName,policy.getName());//中间那个是数据库里面的name
        lam.like(!policy.getType().equals(""),Policy::getType,policy.getType());
        lam.like(!policy.getOrgan().equals(""),Policy::getOrgan,policy.getOrgan());
        List<Policy> list=policyDao.selectList(lam);
        return list;
    }

    @Override
    public String GetText(String name) {
        Text text=new Text();
//        Policy policy=new Policy();
        text.setName(name);
        LambdaQueryWrapper<Text> lam=new LambdaQueryWrapper<Text>();
        lam.eq(Text::getName,text.getName());
        text=textDao.selectOne(lam);
        return text.getText();
    }
}

 

main.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>科技政策管理系统</title>
    <script src="js/axios.min.js"></script>
    <script src="js/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<style>
    /*<!--    表单 -->*/
    .el-table .warning-row {
        background: oldlace;
    }

    .el-table .success-row {
        background: #f0f9eb;
    }
</style>
<body>

<div id="main">
    <!--    输入框-->
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="政策名称">
            <el-input v-model="formInline.name" placeholder="请输入政策名称"></el-input>
        </el-form-item>
        <el-form-item label="发文机构">
            <el-input v-model="formInline.oragan" placeholder="请输入审批人"></el-input>
        </el-form-item>
        <el-form-item label="类型">
            <el-input v-model="formInline.type" placeholder="请输入类型"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
    </el-form>

    <!--表单-->
    <template>
        <el-table
                :data="tableData"
                style="width: 100%"
                :row-class-name="tableRowClassName"
        >
            <el-table-column
                    prop="name"
                    label="政策名称"
                    align:right>
            </el-table-column>
            <el-table-column
                    prop="organ"
                    label="发文机构"
                    align:center>
            </el-table-column>
            <el-table-column
                    prop="type"
                    align:center
                    label="政策类型">
            </el-table-column>
            <el-table-column
                    prop="date"
                    align:center
                    label="发文时间">
            </el-table-column>
            <el-table-column
                    align:center
                    label="操作">
                <template slot-scope="scope">
                    <el-button type="primary" round @click="SelectText(scope.row)">查询</el-button>
            </template>
            </el-table-column>

        </el-table>
    </template>

</div>
<script>
    new Vue({
        el: "#main",
        methods: {//函数方法
            tableRowClassName({row, rowIndex}) {//表单函数
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            SelectAll() {
                axios.get("/policy").then((res) => {
                    this.tableData = res.data
                })
            },
            onSubmit() {
                // console.log(this.formInline)
                axios.post("/policy", this.formInline).then((res) => {
                    this.tableData = res.data
                })
            },
            SelectText(row){
                // alert(row.name)
                var name=row.name
                axios.get("/policy/"+name).then((res)=>{
                    this.text=res.data
                    alert(this.text)
                    this.$alert('<body>'+this.text+'</body>',name , {
                        dangerouslyUseHTMLString: true
                    });
                })
            },
        },
        created() {
            // this.SelectAll()
        },
        data() {//数据源
            return {
                tableData: [],
                formInline: {
                    name: '',
                    type: '',
                    organ:''
                },
                text:''

            }
        },
        mounted() {//初始化
            // alert("加载完成")
            this.SelectAll()
        }
    })
</script>
</body>
</html>

 

application.yml(这个是要把文件类型改成yml才可以使用的)

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/canteen?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: 123456
    type: com.alibaba.druid.pool.DruidDataSource

    #关闭日志
  main:
    banner-mode: off



logging:
  level:
    root: warn
server:
  port: 80

#  去除启动时的日志
mybatis-plus:
  global-config:
    banner: false
#    开启sql语句的日志
#  configuration:
#      map-underscore-to-camel-case: true
#      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

mapper

 

 

标签:name,text,paopao,查询,科技,Springbood,policy,import,com
From: https://www.cnblogs.com/1774323810com/p/16856524.html

相关文章

  • 树形结构查询,科技政策查询系统
         Policy:packagebean;publicclassPolicy{privateStringname;//政策名称privateStringorgan;//发文机构privateStringdate;......
  • java分页查询后端代码
    packagecom.example.demo;importjava.util.List;importorg.apache.ibatis.annotations.Delete;importorg.apache.ibatis.annotations.Insert;importorg.apache.......
  • NHibernate1.2 执行多表查询
    个人写法可能有点傻···在改进先贴出来!让大家找点思路····目的:将两个表的内容综合到一个集合里,然后邦定到GridView上解决方法:1.创建一个综合了两个实体类的一个新的......
  • 07_查询数据_系统数据字典_SQL值表达式
    一、系统数据字典 代码:select*fromgp_pgdatabase;(查看数据字典) 二、SQL值表达式值表达式包括查询条件中的各种命令;值表达式的结果称为标量;表达式语法允许从原......
  • 模糊查询并且对HBase进行CRUD的操作
     我这是两次的实验用的一个项目,第二次的实验是在第一次上的实验的基础上增加而来     pom.xml<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="......
  • MySQL连接分页查询问题
    问题两表连接查询分页,如果不进行排序,则分页不准确,这将导致第一页出现的数据会在后几页再次出现,而且每次查询第一页结果都不一致解决连接查询分页必须按主键分页才能保证......
  • 恒创科技:虚拟服务器的优缺点有哪些?
    服务器虚拟化的概念是使用物理服务器,并在虚拟化软件的帮助下,对服务器进行分区或分割,使其显示为多个“虚拟服务器”,每个“虚拟服务器”都可以运行它们的操作系统副本。为......
  • Linux中tac命令倒序查询日志
    cat命令是正序开始查询日志比如:catxxx.log|grep"sssdsd"如果日志文件比较大,那么会很慢或者直接出错 可以使用tac命令,这个是cat反过来写tacxxx.log|grep"sssdsd"这样就......
  • MySQL—简单,分组,条件查询
    MySQL1.什么是SQL:结构化查询语言(StructuredQueryLanguage)。2.SQL的作用:客户端使用SQL来操作服务器。启动mysql.exe,连接服务器后,就可以使用sql来操作服务器了。将......
  • 数据库等值查询与统计信息
    简介: 统计信息是为优化器的cost估算提供数据支撑,其中很重要的一点需求便是等值查询(EQUALS,IN等)场景下的基数估算。概念统计信息是为优化器的cost估算提供数......