合并了mybatisplus分页的修改

This commit is contained in:
weidong 2023-10-25 10:38:18 +08:00
parent 6e82c17f72
commit 555c88d4b9
5 changed files with 33 additions and 29 deletions

View File

@ -13,10 +13,11 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
* @date 2023/1/31 20:33
*/
@SpringBootApplication(scanBasePackages = {"com.imdroid"})
@MapperScan({"com.imdroid.secapi.dto","com.imdroid.beidou.entity"})
@MapperScan({"com.imdroid.secapi","com.imdroid.beidou.entity"})
@ComponentScan({"io.dt20.*", "com.imdroid.*"})
@EntityScan({"io.dt20.common.persistence", "com.imdroid.*"})
@EnableJpaRepositories({"io.dt20.common.repo", "com.imdroid.*"})
public class SideSlopeRtcmApp {
public static void main(String[] args) {

View File

@ -39,14 +39,14 @@ public class GnssDeviceController extends BasicController{
/**** 推送页面 *****/
@RequestMapping("/page/gnss_dev_cfg")
public String gnssDevCfg(Model m, HttpSession session)throws Exception {
public String gnssDevCfg(Model m, HttpSession session) {
initModel(m, session);
return "/page/gnss_dev_cfg";
}
@RequestMapping("/page/table/gnss_add_dev")
public String gnssUpdateDev(Model m)throws Exception {
public String gnssUpdateDev(Model m){
//以下用于下拉框数据
List<GnssGroup> gnssGroups = gnssGroupMapper.selectList(null);
List<GnssGroupCalc> gnssGroupCalcs = gnssGroupCalcMapper.selectList(null);
@ -64,7 +64,7 @@ public class GnssDeviceController extends BasicController{
/**** 推送数据 *****/
@RequestMapping("/gnss/device/list")
@ResponseBody
public JSONObject list(HttpSession session, int page, int limit, String searchParams) {
public JSONObject list(int page, int limit, String searchParams) {
Page<GnssDevice> pageable = new Page<>(page, limit);
QueryWrapper<GnssDevice> queryWrapper = new QueryWrapper<>();
@ -149,11 +149,10 @@ public class GnssDeviceController extends BasicController{
*
* @param deviceInstallVO 设备安装信息
* @return HttpResult
* @throws Exception
*/
@PostMapping("/gnss/device/install")
@ResponseBody
public HttpResult install(@Validated DeviceInstallVO deviceInstallVO) throws Exception {
public HttpResult install(@Validated DeviceInstallVO deviceInstallVO) {
QueryWrapper<GnssDevice> wrapper = new QueryWrapper<>();
wrapper.eq("deviceid",deviceInstallVO.getDeviceId());
GnssDevice gnssDevice = gnssDeviceMapper.selectOne(wrapper);
@ -182,7 +181,7 @@ public class GnssDeviceController extends BasicController{
if (gnssDevice == null) {
return HttpResult.fail("设备不存在");
}
GnssStatus gnssStatus = gnssStatusMapper.getByDeviceId(gnssDevice.getDeviceid());
GnssStatusJoin gnssStatus = gnssStatusMapper.queryByDeviceId(gnssDevice.getDeviceid());
DeviceStatusVO deviceStatusVO = new DeviceStatusVO(gnssDevice, gnssStatus);
return HttpResult.success(deviceStatusVO);
}

View File

@ -11,8 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
public class GnssGroupController {
@Autowired
@ -24,22 +22,22 @@ public class GnssGroupController {
/********* 推送页面 *********/
@RequestMapping("/page/table/gnss_add_group")
public String gnssAddGroup()throws Exception {
public String gnssAddGroup() {
return "/page/table/gnss_add_group";
}
@RequestMapping("/page/table/gnss_add_group_calc")
public String gnssAddCalcGroup()throws Exception {
public String gnssAddCalcGroup() {
return "/page/table/gnss_add_group_calc";
}
@RequestMapping("/page/table/gnss_add_group_fwd")
public String gnssAddPushGroup()throws Exception {
public String gnssAddPushGroup() {
return "/page/table/gnss_add_group_fwd";
}
@RequestMapping("/page/gnss_group_cfg")
public String gnssGroupCfg()throws Exception {
public String gnssGroupCfg() {
return "/page/gnss_group_cfg";
}
@ -100,7 +98,7 @@ public class GnssGroupController {
@PostMapping("/gnss/group/update_calc")
@ResponseBody
public String updateCalc(@RequestBody JSONObject object) throws Exception {
public String updateCalc(@RequestBody JSONObject object) {
int num = 0;
GnssGroupCalc group = JSONObject.toJavaObject(object,GnssGroupCalc.class);
if(null != gnssGroupCalcMapper.selectById(group.getId())) {
@ -116,7 +114,7 @@ public class GnssGroupController {
@PostMapping("/gnss/group/delete_calc")
@ResponseBody
public String deleteCalc(@RequestParam int del_id) throws Exception {
public String deleteCalc(@RequestParam int del_id) {
int num = gnssGroupCalcMapper.deleteById(del_id);
if (num == 0) {
return HttpResult.failed();
@ -140,7 +138,7 @@ public class GnssGroupController {
@PostMapping("/gnss/group/update_fwd")
@ResponseBody
public String updateFwd(@RequestBody JSONObject object) throws Exception {
public String updateFwd(@RequestBody JSONObject object) {
int num = 0;
GnssGroupFwd group = JSONObject.toJavaObject(object,GnssGroupFwd.class);
if(null != gnssGroupFwdMapper.selectById(group.getId())) {
@ -156,7 +154,7 @@ public class GnssGroupController {
@PostMapping("/gnss/group/delete_fwd")
@ResponseBody
public String deleteFwd(@RequestParam int del_id) throws Exception {
public String deleteFwd(@RequestParam int del_id) {
int num = gnssGroupFwdMapper.deleteById(del_id);
if (num == 0) {
return HttpResult.failed();

View File

@ -1,10 +1,11 @@
package com.imdroid.beidou.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.query.MPJQueryWrapper;
import com.imdroid.secapi.dto.GnssStatus;
import com.imdroid.secapi.dto.GnssStatusJoin;
import com.imdroid.secapi.dto.GnssStatusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -21,7 +22,7 @@ public class GnssStatusController extends BasicController{
/**** 推送页面 *****/
@RequestMapping("/page/gnss_status")
public String gnssStatus(Model m, HttpSession session)throws Exception {
public String gnssStatus(Model m, HttpSession session) {
initModel(m, session);
return "/page/gnss_status";
@ -31,9 +32,13 @@ public class GnssStatusController extends BasicController{
/**** 推送数据 *****/
@RequestMapping("/gnss/status/list")
@ResponseBody
public JSONObject list(HttpSession session, int page, int limit, String searchParams) {
public JSONObject list(int page, int limit, String searchParams) {
Page<GnssStatus> pageable = new Page<>(page, limit);
QueryWrapper<GnssStatus> queryWrapper = new QueryWrapper<>();
MPJQueryWrapper queryWrapper = new MPJQueryWrapper<GnssStatus>()
.selectAll(GnssStatus.class)
.select("d.devicetype as devicetype","d.tenantid as tenantid")
.leftJoin("gnssdevices d on t.deviceid = d.deviceid");
// 条件查询
if(searchParams != null) {
@ -55,7 +60,8 @@ public class GnssStatusController extends BasicController{
}
}
IPage<GnssStatus> cs = gnssStatusMapper.selectPage(pageable, queryWrapper);
//分页查询 需要启用 mybatis plus 分页插件
IPage<GnssStatusJoin> cs = gnssStatusMapper.selectJoinPage(new Page<>(page, limit), GnssStatusJoin.class, queryWrapper);
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);

View File

@ -2,7 +2,7 @@ package com.imdroid.beidou.data.vo.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.imdroid.secapi.dto.GnssDevice;
import com.imdroid.secapi.dto.GnssStatus;
import com.imdroid.secapi.dto.GnssStatusJoin;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
@ -44,17 +44,17 @@ public class DeviceStatusVO {
private Integer rxbytes;
private Integer b562bytes;
private Integer d3xxbytes;
private Integer satelliteInView;
private Integer satelliteInUse;
private Integer satelliteinview;
private Integer satelliteinuse;
private Short dtuState;
private Short dtuState;
public DeviceStatusVO() {
}
public DeviceStatusVO(GnssDevice gnssDevice, GnssStatus gnssStatus) {
public DeviceStatusVO(GnssDevice gnssDevice, GnssStatusJoin gnssStatus) {
this.id = gnssDevice.getId();
this.deviceId = gnssDevice.getDeviceid();
this.name = gnssDevice.getName();
@ -75,8 +75,8 @@ public class DeviceStatusVO {
this.rxbytes = gnssStatus.getRxbytes();
this.d3xxbytes = gnssStatus.getD3xxbytes();
this.b562bytes = gnssStatus.getB562bytes();
this.satelliteInView = gnssStatus.getSatelliteinview();
this.satelliteInUse = gnssStatus.getSatelliteinuse();
this.satelliteinview = gnssStatus.getSatelliteinview();
this.satelliteinuse = gnssStatus.getSatelliteinuse();
this.dtuState = gnssStatus.getState();
}
}