| src/main/java/org/springblade/modules/location/controller/LivePersonLocationController.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/location/entity/LivePersonLocation.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.xml | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/location/service/ILivePersonLocationService.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/location/service/impl/LivePersonLocationServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/location/vo/LivePersonLocationVO.java | ●●●●● patch | view | raw | blame | history |
src/main/java/org/springblade/modules/location/controller/LivePersonLocationController.java
New file @@ -0,0 +1,52 @@ package org.springblade.modules.location.controller; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; import org.springblade.modules.location.entity.LivePersonLocation; import org.springblade.modules.location.entity.Locus; import org.springblade.modules.location.service.ILivePersonLocationService; import org.springblade.modules.location.vo.LivePersonLocationVO; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @author zhongrj * @time 2021-07-21 * @desc 实时位置控制层 */ @RestController @AllArgsConstructor @RequestMapping("/livePersonLocation") public class LivePersonLocationController extends BladeController { private final ILivePersonLocationService livePersonLocationService; /** * 新增 */ @PostMapping("/save") public R save(@RequestBody LivePersonLocation livePersonLocation) { return R.status(livePersonLocationService.save(livePersonLocation)); } /** * 新增或更新位置信息 */ @PostMapping("/saveOrUpdate") public R saveOrUpdate(@RequestBody LivePersonLocation livePersonLocation) { return R.status(livePersonLocationService.saveOrUpdate(livePersonLocation)); } /** * 新增或更新位置信息 */ @GetMapping("/getList") public R getList(LivePersonLocationVO livePersonLocation) { List<LivePersonLocationVO> list = livePersonLocationService.getList(livePersonLocation); return R.data(list); } } src/main/java/org/springblade/modules/location/entity/LivePersonLocation.java
New file @@ -0,0 +1,31 @@ package org.springblade.modules.location.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; import java.util.Date; /** * 人员实时位置 */ @Data @TableName("sys_live_person_location") public class LivePersonLocation implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id",type = IdType.AUTO) private Long id; private String longitude; private String latitude; private Long userId; private Date recordTime; } src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.java
New file @@ -0,0 +1,14 @@ package org.springblade.modules.location.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.springblade.modules.location.entity.LivePersonLocation; import org.springblade.modules.location.vo.LivePersonLocationVO; import java.util.List; public interface LivePersonLocationMapper extends BaseMapper<LivePersonLocation> { LivePersonLocation getUserLocation(@Param("userId") Long userId); List<LivePersonLocationVO> getList(@Param("vo") LivePersonLocationVO livePersonLocation); } src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.xml
New file @@ -0,0 +1,13 @@ <?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="org.springblade.modules.location.mapper.LivePersonLocationMapper"> <select id="getUserLocation" resultType="org.springblade.modules.location.entity.LivePersonLocation"> SELECT * FROM sys_live_person_location WHERE user_id = #{userId} </select> <select id="getList" resultType="org.springblade.modules.location.vo.LivePersonLocationVO"> SELECT lpl.* FROM sys_live_person_location lpl </select> </mapper> src/main/java/org/springblade/modules/location/service/ILivePersonLocationService.java
New file @@ -0,0 +1,11 @@ package org.springblade.modules.location.service; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.location.entity.LivePersonLocation; import org.springblade.modules.location.vo.LivePersonLocationVO; import java.util.List; public interface ILivePersonLocationService extends IService<LivePersonLocation> { List<LivePersonLocationVO> getList(LivePersonLocationVO livePersonLocation); } src/main/java/org/springblade/modules/location/service/impl/LivePersonLocationServiceImpl.java
New file @@ -0,0 +1,36 @@ package org.springblade.modules.location.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.tool.utils.DateUtil; import org.springblade.modules.location.entity.LivePersonLocation; import org.springblade.modules.location.mapper.LivePersonLocationMapper; import org.springblade.modules.location.service.ILivePersonLocationService; import org.springblade.modules.location.vo.LivePersonLocationVO; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Service public class LivePersonLocationServiceImpl extends ServiceImpl<LivePersonLocationMapper, LivePersonLocation> implements ILivePersonLocationService { @Override public boolean saveOrUpdate(LivePersonLocation entity) { Date recordTime = DateUtil.now(); entity.setRecordTime(recordTime); //查询数据库中是否已有该人员 LivePersonLocation livePersonLocation = baseMapper.getUserLocation(entity.getUserId()); if (livePersonLocation == null){ return baseMapper.insert(entity)>-1; }else{ entity.setId(livePersonLocation.getId()); return baseMapper.updateById(entity)>-1; } } @Override public List<LivePersonLocationVO> getList(LivePersonLocationVO livePersonLocation) { return baseMapper.getList(livePersonLocation); } } src/main/java/org/springblade/modules/location/vo/LivePersonLocationVO.java
New file @@ -0,0 +1,8 @@ package org.springblade.modules.location.vo; import lombok.Data; import org.springblade.modules.location.entity.LivePersonLocation; @Data public class LivePersonLocationVO extends LivePersonLocation { }