Springboot集成百度地图实现定位打卡功能

打卡sign表sql

CREATE TABLE `sign` (`id` int(11) NOT NULL AUTO_INCREMENT,`user` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户名称',`location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '打卡位置',`time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '打卡时间',`comment` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

百度开放平台

https://lbsyun.baidu.com/index.php?title=%E9%A6%96%E9%A1%B5

<script type=“text/javascript” src=“https://api.map.baidu.com/api?v=1.0&type=webgl&ak=bmvg8yeOopwOB4aHl5uvx52rgIa3VrPO”>

后台打卡逻辑

 // 新增或者更新@PostMappingpublic Result save(@RequestBody Sign sign) {if (sign.getId() == null) {  // 新增打卡String today = DateUtil.today();QueryWrapper<Sign> queryWrapper = new QueryWrapper<>();queryWrapper.eq("user", sign.getUser());queryWrapper.eq("time", today);Sign one = signService.getOne(queryWrapper);if (one != null) {  // 打过卡了return Result.error("-1", "您已打过卡");}sign.setTime(today);}signService.saveOrUpdate(sign);return Result.success();}

DateUtil是hutool的工具类

前台登录获取位置

mounted() {// 获取地理位置var geolocation = new BMapGL.Geolocation();geolocation.getCurrentPosition(function(r){if(this.getStatus() == BMAP_STATUS_SUCCESS){const province = r.address.provinceconst city = r.address.citylocalStorage.setItem("location", province + city)}});},

前台主页打卡功能

<template><div style="color: #666;font-size: 14px;"><div style="padding-bottom: 20px"><b>您好!{{ user.nickname }}</b></div><el-card>欢迎使用本系统<el-divider />虎虎生威,虎年大吉</el-card><el-card style="margin-top: 20px"><div style="margin: 20px 0; font-size: 20px">{{ new Date().getFullYear() + '年' + (new Date().getMonth() + 1) + '月' + new Date().getDate() + '日' }}</div><div style="width: 200px; height: 200px; line-height: 200px; border-radius: 50%; background-color: #1E90FF;font-size: 50px; color: #fff; text-align: center; cursor: pointer; box-shadow: 0 0 30px rgba(0, 0, 0, .2);" @click="sign">打 卡</div></el-card></div>
</template><script>export default {name: "Home",data() {return {user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}}},methods: {sign() {const location = localStorage.getItem("location")const username = this.user.usernamethis.request.post("/sign", { user: username, location: location }).then(res => {if (res.code === '200') {this.$message.success("打卡成功")} else {this.$message.error(res.msg)}})}}
}
</script>

前台管理打卡 SIgn.vue

<template><div><div style="margin: 10px 0"><el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search" v-model="name"></el-input>
<!--      <el-input style="width: 200px" placeholder="请输入" suffix-icon="el-icon-message" class="ml-5" v-model="email"></el-input>-->
<!--      <el-input style="width: 200px" placeholder="请输入" suffix-icon="el-icon-position" class="ml-5" v-model="address"></el-input>--><el-button class="ml-5" type="primary" @click="load">搜索</el-button><el-button type="warning" @click="reset">重置</el-button></div><div style="margin: 10px 0"><el-button type="primary" @click="handleAdd">新增 <i class="el-icon-circle-plus-outline"></i></el-button><el-popconfirmclass="ml-5"confirm-button-text='确定'cancel-button-text='我再想想'icon="el-icon-info"icon-color="red"title="您确定批量删除这些数据吗?"@confirm="delBatch"><el-button type="danger" slot="reference">批量删除 <i class="el-icon-remove-outline"></i></el-button></el-popconfirm><!-- <el-upload action="http://localhost:9090/sign/import" :show-file-list="false" accept="xlsx" :on-success="handleExcelImportSuccess" style="display: inline-block"><el-button type="primary" class="ml-5">导入 <i class="el-icon-bottom"></i></el-button></el-upload><el-button type="primary" @click="exp" class="ml-5">导出 <i class="el-icon-top"></i></el-button> --></div><el-table :data="tableData" border stripe :header-cell-class-name="'headerBg'"  @selection-change="handleSelectionChange"><el-table-column type="selection" width="55"></el-table-column><el-table-column prop="id" label="ID" width="80" sortable></el-table-column><el-table-column prop="user" label="用户名称"></el-table-column><el-table-column prop="location" label="打卡位置"></el-table-column><el-table-column prop="time" label="打卡时间"></el-table-column><el-table-column prop="comment" label="备注"></el-table-column><el-table-column label="操作"  width="180" align="center"><template slot-scope="scope"><el-button type="success" @click="handleEdit(scope.row)">编辑 <i class="el-icon-edit"></i></el-button><el-popconfirmclass="ml-5"confirm-button-text='确定'cancel-button-text='我再想想'icon="el-icon-info"icon-color="red"title="您确定删除吗?"@confirm="del(scope.row.id)"><el-button type="danger" slot="reference">删除 <i class="el-icon-remove-outline"></i></el-button></el-popconfirm></template></el-table-column></el-table><div style="padding: 10px 0"><el-pagination@size-change="handleSizeChange"@current-change="handleCurrentChange":current-page="pageNum":page-sizes="[2, 5, 10, 20]":page-size="pageSize"layout="total, sizes, prev, pager, next, jumper":total="total"></el-pagination></div><el-dialog title="信息" :visible.sync="dialogFormVisible" width="40%" :close-on-click-modal="false"><el-form label-width="140px" size="small" style="width: 85%;"><el-form-item label="用户名称"><el-input v-model="form.user" autocomplete="off"></el-input></el-form-item><el-form-item label="打卡位置"><el-input v-model="form.location" autocomplete="off"></el-input></el-form-item><el-form-item label="打卡时间"><el-date-picker v-model="form.time" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间"></el-date-picker></el-form-item><el-form-item label="备注"><el-input v-model="form.comment" autocomplete="off"></el-input></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="dialogFormVisible = false">取 消</el-button><el-button type="primary" @click="save">确 定</el-button></div></el-dialog></div>
</template><script>
export default {name: "Sign",data() {return {tableData: [],total: 0,pageNum: 1,pageSize: 10,name: "",form: {},dialogFormVisible: false,multipleSelection: [],user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}}},created() {this.load()},methods: {load() {this.request.get("/sign/page", {params: {pageNum: this.pageNum,pageSize: this.pageSize,name: this.name,}}).then(res => {this.tableData = res.data.recordsthis.total = res.data.total})},save() {this.request.post("/sign", this.form).then(res => {if (res.code === '200') {this.$message.success("保存成功")this.dialogFormVisible = falsethis.load()} else {this.$message.error("保存失败")}})},handleAdd() {this.dialogFormVisible = truethis.form = {}this.$nextTick(() => {if(this.$refs.img) {this.$refs.img.clearFiles();}if(this.$refs.file) {this.$refs.file.clearFiles();}})},handleEdit(row) {this.form = JSON.parse(JSON.stringify(row))this.dialogFormVisible = truethis.$nextTick(() => {if(this.$refs.img) {this.$refs.img.clearFiles();}if(this.$refs.file) {this.$refs.file.clearFiles();}})},del(id) {this.request.delete("/sign/" + id).then(res => {if (res.code === '200') {this.$message.success("删除成功")this.load()} else {this.$message.error("删除失败")}})},handleSelectionChange(val) {console.log(val)this.multipleSelection = val},delBatch() {if (!this.multipleSelection.length) {this.$message.error("请选择需要删除的数据")return}let ids = this.multipleSelection.map(v => v.id)  // [{}, {}, {}] => [1,2,3]this.request.post("/sign/del/batch", ids).then(res => {if (res.code === '200') {this.$message.success("批量删除成功")this.load()} else {this.$message.error("批量删除失败")}})},reset() {this.name = ""this.load()},handleSizeChange(pageSize) {console.log(pageSize)this.pageSize = pageSizethis.load()},handleCurrentChange(pageNum) {console.log(pageNum)this.pageNum = pageNumthis.load()},handleFileUploadSuccess(res) {this.form.file = res},handleImgUploadSuccess(res) {this.form.img = res},download(url) {window.open(url)},exp() {window.open("http://localhost:9090/sign/export")},handleExcelImportSuccess() {this.$message.success("导入成功")this.load()}}
}
</script><style>
.headerBg {background: #eee!important;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/554902.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux版本i686,linux-x86_64平台上的gcc i686

我在RHEL X86_64上安装GCC i686时遇到一些麻烦.确实,我必须在此平台上构建一些32位软件和共享库.我可以在32位平台(Linux或Windows)上构建这些软件和库.我的问题在这篇文章的结尾.我的第一个问题是这个错误&#xff1a;(在buil期间,在Eclipse -helios下)In file included from …

线程死锁——死锁产生的条件

什么是线程死锁 线程死锁是指由于两个或者多个线程互相持有对方所需要的资源&#xff0c;导致这些线程处于相互等待状态&#xff0c;若无外力作用&#xff0c;它们将无法继续执行下去。 造成死锁的原因可以概括成三句话&#xff1a; 当前线程拥有其他线程需要的资源当前线程…

linux查看正在运行的窗口,获取linux中打开的应用程序窗口的数量

我想检测由窗口管理器管理的特定应用程序的实例数量.目前,我有这个&#xff1a;#!/bin/bash# wmctrl requiredpids$(pidof $1)IFS read -a pid_arr <<< "$pids"matches0for pid in "${pid_arr[]}"domatching_lines$(wmctrl -l -p | egrep -c &qu…

TortoiseGit的使用详解

Git是什么&#xff0c;相信大家都很清楚。Git不就是分布式版本控制系统嘛&#xff1f;那你知道TortoiseGit是什么吗&#xff1f;下面我们就介绍一下TortoiseGit它是什么&#xff1f;如何使用&#xff1f;   TortoiseGit其实是一款开源的git的版本控制系统&#xff0c;也叫海龟…

linux gpt分区看不到,Linux无法看到我的任何分区 – 备份GPT表不在磁盘的末尾

我正在尝试在HP Pavilion 14英寸超极本上安装Linux,但没有任何成功.起初我尝试在其上安装Ubuntu;一切都很顺利,我进入了Live DVD(是的,我就像那样老了),然后去我的磁盘上安装系统.发生的第一个奇怪的事情是,我没有被提示选择在Windows旁边安装Ubuntu,而是直接用分区表抛入窗口.…

将项目上传到Gitee上(命令方式使用TortoiseGit方式)

如何将项目上传到Gitee上&#xff08;命令方式&#xff09; 目录 将项目上传到Gitee是我们经常需要使用到的操作&#xff0c;因此我们要熟悉这些步骤 一、首先保证本机已经安装了Git git官网安装完成之后&#xff0c;鼠标右键会出现Git GUI Here和Git Bash Here 二、上传代…

linux自动重新启动,linux 系统自动重新启动,请帮忙看看

在查了一下,的确有这个log其中有一段之后系统开始重新启动&#xff0c;请帮忙看看是什么原因&#xff1a;谢谢[2011-01-25 11:33:36 xend.XendDomainInfo 2990] DEBUG (XendDomainInfo:228) XendDomainInfo.recreate({paused: 0, cpu_time: 41195236230L, ssidref: 0, hvm: 0, …

java.awt.Color类

Color类概述 Color是用来封装颜色的&#xff0c;支持多种颜色空间&#xff0c;默认为RGB颜色空间。每个Color对象都有一个alpha通道&#xff0c;值为0到255&#xff0c;代表透明度&#xff0c;当alpha通道值为255时&#xff0c;表示完全不透明&#xff1b;当alpha通道值为0时&…

BufferedImage类、Image类、Graphics类

BufferedImage Image是一个抽象类&#xff0c;BufferedImage是其实现类&#xff0c;是一个带缓冲区图像类&#xff0c;主要作用是将一幅图片加载到内存中&#xff08;BufferedImage生成的图片在内存里有一个图像缓冲区&#xff0c;利用这个缓冲区我们可以很方便地操作这个图片&…

linux远程连接最大数是多少,Linux Shell 脚本限制ssh最大用户登录数

我撰写本文原来的意图是想把“复制SSH渠道”和"copy SSH Session"这样的功能从远程ssh客户端中剔除掉.因此想到可以在SSH服务端设置一下&#xff0c;但查阅了sshd_config的man手册,发现里面的看起来限制ssh连接数量的参数(MaxSessions &#xff0c;ClientAliveCountM…

linux 文件名带特殊符号,Linux删除含有特殊符号文件名的文件

Web前端面试题目及答案汇总HTML/CSS部分 1.什么是盒子模型? 在网页中,一个元素占有空间的大小由几个部分构成,其中包括元素的内容(content),元素的内边距(padding),元素的边框(border),元素的外边 ...Delphi中滚动文字的应用1.添加一个Timer控件,Interval属性设置为20. 2.添加…

Vue this.$refs的作用

案例一、ref 写在标签上时 <!-- ref 写在标签上时&#xff1a;this.$refs.名字 获取的是标签对应的dom元素ref 写在组件上时&#xff1a;这时候获取到的是 子组件&#xff08;比如counter&#xff09;的引用--><div id"root"><!-- ref hello&#…

linux电脑合盖后卡住了,解决ubuntu合盖后无法唤醒

解决办法&#xff1a;安装laptop-mode-tools工具包。1.检查是否安装了grep laptop-mode-tools 工具包$ dpkg -l | grep laptop-mode-tools如果执行命令无结果输出&#xff0c;表示未安装(如果已安装&#xff0c;忽略第2步)2.安装laptop-mode执行命令&#xff1a;$ sudo apt-get…

三列布局 css

实现如下图的三列布局&#xff1a; .box {width:1400px;margin:0 auto;padding-bottom:40px;> .left {float:left;width:180px;margin-top:100px;text-align:center;}> .center {float:left;margin-top:100px;margin-left:130px;item-box {float:left;text-align:left;…

axios和ajax的区别是什么

axios和ajax的区别&#xff1a; 1、axios是一个基于Promise的HTTP库&#xff0c;而ajax是对原生XHR的封装&#xff1b; 2、ajax技术实现了局部数据的刷新&#xff0c;而axios实现了对ajax的封装。 axios和ajax的区别是什么? axios和ajax的区别及优缺点: ajax&#xff1a; 1…

telnet linux 命令详解,解析Linux Telnet命令

不少系统中&#xff0c;都有Telnet的相关涉及和使用。那么今天我们就来讲解一下Linux Telnet命令的相关使用和操作。这里我们针对一些重点的内容和命令进行讲解。希望对大家有所帮助。用户使用Telnet命令进行远程登录。该命令允许用户使用Telnet协议在远程计算机之间进行通信&a…

VUE学习笔记详细

VUE学习笔记 本文章以vue3来记录的&#xff0c;但并非记录vue3所有变化&#xff01; 1、ES6语法 1.1、let变量声明 let用于声明变量有局部作用域let声明的变量不会提升&#xff08;只能先定义后使用&#xff09; 1.2、const变量声明 const用于声明常量const声明的常量也不会…

C语言2020年作业,2020年c语言上机报告范文【四篇】

《2020年c语言上机报告范文【四篇】》由会员分享&#xff0c;可在线阅读&#xff0c;更多相关《2020年c语言上机报告范文【四篇】(7页珍藏版)》请在人人文库网上搜索。1、2020 年 c 语言上机报告范文【四篇】2020 年 c 语言上机报告范文一说到我学习 C 语言时&#xff0c;真是用…

Centos7配置gitlab服务器

Centos7配置gitlab服务器 1、安装SSH yum install -y curl policycoreutils-pythonopenssh-server设置开机自启 sudo systemctl enable sshd启动服务 sudo systemctl start sshd2、安装postfix 邮件服务 sudo yum install postfix设置开机自启 sudo systemctl enable po…

湖南工大11级C语言网上作业,湖南工大11级C语言网上作业之《最简单的程序设计》.docx...

《程序设计语言 C1》随机作业题做作业时间&#xff1a;2012-3-9 8:00:00至2012-5-29 23:30:00?1、以下程序的输出结果是 main() { char cz; printf("%c",c-25); } (3分)A、B、C、D、A、aB、ZC、z-25D、y?2、以下程序段的输出结果是 char s[]"\\141\141abc\t&q…