Commit fc99621e authored by AfirSraftGarrier's avatar AfirSraftGarrier

修改

parent a8e382c2
......@@ -18,6 +18,7 @@ import iot.sixiang.license.model.vo.DeviceVo;
import iot.sixiang.license.service.DeviceBlackService;
import iot.sixiang.license.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -43,22 +44,25 @@ public class DeviceController {
@Autowired
private DeviceBlackService deviceBlackService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"adminCome"});
}
/**
* 添加device
*
* @param jsonObject
* @return
*/
@ApiOperation(value = "添加设备接口", notes = "用于添加设备")
@PostMapping("add")
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "appId",value = "应用Id",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "count",value = "需要创建的设备数量",required = true,dataTypeClass = Integer.class),
}))
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {@DynamicParameter(name = "appId", value = "应用Id", required = true, dataTypeClass = String.class), @DynamicParameter(name = "count", value = "需要创建的设备数量", required = true, dataTypeClass = Integer.class),}))
@MyLog(title = "添加设备", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
public BaseResult addDevice(@RequestBody JSONObject jsonObject) {
String appId = jsonObject.getString("appId");
int count = jsonObject.getIntValue("count");
boolean res = deviceService.addDevice(appId,count);
boolean res = deviceService.addDevice(appId, count);
if (res) {
return BaseResult.success();
} else {
......@@ -68,6 +72,7 @@ public class DeviceController {
/**
* 可按条件分页查询所有的设备
*
* @param pageNo
* @param pageSize
* @param appName
......@@ -77,40 +82,24 @@ public class DeviceController {
@ApiOperation(value = "获取设备列表接口", notes = "用于获取设备列表")
@GetMapping("list")
@MyLog(title = "获取设备列表", optParam = "#{pageNo},#{pageSize},#{appName},#{userName}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true, dataType="int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType="int"),
@ApiImplicitParam(name = "appName",value = "应用名"),
@ApiImplicitParam(name = "userName",value = "用户名")
})
public PageResult<DeviceVo> getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName",required = false) String appName,
@RequestParam(value = "userName",required = false) String userName) {
PageInfoModel<DeviceVo> records = deviceService.getDeviceList(pageNo,pageSize,appName,userName);
@ApiImplicitParams({@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页显示多少页", required = true, dataType = "int"), @ApiImplicitParam(name = "appName", value = "应用名"), @ApiImplicitParam(name = "userName", value = "用户名")})
public PageResult<DeviceVo> getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize, @RequestParam(value = "appName", required = false) String appName, @RequestParam(value = "userName", required = false) String userName) {
PageInfoModel<DeviceVo> records = deviceService.getDeviceList(pageNo, pageSize, appName, userName);
int total = records.getTotal();
int pages = total/pageSize;//pages为总页数
int mod = total%pageSize;
if(mod!=0){
pages = pages +1;
int pages = total / pageSize;//pages为总页数
int mod = total % pageSize;
if (mod != 0) {
pages = pages + 1;
}
List<DeviceVo> pageResult = records.getResult();
return new PageResult(200,"查找成功",pageNo,pages,total,pageResult);
return new PageResult(200, "查找成功", pageNo, pages, total, pageResult);
}
@ApiOperation(value = "获取设备详细信息接口", notes = "用于获取设备详细信息列表")
@GetMapping("detail/list")
@MyLog(title = "获取设备详细信息接口", optParam = "#{pageNo},#{pageSize},#{appName},#{userName}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示多少条", required = true, dataType = "int"),
@ApiImplicitParam(name = "appName", value = "应用名"),
@ApiImplicitParam(name = "userName", value = "用户名")
})
public PageResult<DeviceDetailVo> getDeviceDetailList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName", required = false) String appName,
@RequestParam(value = "userName", required = false) String userName) {
@ApiImplicitParams({@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页显示多少条", required = true, dataType = "int"), @ApiImplicitParam(name = "appName", value = "应用名"), @ApiImplicitParam(name = "userName", value = "用户名")})
public PageResult<DeviceDetailVo> getDeviceDetailList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize, @RequestParam(value = "appName", required = false) String appName, @RequestParam(value = "userName", required = false) String userName) {
PageInfoModel<DeviceDetailVo> records = deviceManager.getDeviceDetailList(pageNo, pageSize, appName, userName);
int total = records.getTotal();
......@@ -125,14 +114,13 @@ public class DeviceController {
/**
* 添加device_black
*
* @param jsonObject
* @return
*/
@ApiOperation(value = "添加设备黑名单接口", notes = "用于添加设备黑名单")
@PostMapping("device_black/add")
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "deviceId",value = "设备Id",required = true,dataTypeClass = Integer.class)
}))
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {@DynamicParameter(name = "deviceId", value = "设备Id", required = true, dataTypeClass = Integer.class)}))
@MyLog(title = "添加设备黑名单", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
public BaseResult addDeviceBlack(@RequestBody JSONObject jsonObject) {
int deviceId = jsonObject.getIntValue("deviceId");
......@@ -146,14 +134,13 @@ public class DeviceController {
/**
* 删除device_black
*
* @param jsonObject
* @return
*/
@ApiOperation(value = "设备黑名单删除接口", notes = "删除设备黑名单")
@PostMapping("device_black/delete")
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "deviceId",value = "设备Id",required = true,dataTypeClass = Integer.class)
}))
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {@DynamicParameter(name = "deviceId", value = "设备Id", required = true, dataTypeClass = Integer.class)}))
@MyLog(title = "删除设备黑名单", optParam = "#{deviceId}", businessType = BusinessType.DELETE)
public BaseResult deleteDeviceBlack(@RequestBody JSONObject jsonObject) {
int deviceId = jsonObject.getIntValue("deviceId");
......@@ -167,6 +154,7 @@ public class DeviceController {
/**
* 分页查询所有黑名单设备
*
* @param pageNo
* @param pageSize
* @return
......@@ -174,20 +162,17 @@ public class DeviceController {
@ApiOperation(value = "获取设备黑名单列表接口", notes = "用于获取设备黑名单列表")
@GetMapping("device_black/list")
@MyLog(title = "获取设备黑名单列表", optParam = "#{pageNo},#{pageSize}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true, dataType="int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType="int")
})
public PageResult<DeviceBlack> getDeviceBlackList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize){
PageInfoModel<DeviceBlack> records = deviceBlackService.getDeviceBlackList(pageNo,pageSize);
@ApiImplicitParams({@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页显示多少页", required = true, dataType = "int")})
public PageResult<DeviceBlack> getDeviceBlackList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize) {
PageInfoModel<DeviceBlack> records = deviceBlackService.getDeviceBlackList(pageNo, pageSize);
int total = records.getTotal();
int pages = total/pageSize;//pages为总页数
int mod = total%pageSize;
if(mod!=0){
pages = pages +1;
int pages = total / pageSize;//pages为总页数
int mod = total % pageSize;
if (mod != 0) {
pages = pages + 1;
}
List<DeviceBlack> pageResult = records.getResult();
return new PageResult(200,"查找成功",pageNo,pages,total,pageResult);
return new PageResult(200, "查找成功", pageNo, pages, total, pageResult);
}
}
......@@ -28,6 +28,7 @@ import iot.sixiang.license.service.ServerService;
import lombok.extern.slf4j.Slf4j;
import org.owasp.esapi.ESAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
......@@ -56,6 +57,11 @@ public class OperateController {
@Autowired
HttpServletResponse response;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"adminCome"});
}
@ApiOperation(value = "服务接口", notes = "用于获取服务列表")
@GetMapping("monitor/server")
@MyLog(title = "获取服务列表", businessType = BusinessType.SELECT)
......@@ -95,7 +101,7 @@ public class OperateController {
@GetMapping("alarm/list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult<List<AlarmVo>> getAlarmList() {
response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
response.setHeader("Set-Cookie", "cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
String user = UserUtils.getLoginUserId();
int userI = Integer.valueOf(user);
List<AlarmVo> alarmList = alarmService.getAlarmList(userI);
......
......@@ -18,6 +18,7 @@ import iot.sixiang.license.model.vo.UserVo;
import iot.sixiang.license.service.UserService;
import iot.sixiang.license.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -38,17 +39,23 @@ public class UserController {
@Autowired
private UserService userService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"adminCome"});
}
/**
* 添加user
*
* @param jsonObject
* @return
*/
@ApiOperation(value = "用户添加接口", notes = "用于添加用户")
@PostMapping("add")
@MyLog(title = "添加用户", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "userName",value = "账户名",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "company",value = "公司名",required = true,dataTypeClass = String.class)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter(name = "userName", value = "账户名", required = true, dataTypeClass = String.class),
@DynamicParameter(name = "company", value = "公司名", required = true, dataTypeClass = String.class)
}))
public BaseResult addUser(@RequestBody JSONObject jsonObject) {
String userName = (String) jsonObject.get("userName");
......@@ -64,6 +71,7 @@ public class UserController {
/**
* 删除user
*
* @param userId
* @return
*/
......@@ -81,15 +89,16 @@ public class UserController {
/**
* 修改user
*
* @param jsonObject
* @return
*/
@ApiOperation(value = "用户修改接口", notes = "修改用户")
@PostMapping("update")
@MyLog(title = "修改用户", optParam = "#{userId},#{password}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "userId",value = "用户Id",required = true,dataTypeClass = Integer.class),
@DynamicParameter(name = "password",value = "密码",required = true,dataTypeClass = String.class)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter(name = "userId", value = "用户Id", required = true, dataTypeClass = Integer.class),
@DynamicParameter(name = "password", value = "密码", required = true, dataTypeClass = String.class)
}))
public BaseResult updateUser(@RequestBody JSONObject jsonObject) {
int userId = jsonObject.getInteger("userId");
......@@ -105,6 +114,7 @@ public class UserController {
/**
* 分页查询所有的user
*
* @param pageNo
* @param pageSize
* @return
......@@ -113,24 +123,24 @@ public class UserController {
@GetMapping("list")
@MyLog(title = "获取用户列表", optParam = "#{pageNo},#{pageSize},#{userName},#{company}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少条", required = true, dataType = "int"),
@ApiImplicitParam(name = "userName",value = "用户名"),
@ApiImplicitParam(name = "company",value = "公司名")
@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示多少条", required = true, dataType = "int"),
@ApiImplicitParam(name = "userName", value = "用户名"),
@ApiImplicitParam(name = "company", value = "公司名")
})
public PageResult<UserVo> getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "0") int pageSize,
@RequestParam(value = "userName",required = false) String userName,
@RequestParam(value = "company",required = false) String company) {
PageInfoModel<UserVo> records = userService.getUserList(pageNo,pageSize,userName,company);
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "company", required = false) String company) {
PageInfoModel<UserVo> records = userService.getUserList(pageNo, pageSize, userName, company);
int total = records.getTotal();
int pages = total/pageSize;//pages为总页数
int mod = total%pageSize;
if(mod!=0){
int pages = total / pageSize;//pages为总页数
int mod = total % pageSize;
if (mod != 0) {
pages = pages + 1;
}
List<UserVo> result = records.getResult();
return new PageResult(200,"查找成功",pageNo,pages,total,result);
return new PageResult(200, "查找成功", pageNo, pages, total, result);
}
}
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