Commit 1115ec57 authored by zengtianlai3's avatar zengtianlai3

Merge branch 'm33' into 'master'

删除License相关内容和修改部分文件

See merge request !21
parents e216ecce f0ebda73
......@@ -2,16 +2,9 @@ package iot.sixiang.license.auth;
import iot.sixiang.license.device.DeviceManager;
import iot.sixiang.license.entity.Apply;
import iot.sixiang.license.entity.Device;
import iot.sixiang.license.entity.License;
import iot.sixiang.license.entity.User;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.vo.AppVo;
import iot.sixiang.license.model.vo.DeviceVo;
import iot.sixiang.license.service.ApplyService;
import iot.sixiang.license.service.DeviceService;
import iot.sixiang.license.service.LicenseService;
import iot.sixiang.license.service.UserService;
import iot.sixiang.license.util.HmacUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -25,8 +18,6 @@ import java.util.Map;
@Component
@Slf4j
public class AuthManager {
@Autowired
private UserService userService;
@Autowired
private ApplyService applyService;
@Autowired
......@@ -35,7 +26,7 @@ public class AuthManager {
private Map<String, Apply> allApply = null;
public AuthManager() {
allApply = new HashMap<String, Apply>();
allApply = new HashMap<>();
}
@PostConstruct
......
package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.entity.License;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.service.LicenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-06
*/
@RestController
@RequestMapping("/iot_license/license")
public class LicenseController {
@Autowired
private LicenseService licenseService;
/**
* 添加license
* @param jsonObject
* @return
*/
@PostMapping("add")
public BaseResult addLicense(@RequestBody JSONObject jsonObject){
String appId = jsonObject.getString("appId");
String appKey = jsonObject.getString("appKey");
String userId = jsonObject.getString("userId");
boolean res = licenseService.addLicense(appId,appKey,userId);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 删除license
* @param appId
* @return
*/
@PostMapping("delete")
public BaseResult deleteLicense(@RequestParam(value = "appId", defaultValue = "0") String appId) {
boolean res = licenseService.deleteLicense(appId);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 修改license
* @param jsonObject
* @return
*/
@PostMapping("update")
public BaseResult updateLicense(@RequestBody JSONObject jsonObject){
String appId = jsonObject.getString("appId");
String appKey = jsonObject.getString("appKey");
String userId = jsonObject.getString("userId");
boolean res = licenseService.updateLicense(appId,appKey,userId);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
/**
* 分页查询所有的license
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("list")
public ResResult getLicenseList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize) {
List<License> records = licenseService.getLicenseList(pageNo,pageSize);
return ResResult.success().record(records);
}
}
......@@ -28,6 +28,6 @@ public class Device implements Serializable {
private String sn;
private Integer applyId;
private Integer appId;
}
package iot.sixiang.license.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author m33
* @since 2022-06-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class License implements Serializable {
private static final long serialVersionUID = 1L;
private String appId;
private String appKey;
private Integer userId;
}
......@@ -38,7 +38,7 @@ public class OperateSAMStatusResponseEventHandler {
int samCount = samInfoList.size();
int onlineCount = 0;
for (SamInfo samInfo : samInfoList) {
if (samInfo.getStatus() == 0 || samInfo.getStatus() == 1 || samInfo.getStatus() == 2 || samInfo.getStatus() == 4) {
if (samInfo.getStatus() == 2 || samInfo.getStatus() == 4) {
onlineCount++;
} else {
int index = samInfo.getIndex();
......
package iot.sixiang.license.mapper;
import iot.sixiang.license.entity.License;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author m33
* @since 2022-06-06
*/
public interface LicenseMapper extends BaseMapper<License> {
boolean deleteLicense(String appId);
boolean addLicense(String appId, String appKey, String userId);
boolean updateLicense(String appId, String appKey, String userId);
}
......@@ -30,17 +30,22 @@ public class TcpServer {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
//创建两个线程组 bossGroup、workerGroup
EventLoopGroup bossGroup = new NioEventLoopGroup(4);
EventLoopGroup workerGroup = new NioEventLoopGroup(4);
logger.debug("begin open the port:" + port);
try {
//创建服务端的启动对象,设置参数
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
//设置两个线程组boosGroup和workerGroup
b.group(bossGroup, workerGroup)
//设置服务端通道实现类型
.channel(NioServerSocketChannel.class)
// .handler(new LoggingHandler(LogLevel.INFO))
.childHandler(channelInitializer)
.option(ChannelOption.SO_BACKLOG, 1024) // 设置tcp缓冲区
// 设置tcp缓冲区
.option(ChannelOption.SO_BACKLOG, 1024)
//设置保持活动连接状态
.childOption(ChannelOption.SO_KEEPALIVE, true);
ChannelFuture f;
try {
......
......@@ -73,7 +73,6 @@ public class OperateManager {
Map.Entry<String, Server> next = iterator.next();
Server server = next.getValue();
//TODO 创建运维客户端去查询相关的运维消息
String serverIp = server.getServerIp();
Integer port = server.getPort();
this.startTcpClient(serverIp, port);
......
package iot.sixiang.license.service;
import com.baomidou.mybatisplus.extension.service.IService;
import iot.sixiang.license.entity.License;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-06
*/
public interface LicenseService extends IService<License> {
List<License> getLicenseList(int pageNo, int pageSize);
boolean deleteLicense(String appId);
boolean addLicense(String appId, String appKey, String userId);
boolean updateLicense(String appId, String appKey, String userId);
}
package iot.sixiang.license.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import iot.sixiang.license.entity.License;
import iot.sixiang.license.mapper.LicenseMapper;
import iot.sixiang.license.service.LicenseService;
import iot.sixiang.license.util.JsonUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-06
*/
@Service
public class LicenseServiceImpl extends ServiceImpl<LicenseMapper, License> implements LicenseService {
@Resource
LicenseMapper licenseMapper;
@Override
public List<License> getLicenseList(int pageNo, int pageSize) {
Page<License> page = new Page<>(pageNo,pageSize);
baseMapper.selectPage(page,null);
List<License> records = page.getRecords();
return records;
}
@Override
public boolean deleteLicense(String appId) {
if(JsonUtil.isNull(appId)) {
return false;
}
return licenseMapper.deleteLicense(appId);
}
@Override
public boolean addLicense(String appId, String appKey, String userId) {
if(JsonUtil.isNull(appId) || JsonUtil.isNull(appKey) || JsonUtil.isNull(userId)) {
return false;
}
return licenseMapper.addLicense(appId,appKey,userId);
}
@Override
public boolean updateLicense(String appId, String appKey, String userId) {
if(JsonUtil.isNull(appId) || JsonUtil.isNull(appKey) || JsonUtil.isNull(userId)) {
return false;
}
return licenseMapper.updateLicense(appId,appKey,userId);
}
}
......@@ -19,9 +19,9 @@ public class OperateSchedu {
@Scheduled(cron = "0 0 0/1 * * ?")
public void scheduled() {
operateManager.createProxyClient();
int count = operateManager.getCount();
monitorService.addMonitor(count);
operateManager.clearCount();
}
}
<?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="iot.sixiang.license.mapper.LicenseMapper">
<insert id="addLicense" parameterType="iot.sixiang.license.entity.License">
insert into license(app_id, app_key, user_id) values (#{appId},#{appKey},#{userId})
</insert>
<delete id="deleteLicense" parameterType="iot.sixiang.license.entity.License">
delete from license where app_id = #{appId}
</delete>
<update id="updateLicense" parameterType="iot.sixiang.license.entity.License">
update license set app_key = #{appKey} , user_id = #{userId} where app_id = #{appId}
</update>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment