Skip to content

Commit

Permalink
mybatisplus升级3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwei committed Mar 17, 2020
1 parent b412b74 commit 14bd6e3
Show file tree
Hide file tree
Showing 60 changed files with 708 additions and 171 deletions.
2 changes: 1 addition & 1 deletion bullet-codemaker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<junit.version>4.12</junit.version>
<druid.version>1.1.0</druid.version>
<fastjson.version>1.2.8</fastjson.version>
<mybaitsplus.version>3.1.1</mybaitsplus.version>
<mybaitsplus.version>3.3.1</mybaitsplus.version>
<mysql.version>5.1.38</mysql.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.19</slf4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void main(String[] args) {


/** 包路径 */
final String basePackage = "com.wuweibi.bullet.entity";
final String basePackage = "com.wuweibi.bullet";
final String moduleName = "";

/** 开发者 */
Expand Down
18 changes: 8 additions & 10 deletions bullet-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<mybaitsplus.version>2.1.4</mybaitsplus.version>
<mybaitsplus.version>3.3.1</mybaitsplus.version>
<aspectjweaver.version>1.8.8</aspectjweaver.version>
<mysql.version>5.1.38</mysql.version>

Expand Down Expand Up @@ -73,17 +73,15 @@




<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatisplus-spring-boot-starter</artifactId>
<version>1.0.5</version>
<exclusions>
<exclusion>
<artifactId>HikariCP</artifactId>
<groupId>com.zaxxer</groupId>
</exclusion>
</exclusions>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1.tmp</version>
</dependency>



<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
Expand Down Expand Up @@ -187,7 +185,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.2</version>
<version>1.1.21</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class OrderPayBizImpl implements OrderPayBiz {

@Override
public Result calculate(Long domainId, Integer time) {
Domain domain = domainService.selectById(domainId);
Domain domain = domainService.getById(domainId);
// 校验域名是否存在
if(domain == null){
return Result.fail(SystemErrorType.DOMAIN_NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.wuweibi.bullet.common.domain;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
* Created by marker on 2018/3/7.
*/

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
* Mybatis MapperConfig
*
* @author marker
* @create 2018-03-07 下午1:58
**/
@Configuration
@MapperScan({
"com.wuweibi.bullet.mapper*",
"com.wuweibi.bullet.oauth2.dao*",
@MapperScan(basePackages={
"com.wuweibi.bullet.mapper",
"com.wuweibi.bullet.oauth2.dao",
})
public class MapperConfig {

@Resource
private DataSource dataSource;

/**
* mybatis-plus分页插件
*/
Expand All @@ -31,4 +37,12 @@ public PaginationInterceptor paginationInterceptor() {
return page;
}

// @Bean
// public MybatisSqlSessionFactoryBean newMybatisSqlSessionFactoryBean(){
// MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
// sqlSessionFactory.setDataSource(dataSource);
// return sqlSessionFactory;
// }


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wuweibi.bullet.annotation.JwtUser;
import com.wuweibi.bullet.core.builder.MapBuilder;
import com.wuweibi.bullet.conn.CoonPool;
Expand Down Expand Up @@ -71,7 +71,7 @@ public Object device(@JwtUser Session session){

Long userId = session.getUserId();

List<Device> list =deviceService.selectByMap(newMap(1)
List<Device> list =deviceService.listByMap(newMap(1)
.setParam("userId", userId)
.build());

Expand Down Expand Up @@ -138,11 +138,11 @@ public Object save(@JwtUser Session session,
// 校验设备是否是他的
boolean status = deviceService.exists(userId, id);
if(status){
Device device = deviceService.selectById(id);
Device device = deviceService.getById(id);

// 删除映射
deviceMappingService.deleteByDeviceId(id);
deviceService.deleteById(id);
deviceService.removeById(id);

try {
// 停止ws链接
Expand Down Expand Up @@ -171,13 +171,13 @@ public Result validate(@JwtUser Session session, String deviceId, HttpServletRe
return Result.fail(SystemErrorType.DEVICE_INPUT_NUMBER);
}


EntityWrapper ew = new EntityWrapper();
ew.setEntity(new DeviceOnline());
ew.where("deviceNo = {0}", deviceId).andNew("status = {0}", 1).orderBy("updateTime", false);
QueryWrapper wrapper2 = new QueryWrapper();
wrapper2.eq("deviceNo", deviceId);
wrapper2.eq("status", 1);
wrapper2.orderByDesc("updateTime");

// 验证是否存在
DeviceOnline deviceOnline = deviceOnlineService.selectOne(ew);
DeviceOnline deviceOnline = deviceOnlineService.getOne(wrapper2);
if(deviceOnline != null){
// 验证是否绑定
boolean isBinded = deviceService.existsDevice(deviceId);
Expand All @@ -194,7 +194,7 @@ public Result validate(@JwtUser Session session, String deviceId, HttpServletRe
device.setMacAddr(deviceOnline.getMacAddr());
device.setIntranetIp(deviceOnline.getIntranetIp());

deviceService.insert(device);
deviceService.save(device);

return Result.success();
}
Expand Down Expand Up @@ -233,7 +233,7 @@ public Object device(HttpServletRequest request, @RequestParam Long deviceId,
MapBuilder mapBuilder = newMap(3);

// 设备信息
Device device = deviceService.selectById(deviceId);
Device device = deviceService.getById(deviceId);
DeviceOnline deviceOnline = deviceOnlineService.selectByDeviceNo(device.getDeviceNo());
JSONObject deviceInfo = (JSONObject) JSON.toJSON(device);

Expand All @@ -244,13 +244,21 @@ public Object device(HttpServletRequest request, @RequestParam Long deviceId,
deviceInfo.put("status", -1);
}

EntityWrapper<DeviceMapping> entityWrapper = new EntityWrapper();
entityWrapper.where("userId={0} and device_id={1} and protocol=2", userId, deviceId);
List<DeviceMapping> portList = deviceMappingService.selectList(entityWrapper);

entityWrapper = new EntityWrapper();
entityWrapper.where("userId={0} and device_id={1} and protocol!=2", userId, deviceId);
List<DeviceMapping> domainList = deviceMappingService.selectList(entityWrapper);
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("userId", userId);
wrapper.eq("device_id", deviceId);
wrapper.eq("protocol", 2);

List<DeviceMapping> portList = deviceMappingService.list(wrapper);


QueryWrapper wrapper2 = new QueryWrapper();
wrapper2.eq("userId", userId);
wrapper2.eq("device_id", deviceId);
wrapper2.ne("protocol", 2);

List<DeviceMapping> domainList = deviceMappingService.list(wrapper2);


mapBuilder.setParam("deviceInfo", deviceInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public Object delete(@JwtUser Session session, @RequestParam Long id){
boolean status = deviceMappingService.exists(userId, id);
if(status){

DeviceMapping entity = deviceMappingService.selectById(id);
deviceMappingService.deleteById(id);
DeviceMapping entity = deviceMappingService.getById(id);
deviceMappingService.removeById(id);

String deviceNo = deviceMappingService.getDeviceNo(entity.getDeviceId());
if(!org.apache.commons.lang3.StringUtils.isBlank(deviceNo)){
Expand Down Expand Up @@ -99,7 +99,7 @@ public Object delete(@JwtUser Session session, @RequestParam Long id){
@RequestMapping(value = "/", method = RequestMethod.GET)
public Object device(@JwtUser Session session,@RequestParam Long deviceId){
Long userId = session.getUserId();
return MessageFactory.get(deviceMappingService.selectByMap(newMap(2)
return MessageFactory.get(deviceMappingService.listByMap(newMap(2)
.setParam("userId", userId)
.setParam("device_id", deviceId)
.build()));
Expand All @@ -116,7 +116,7 @@ public Result save(@JwtUser Session session, DeviceMapping entity ){
Long userId = session.getUserId();
entity.setUserId(userId);

DeviceMapping deviceMapping = deviceMappingService.selectById(entity.getId());
DeviceMapping deviceMapping = deviceMappingService.getById(entity.getId());
entity.setDomainId(deviceMapping.getDomainId());

// 验证设备映射是自己的
Expand All @@ -134,7 +134,7 @@ public Result save(@JwtUser Session session, DeviceMapping entity ){
return Result.fail(SystemErrorType.DOMAIN_IS_OTHER_BIND);
}

status = deviceMappingService.insert(entity);
status = deviceMappingService.save(entity);
}
if(status){
// 发送绑定数据
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,34 @@
* Created by marker on 2017/12/6.
*/

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.wuweibi.bullet.annotation.JwtUser;
import com.wuweibi.bullet.business.OrderPayBiz;
import com.wuweibi.bullet.conn.CoonPool;
import com.wuweibi.bullet.domain.domain.session.Session;
import com.wuweibi.bullet.domain.message.MessageFactory;
import com.wuweibi.bullet.business.OrderPayBiz;
import com.wuweibi.bullet.entity.Device;
import com.wuweibi.bullet.entity.DeviceMapping;
import com.wuweibi.bullet.entity.Domain;
import com.wuweibi.bullet.entity.api.Result;
import com.wuweibi.bullet.exception.type.AuthErrorType;
import com.wuweibi.bullet.exception.type.SystemErrorType;
import com.wuweibi.bullet.protocol.MsgUnMapping;
import com.wuweibi.bullet.service.DeviceMappingService;
import com.wuweibi.bullet.service.DeviceOnlineService;
import com.wuweibi.bullet.service.DeviceService;
import com.wuweibi.bullet.service.DomainService;
import com.wuweibi.bullet.websocket.BulletAnnotation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.*;

import static com.wuweibi.bullet.utils.SessionHelper.getUserId;
import java.util.Date;
import java.util.List;

/**
*
Expand Down Expand Up @@ -103,7 +98,7 @@ public Object getInfo(@JwtUser Session session, @RequestParam Long domainId){
if(!domainService.checkDomain(userId, domainId)){
return Result.fail(SystemErrorType.DOMAIN_NOT_FOUND);
}
Domain domain = domainService.selectById(domainId);
Domain domain = domainService.getById(domainId);

return Result.success(domain);
}
Expand Down Expand Up @@ -224,8 +219,8 @@ public Object getInfo(@JwtUser Session session,
}

// 执行绑定
Domain domainInfo = domainService.selectById(domainId);
Device deviceInfo = deviceService.selectById(deviceId);
Domain domainInfo = domainService.getById(domainId);
Device deviceInfo = deviceService.getById(deviceId);

DeviceMapping mapping = new DeviceMapping();
mapping.setDomain(domainInfo.getDomain());
Expand All @@ -240,7 +235,7 @@ public Object getInfo(@JwtUser Session session,
mapping.setDomain(domainInfo.getDomain());
mapping.setProtocol(DeviceMapping.PROTOCOL_HTTP);
}
deviceMappingService.insert(mapping);
deviceMappingService.save(mapping);
return Result.success();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.wuweibi.bullet.controller;


import com.wuweibi.bullet.annotation.JwtUser;
import com.wuweibi.bullet.domain.domain.session.Session;
import com.wuweibi.bullet.entity.SysMenu;
import com.wuweibi.bullet.entity.api.Result;
import com.wuweibi.bullet.service.ISysMenuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
* <p>
* 菜单表 前端控制器
* </p>
*
* @author marker
* @since 2020-03-16
*/
@RestController
@RequestMapping("/api/menu")
public class SysMenuController {

@Resource
private ISysMenuService sysMenuService;


/**
* 获取用户的一级菜单
* (系统主界面菜单使用该接口)
*/
@GetMapping("/list/one")
public Object listOneLevel(@JwtUser Session session) {
Long userId = session.getUserId();
List<SysMenu> list = sysMenuService.getOneLevel(userId);
return Result.success(list);
}


/**
* 获取二级以后的菜单
*
* (系统主界面菜单使用该接口)
*
* @return
*/
@GetMapping("/list/secondary")
public Object listSecondaryLevel(@JwtUser Session session, @RequestParam Long pid) {
Long userId = session.getUserId();
List<SysMenu> list = sysMenuService.getSecondaryLevel(userId, pid);
return Result.success(list);
}
}
Loading

0 comments on commit 14bd6e3

Please sign in to comment.