增加操作日志功能
This commit is contained in:
parent
99a12486b5
commit
55a9417cf6
@ -48,7 +48,4 @@ public class GnssDevice {
|
|||||||
private Double iposn; //初始位置
|
private Double iposn; //初始位置
|
||||||
private Double iposd; //初始位置
|
private Double iposd; //初始位置
|
||||||
|
|
||||||
public String getObjectName(){
|
|
||||||
return "gnssdevice";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.imdroid.secapi.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户配置,一个用户由name(手机号)唯一确定
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface OpLogMapper extends BaseMapper<OperationLog> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.imdroid.secapi.dto;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
//member name must be same as the field name in mysql
|
||||||
|
@Data
|
||||||
|
@TableName(value = "OperationLog")
|
||||||
|
public class OperationLog {
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
@ExcelIgnore
|
||||||
|
Long id;
|
||||||
|
@ExcelProperty("用户名")
|
||||||
|
String user_name;
|
||||||
|
@ExcelProperty("租户id")
|
||||||
|
Integer tenantid;
|
||||||
|
@ExcelProperty("时间")
|
||||||
|
Timestamp op_time;
|
||||||
|
@ExcelProperty("类型")
|
||||||
|
Short op_type;
|
||||||
|
@ExcelProperty("对象")
|
||||||
|
Short op_object;
|
||||||
|
@ExcelProperty("内容")
|
||||||
|
String content;
|
||||||
|
}
|
||||||
@ -26,4 +26,8 @@ public class BasicController {
|
|||||||
public Integer getTenantId(HttpSession session){
|
public Integer getTenantId(HttpSession session){
|
||||||
return (Integer) session.getAttribute(SessionUtils.SESSION_TENANT_ID);
|
return (Integer) session.getAttribute(SessionUtils.SESSION_TENANT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLoginUser(HttpSession session){
|
||||||
|
return (String) session.getAttribute(SessionUtils.SESSION_CURRENT_USER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.imdroid.beidou.common.HttpResult;
|
import com.imdroid.beidou.common.HttpResult;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
import com.imdroid.secapi.client.HttpResp;
|
import com.imdroid.secapi.client.HttpResp;
|
||||||
import com.imdroid.secapi.client.RtcmClient;
|
import com.imdroid.secapi.client.RtcmClient;
|
||||||
import com.imdroid.secapi.dto.*;
|
import com.imdroid.secapi.dto.*;
|
||||||
@ -29,6 +30,8 @@ public class CmdLineController extends BasicController{
|
|||||||
DeviceCmdMapper deviceCmdMapper;
|
DeviceCmdMapper deviceCmdMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
DeviceCacheCmdMapper cacheCmdMapper;
|
DeviceCacheCmdMapper cacheCmdMapper;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
|
|
||||||
/**** 推送页面 *****/
|
/**** 推送页面 *****/
|
||||||
@RequestMapping("/page/cmd_line")
|
@RequestMapping("/page/cmd_line")
|
||||||
@ -98,6 +101,10 @@ public class CmdLineController extends BasicController{
|
|||||||
gnssMsg.setContent(cmd);
|
gnssMsg.setContent(cmd);
|
||||||
msgMapper.insert(gnssMsg);
|
msgMapper.insert(gnssMsg);
|
||||||
|
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_CMD,OpLogManager.OP_OBJ_DEVICE,
|
||||||
|
deviceId + ": " + cmd);
|
||||||
|
|
||||||
return HttpResult.success(txInfo);
|
return HttpResult.success(txInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +144,13 @@ public class CmdLineController extends BasicController{
|
|||||||
cacheCmd.setMsgtype(msgType);
|
cacheCmd.setMsgtype(msgType);
|
||||||
cacheCmdMapper.insert(cacheCmd);
|
cacheCmdMapper.insert(cacheCmd);
|
||||||
|
|
||||||
|
if(cmd.length() >= 100) {
|
||||||
|
cmd = cmd.substring(0, 100)+"...";
|
||||||
|
}
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_CMD,OpLogManager.OP_OBJ_DEVICE,
|
||||||
|
deviceId + " cache cmd: " + cmd);
|
||||||
|
|
||||||
return HttpResult.success("OK");
|
return HttpResult.success("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,9 @@ package com.imdroid.beidou.controller;
|
|||||||
import com.imdroid.beidou.common.Role;
|
import com.imdroid.beidou.common.Role;
|
||||||
import com.imdroid.beidou.entity.TenantMapper;
|
import com.imdroid.beidou.entity.TenantMapper;
|
||||||
import com.imdroid.beidou.entity.Tenant;
|
import com.imdroid.beidou.entity.Tenant;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
import com.imdroid.common.util.NumberUtils;
|
import com.imdroid.common.util.NumberUtils;
|
||||||
|
import com.imdroid.common.util.ObjUtil;
|
||||||
import com.imdroid.secapi.client.RtcmClient;
|
import com.imdroid.secapi.client.RtcmClient;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
@ -45,6 +47,8 @@ public class GnssDeviceController extends BasicController{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RtcmClient rtcmClient;
|
RtcmClient rtcmClient;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
|
|
||||||
/**** 推送页面 *****/
|
/**** 推送页面 *****/
|
||||||
@RequestMapping("/page/gnss_dev_cfg")
|
@RequestMapping("/page/gnss_dev_cfg")
|
||||||
@ -167,6 +171,15 @@ public class GnssDeviceController extends BasicController{
|
|||||||
device.setId(old_device.getId());
|
device.setId(old_device.getId());
|
||||||
device.setCreateuser(old_device.getCreateuser());
|
device.setCreateuser(old_device.getCreateuser());
|
||||||
device.setCreatetime(old_device.getCreatetime());
|
device.setCreatetime(old_device.getCreatetime());
|
||||||
|
device.setUpdateuser(getLoginUser(session));
|
||||||
|
device.setUpdatetime(old_device.getUpdatetime());
|
||||||
|
device.setSyn(old_device.getSyn());
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_UPDATE,
|
||||||
|
OpLogManager.OP_OBJ_DEVICE,
|
||||||
|
device.getDeviceid()+" update: "+ObjUtil.compare(old_device,device));
|
||||||
|
|
||||||
|
device.setUpdatetime(LocalDateTime.now());
|
||||||
num = gnssDeviceMapper.updateById(device);
|
num = gnssDeviceMapper.updateById(device);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -174,7 +187,12 @@ public class GnssDeviceController extends BasicController{
|
|||||||
device.setCreateuser((String) session.getAttribute("login_user"));
|
device.setCreateuser((String) session.getAttribute("login_user"));
|
||||||
device.setSyn(false);
|
device.setSyn(false);
|
||||||
num = gnssDeviceMapper.insert(device); //id自增
|
num = gnssDeviceMapper.insert(device); //id自增
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_DEVICE,
|
||||||
|
device.getDeviceid() + " create new");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else {
|
} else {
|
||||||
@ -262,10 +280,14 @@ public class GnssDeviceController extends BasicController{
|
|||||||
|
|
||||||
@PostMapping("/gnss/device/delete")
|
@PostMapping("/gnss/device/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam String del_id) throws Exception {
|
public String delete(HttpSession session, @RequestParam String del_id) throws Exception {
|
||||||
QueryWrapper<GnssDevice> wrapper = new QueryWrapper<>();
|
QueryWrapper<GnssDevice> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("deviceid",del_id);
|
wrapper.eq("deviceid",del_id);
|
||||||
int num = gnssDeviceMapper.delete(wrapper);
|
int num = gnssDeviceMapper.delete(wrapper);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_DEL,
|
||||||
|
OpLogManager.OP_OBJ_DEVICE,
|
||||||
|
del_id + " deleted");
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.imdroid.beidou.common.HttpResult;
|
import com.imdroid.beidou.common.HttpResult;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
|
import com.imdroid.common.util.ObjUtil;
|
||||||
import com.imdroid.secapi.client.RtcmClient;
|
import com.imdroid.secapi.client.RtcmClient;
|
||||||
import com.imdroid.secapi.dto.*;
|
import com.imdroid.secapi.dto.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -23,6 +25,8 @@ public class GnssGroupController extends BasicController {
|
|||||||
GnssDeviceMapper deviceMapper;
|
GnssDeviceMapper deviceMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
RtcmClient rtcmClient;
|
RtcmClient rtcmClient;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
|
|
||||||
/********* 推送页面 *********/
|
/********* 推送页面 *********/
|
||||||
@RequestMapping("/page/table/gnss_add_group")
|
@RequestMapping("/page/table/gnss_add_group")
|
||||||
@ -60,7 +64,7 @@ public class GnssGroupController extends BasicController {
|
|||||||
|
|
||||||
@PostMapping("/gnss/group/update")
|
@PostMapping("/gnss/group/update")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String update(@RequestBody JSONObject object) throws Exception {
|
public String update(HttpSession session, @RequestBody JSONObject object) throws Exception {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
GnssGroup group = JSONObject.toJavaObject(object,GnssGroup.class);
|
GnssGroup group = JSONObject.toJavaObject(object,GnssGroup.class);
|
||||||
GnssGroup oldGroup = gnssGroupMapper.selectById(group.getId());
|
GnssGroup oldGroup = gnssGroupMapper.selectById(group.getId());
|
||||||
@ -69,10 +73,19 @@ public class GnssGroupController extends BasicController {
|
|||||||
//if(oldGroup != null && oldGroup.equals(group)) return HttpResult.ok();
|
//if(oldGroup != null && oldGroup.equals(group)) return HttpResult.ok();
|
||||||
|
|
||||||
if(null != oldGroup) {
|
if(null != oldGroup) {
|
||||||
|
group.setDevice_num(oldGroup.getDevice_num());
|
||||||
num = gnssGroupMapper.updateById(group);
|
num = gnssGroupMapper.updateById(group);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_UPDATE,
|
||||||
|
OpLogManager.OP_OBJ_GROUP,
|
||||||
|
group.getName()+" changed:"+ObjUtil.compare(oldGroup,group));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
num = gnssGroupMapper.insert(group);
|
num = gnssGroupMapper.insert(group);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_GROUP,
|
||||||
|
group.getName());
|
||||||
}
|
}
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
@ -85,7 +98,7 @@ public class GnssGroupController extends BasicController {
|
|||||||
|
|
||||||
@PostMapping("/gnss/group/delete")
|
@PostMapping("/gnss/group/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam int del_id) throws Exception {
|
public String delete(HttpSession session, @RequestParam int del_id) throws Exception {
|
||||||
GnssGroup group = gnssGroupMapper.selectById(del_id);
|
GnssGroup group = gnssGroupMapper.selectById(del_id);
|
||||||
if(group == null) return HttpResult.failed();
|
if(group == null) return HttpResult.failed();
|
||||||
|
|
||||||
@ -94,6 +107,10 @@ public class GnssGroupController extends BasicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num = gnssGroupMapper.deleteById(del_id);
|
int num = gnssGroupMapper.deleteById(del_id);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_DEL,
|
||||||
|
OpLogManager.OP_OBJ_GROUP,
|
||||||
|
group.getName());
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else return HttpResult.ok();
|
} else return HttpResult.ok();
|
||||||
@ -116,14 +133,24 @@ public class GnssGroupController extends BasicController {
|
|||||||
|
|
||||||
@PostMapping("/gnss/group/update_calc")
|
@PostMapping("/gnss/group/update_calc")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String updateCalc(@RequestBody JSONObject object) {
|
public String updateCalc(HttpSession session, @RequestBody JSONObject object) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
GnssGroupCalc group = JSONObject.toJavaObject(object,GnssGroupCalc.class);
|
GnssGroupCalc group = JSONObject.toJavaObject(object,GnssGroupCalc.class);
|
||||||
if(null != gnssGroupCalcMapper.selectById(group.getId())) {
|
GnssGroupCalc oldGroup = gnssGroupCalcMapper.selectById(group.getId());
|
||||||
|
if(null != oldGroup) {
|
||||||
|
group.setDevice_num(oldGroup.getDevice_num());
|
||||||
num = gnssGroupCalcMapper.updateById(group);
|
num = gnssGroupCalcMapper.updateById(group);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_UPDATE,
|
||||||
|
OpLogManager.OP_OBJ_GROUP,
|
||||||
|
group.getName()+" changed:"+ObjUtil.compare(oldGroup,group));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
num = gnssGroupCalcMapper.insert(group);
|
num = gnssGroupCalcMapper.insert(group);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_GROUP,
|
||||||
|
group.getName());
|
||||||
}
|
}
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
@ -135,7 +162,7 @@ public class GnssGroupController extends BasicController {
|
|||||||
|
|
||||||
@PostMapping("/gnss/group/delete_calc")
|
@PostMapping("/gnss/group/delete_calc")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String deleteCalc(@RequestParam int del_id) {
|
public String deleteCalc(HttpSession session, @RequestParam int del_id) {
|
||||||
GnssGroupCalc group = gnssGroupCalcMapper.selectById(del_id);
|
GnssGroupCalc group = gnssGroupCalcMapper.selectById(del_id);
|
||||||
if(group == null) return HttpResult.failed();
|
if(group == null) return HttpResult.failed();
|
||||||
|
|
||||||
@ -144,6 +171,10 @@ public class GnssGroupController extends BasicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num = gnssGroupCalcMapper.deleteById(del_id);
|
int num = gnssGroupCalcMapper.deleteById(del_id);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_DEL,
|
||||||
|
OpLogManager.OP_OBJ_GROUP,
|
||||||
|
group.getName());
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.imdroid.beidou.entity.Tenant;
|
|||||||
import com.imdroid.beidou.entity.TenantMapper;
|
import com.imdroid.beidou.entity.TenantMapper;
|
||||||
import com.imdroid.beidou.entity.User;
|
import com.imdroid.beidou.entity.User;
|
||||||
import com.imdroid.beidou.entity.UserMapper;
|
import com.imdroid.beidou.entity.UserMapper;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
import com.imdroid.beidou.utils.BCryptPasswordEncoderUtil;
|
import com.imdroid.beidou.utils.BCryptPasswordEncoderUtil;
|
||||||
import com.imdroid.beidou.utils.WXUtils;
|
import com.imdroid.beidou.utils.WXUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +42,8 @@ public class LoginController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BCryptPasswordEncoderUtil bCryptPasswordEncoderUtil;
|
private BCryptPasswordEncoderUtil bCryptPasswordEncoderUtil;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
@RequestMapping("/login")
|
@RequestMapping("/login")
|
||||||
public String login(){
|
public String login(){
|
||||||
return "/login";
|
return "/login";
|
||||||
@ -61,6 +64,10 @@ public class LoginController {
|
|||||||
}
|
}
|
||||||
Tenant tenant = tenantMapper.selectById(user.getTenantid());
|
Tenant tenant = tenantMapper.selectById(user.getTenantid());
|
||||||
SessionUtils.setCurrentUser(request, user, tenant);
|
SessionUtils.setCurrentUser(request, user, tenant);
|
||||||
|
opLogManager.addLog(user.getName(), user.getTenantid(),
|
||||||
|
OpLogManager.OP_TYPE_LOGIN,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
"login from wechat");
|
||||||
|
|
||||||
return HttpResult.success(buildMiniUser(user, tenant));
|
return HttpResult.success(buildMiniUser(user, tenant));
|
||||||
} else {
|
} else {
|
||||||
@ -74,6 +81,10 @@ public class LoginController {
|
|||||||
}
|
}
|
||||||
Tenant tenant = tenantMapper.selectById(user.getTenantid());
|
Tenant tenant = tenantMapper.selectById(user.getTenantid());
|
||||||
SessionUtils.setCurrentUser(request, user, tenant);
|
SessionUtils.setCurrentUser(request, user, tenant);
|
||||||
|
opLogManager.addLog(user.getName(), user.getTenantid(),
|
||||||
|
OpLogManager.OP_TYPE_LOGIN,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
"login from web");
|
||||||
//response.sendRedirect("/index"); //发这条没用,会导致login.html收不到应答,也跳转不了
|
//response.sendRedirect("/index"); //发这条没用,会导致login.html收不到应答,也跳转不了
|
||||||
return HttpResult.success(null);
|
return HttpResult.success(null);
|
||||||
}
|
}
|
||||||
@ -122,6 +133,13 @@ public class LoginController {
|
|||||||
|
|
||||||
@RequestMapping(value = "/do_logout")
|
@RequestMapping(value = "/do_logout")
|
||||||
public String logout(HttpServletRequest request) throws IOException {
|
public String logout(HttpServletRequest request) throws IOException {
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
opLogManager.addLog(
|
||||||
|
(String) session.getAttribute(SessionUtils.SESSION_CURRENT_USER),
|
||||||
|
(Integer) session.getAttribute(SessionUtils.SESSION_TENANT_ID),
|
||||||
|
OpLogManager.OP_TYPE_LOGOUT,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
"logout");
|
||||||
request.getSession().invalidate();
|
request.getSession().invalidate();
|
||||||
return "/login";
|
return "/login";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,80 @@
|
|||||||
|
package com.imdroid.beidou.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.imdroid.beidou.service.CommonExcelService;
|
||||||
|
import com.imdroid.secapi.dto.OpLogMapper;
|
||||||
|
import com.imdroid.secapi.dto.OperationLog;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息摘要 控制器
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class OpLogController extends BasicController implements CommonExcelService<OperationLog, OperationLog> {
|
||||||
|
|
||||||
|
private final OpLogMapper opLogMapper;
|
||||||
|
|
||||||
|
/**** 推送页面 *****/
|
||||||
|
@RequestMapping("/sys/oplog")
|
||||||
|
public String opLog(Model m, HttpSession session) {
|
||||||
|
initModel(m, session);
|
||||||
|
return "/page/operation_log";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**** 推送数据 *****/
|
||||||
|
@RequestMapping("/sys/list_oplog")
|
||||||
|
@ResponseBody
|
||||||
|
public JSONObject listLog(HttpSession session, Integer page, Integer limit, String searchParams) {
|
||||||
|
return this.pageList(session, page, limit, searchParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param session HttpSession
|
||||||
|
* @param request HttpServletRequest
|
||||||
|
* @param response HttpServletResponse
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping("/sys/oplog/export")
|
||||||
|
@ResponseBody
|
||||||
|
public void exportData(HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
this.export(session, request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取实体类的class
|
||||||
|
*
|
||||||
|
* @return 实体类的class
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Class<OperationLog> getEntityClass() {
|
||||||
|
return OperationLog.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取实体类对应的mybatis mapper
|
||||||
|
*
|
||||||
|
* @return 实体类对应的mybatis mapper
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BaseMapper<OperationLog> getMapper() {
|
||||||
|
return opLogMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOrderByColumn() {
|
||||||
|
return "op_time";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.imdroid.beidou.common.HttpResult;
|
import com.imdroid.beidou.common.HttpResult;
|
||||||
import com.imdroid.beidou.entity.Tenant;
|
import com.imdroid.beidou.entity.Tenant;
|
||||||
import com.imdroid.beidou.entity.TenantMapper;
|
import com.imdroid.beidou.entity.TenantMapper;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
|
import com.imdroid.common.util.ObjUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
@ -14,14 +16,13 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class TenantController extends BasicController{
|
public class TenantController extends BasicController{
|
||||||
@Autowired
|
@Autowired
|
||||||
TenantMapper tenantMapper;
|
TenantMapper tenantMapper;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
/**** 推送页面 *****/
|
/**** 推送页面 *****/
|
||||||
@RequestMapping("/sys/tenant")
|
@RequestMapping("/sys/tenant")
|
||||||
public String listTenant(Model m, HttpSession session) {
|
public String listTenant(Model m, HttpSession session) {
|
||||||
@ -72,6 +73,11 @@ public class TenantController extends BasicController{
|
|||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
if(null != tenantOld) {
|
if(null != tenantOld) {
|
||||||
tenantNew.setCreate_time(tenantOld.getCreate_time());
|
tenantNew.setCreate_time(tenantOld.getCreate_time());
|
||||||
|
tenantNew.setUpdate_time(tenantOld.getUpdate_time());
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_UPDATE,
|
||||||
|
OpLogManager.OP_OBJ_TENANT,
|
||||||
|
tenantNew.getName()+" changed:"+ObjUtil.compare(tenantOld,tenantNew));
|
||||||
tenantNew.setUpdate_time(now);
|
tenantNew.setUpdate_time(now);
|
||||||
num = tenantMapper.updateById(tenantNew);
|
num = tenantMapper.updateById(tenantNew);
|
||||||
}
|
}
|
||||||
@ -83,7 +89,11 @@ public class TenantController extends BasicController{
|
|||||||
tenantNew.setId(maxTenant.getId()+1);
|
tenantNew.setId(maxTenant.getId()+1);
|
||||||
tenantNew.setCreate_time(now);
|
tenantNew.setCreate_time(now);
|
||||||
tenantNew.setUpdate_time(now);
|
tenantNew.setUpdate_time(now);
|
||||||
num = tenantMapper.insert(tenantNew); //id自增
|
num = tenantMapper.insert(tenantNew);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_TENANT,
|
||||||
|
tenantNew.getName()+" create new");
|
||||||
}
|
}
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
@ -94,10 +104,14 @@ public class TenantController extends BasicController{
|
|||||||
|
|
||||||
@PostMapping("/sys/tenant/delete")
|
@PostMapping("/sys/tenant/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam String name) throws Exception {
|
public String delete(HttpSession session, @RequestParam String name) throws Exception {
|
||||||
QueryWrapper<Tenant> wrapper = new QueryWrapper<>();
|
QueryWrapper<Tenant> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("name",name);
|
wrapper.eq("name",name);
|
||||||
int num = tenantMapper.delete(wrapper);
|
int num = tenantMapper.delete(wrapper);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_TENANT,
|
||||||
|
name+" deleted");
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else return HttpResult.ok();
|
} else return HttpResult.ok();
|
||||||
|
|||||||
@ -5,11 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.imdroid.beidou.common.HttpResult;
|
import com.imdroid.beidou.common.HttpResult;
|
||||||
import com.imdroid.beidou.common.Role;
|
|
||||||
import com.imdroid.beidou.entity.Tenant;
|
import com.imdroid.beidou.entity.Tenant;
|
||||||
import com.imdroid.beidou.entity.TenantMapper;
|
import com.imdroid.beidou.entity.TenantMapper;
|
||||||
import com.imdroid.beidou.entity.User;
|
import com.imdroid.beidou.entity.User;
|
||||||
import com.imdroid.beidou.entity.UserMapper;
|
import com.imdroid.beidou.entity.UserMapper;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
|
import com.imdroid.common.util.ObjUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
@ -28,6 +29,8 @@ public class UserController extends BasicController {
|
|||||||
UserMapper userMapper;
|
UserMapper userMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
TenantMapper tenantMapper;
|
TenantMapper tenantMapper;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
/**** 推送页面 *****/
|
/**** 推送页面 *****/
|
||||||
@RequestMapping("/sys/user/pwd")
|
@RequestMapping("/sys/user/pwd")
|
||||||
public String userPwd() {
|
public String userPwd() {
|
||||||
@ -44,7 +47,10 @@ public class UserController extends BasicController {
|
|||||||
public String addUser(Model m, HttpSession session){
|
public String addUser(Model m, HttpSession session){
|
||||||
initModel(m, session);
|
initModel(m, session);
|
||||||
QueryWrapper<Tenant> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Tenant> queryWrapper = new QueryWrapper<>();
|
||||||
if(loginRole.equals(Role.ADMIN)) queryWrapper.ne("id",Tenant.SAAS_PROVIDER_ID);
|
Integer tenantId = getTenantId(session);
|
||||||
|
if (tenantId != null && tenantId != Tenant.SAAS_PROVIDER_ID) {
|
||||||
|
queryWrapper.eq("id", tenantId);
|
||||||
|
}
|
||||||
List<Tenant> tenants = tenantMapper.selectList(queryWrapper);
|
List<Tenant> tenants = tenantMapper.selectList(queryWrapper);
|
||||||
m.addAttribute("tenant_list", tenants);
|
m.addAttribute("tenant_list", tenants);
|
||||||
|
|
||||||
@ -55,7 +61,10 @@ public class UserController extends BasicController {
|
|||||||
public String editUser(Model m, HttpSession session){
|
public String editUser(Model m, HttpSession session){
|
||||||
initModel(m, session);
|
initModel(m, session);
|
||||||
QueryWrapper<Tenant> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Tenant> queryWrapper = new QueryWrapper<>();
|
||||||
if(loginRole.equals(Role.ADMIN)) queryWrapper.ne("id",Tenant.SAAS_PROVIDER_ID);
|
Integer tenantId = getTenantId(session);
|
||||||
|
if (tenantId != null && tenantId != Tenant.SAAS_PROVIDER_ID) {
|
||||||
|
queryWrapper.eq("id", tenantId);
|
||||||
|
}
|
||||||
List<Tenant> tenants = tenantMapper.selectList(queryWrapper);
|
List<Tenant> tenants = tenantMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
m.addAttribute("tenant_list", tenants);
|
m.addAttribute("tenant_list", tenants);
|
||||||
@ -68,8 +77,10 @@ public class UserController extends BasicController {
|
|||||||
public JSONObject list(HttpSession session, int page, int limit, String searchParams) {
|
public JSONObject list(HttpSession session, int page, int limit, String searchParams) {
|
||||||
Page<User> pageable = new Page<>(page, limit);
|
Page<User> pageable = new Page<>(page, limit);
|
||||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||||
if(loginRole.equals(Role.ADMIN)) queryWrapper.ne("role",Role.SUPER_ADMIN);
|
Integer tenantId = getTenantId(session);
|
||||||
|
if (tenantId != null && tenantId != Tenant.SAAS_PROVIDER_ID) {
|
||||||
|
queryWrapper.eq("tenantid", tenantId);
|
||||||
|
}
|
||||||
IPage<User> cs = userMapper.selectPage(pageable, queryWrapper);
|
IPage<User> cs = userMapper.selectPage(pageable, queryWrapper);
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
@ -101,11 +112,21 @@ public class UserController extends BasicController {
|
|||||||
int num = 0;
|
int num = 0;
|
||||||
if(null != userOld) {
|
if(null != userOld) {
|
||||||
userNew.setId(userOld.getId());
|
userNew.setId(userOld.getId());
|
||||||
|
userNew.setPwd(userOld.getPwd());
|
||||||
|
userNew.setInit_pwd(userOld.getInit_pwd());
|
||||||
num = userMapper.updateById(userNew);
|
num = userMapper.updateById(userNew);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_UPDATE,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
userNew.getName()+" changed:"+ObjUtil.compare(userOld,userNew));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
userNew.setPwd(new BCryptPasswordEncoder().encode(default_pwd));
|
userNew.setPwd(new BCryptPasswordEncoder().encode(default_pwd));
|
||||||
num = userMapper.insert(userNew); //id自增
|
num = userMapper.insert(userNew); //id自增
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
userNew.getName()+" create new");
|
||||||
}
|
}
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
@ -116,10 +137,14 @@ public class UserController extends BasicController {
|
|||||||
|
|
||||||
@PostMapping("/sys/user/delete")
|
@PostMapping("/sys/user/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam String name) throws Exception {
|
public String delete(HttpSession session, @RequestParam String name) throws Exception {
|
||||||
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("name",name);
|
wrapper.eq("name",name);
|
||||||
int num = userMapper.delete(wrapper);
|
int num = userMapper.delete(wrapper);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_DEL,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
name + " deleted");
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else return HttpResult.ok();
|
} else return HttpResult.ok();
|
||||||
@ -150,6 +175,10 @@ public class UserController extends BasicController {
|
|||||||
flag = true;
|
flag = true;
|
||||||
user.setPwd(pwdEncoder.encode(new_pwd));
|
user.setPwd(pwdEncoder.encode(new_pwd));
|
||||||
user.setInit_pwd(false);
|
user.setInit_pwd(false);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_UPDATE,
|
||||||
|
OpLogManager.OP_OBJ_USER,
|
||||||
|
" changed password");
|
||||||
userMapper.updateById(user);
|
userMapper.updateById(user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.imdroid.beidou.common.HttpResult;
|
import com.imdroid.beidou.common.HttpResult;
|
||||||
import com.imdroid.beidou.service.CommonExcelService;
|
import com.imdroid.beidou.service.CommonExcelService;
|
||||||
|
import com.imdroid.beidou.service.OpLogManager;
|
||||||
|
import com.imdroid.common.util.ObjUtil;
|
||||||
import com.imdroid.secapi.client.RtcmClient;
|
import com.imdroid.secapi.client.RtcmClient;
|
||||||
import com.imdroid.secapi.dto.*;
|
import com.imdroid.secapi.dto.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -30,7 +32,8 @@ public class WarningController extends BasicController implements CommonExcelSer
|
|||||||
WarningCfgMapper warningCfgMapper;
|
WarningCfgMapper warningCfgMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
RtcmClient rtcmClient;
|
RtcmClient rtcmClient;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
public static final Map<Integer, String> warningMap = new HashMap<>();
|
public static final Map<Integer, String> warningMap = new HashMap<>();
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@ -104,7 +107,7 @@ public class WarningController extends BasicController implements CommonExcelSer
|
|||||||
|
|
||||||
@PostMapping("/warning/update")
|
@PostMapping("/warning/update")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String update(@RequestBody JSONObject object) throws Exception {
|
public String update(HttpSession session, @RequestBody JSONObject object) throws Exception {
|
||||||
// 从请求参数中创建对象
|
// 从请求参数中创建对象
|
||||||
WarningCfg cfg = JSONObject.toJavaObject(object, WarningCfg.class);
|
WarningCfg cfg = JSONObject.toJavaObject(object, WarningCfg.class);
|
||||||
cfg.setTypename(warningMap.get(cfg.getType()));
|
cfg.setTypename(warningMap.get(cfg.getType()));
|
||||||
@ -114,10 +117,19 @@ public class WarningController extends BasicController implements CommonExcelSer
|
|||||||
QueryWrapper<WarningCfg> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<WarningCfg> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("devicetype", cfg.getDevicetype());
|
queryWrapper.eq("devicetype", cfg.getDevicetype());
|
||||||
queryWrapper.eq("type", cfg.getType());
|
queryWrapper.eq("type", cfg.getType());
|
||||||
if (warningCfgMapper.selectCount(queryWrapper) == 0) {
|
WarningCfg oldCfg = warningCfgMapper.selectOne(queryWrapper);
|
||||||
|
if (oldCfg == null) {
|
||||||
num = warningCfgMapper.insert(cfg);
|
num = warningCfgMapper.insert(cfg);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_WARNING,
|
||||||
|
cfg.getTypename()+" create new");
|
||||||
} else {
|
} else {
|
||||||
num = warningCfgMapper.update(cfg, queryWrapper);
|
num = warningCfgMapper.update(cfg, queryWrapper);
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_WARNING,
|
||||||
|
cfg.getTypename() +" update: " + ObjUtil.compare(oldCfg, cfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
@ -131,8 +143,16 @@ public class WarningController extends BasicController implements CommonExcelSer
|
|||||||
|
|
||||||
@PostMapping("/warning/delete")
|
@PostMapping("/warning/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam Integer del_id) throws Exception {
|
public String delete(HttpSession session, @RequestParam Integer del_id) throws Exception {
|
||||||
int num = warningCfgMapper.deleteById(del_id);
|
WarningCfg cfg = warningCfgMapper.selectById(del_id);
|
||||||
|
int num = 0;
|
||||||
|
if(cfg != null) {
|
||||||
|
num = warningCfgMapper.deleteById(del_id);
|
||||||
|
opLogManager.addLog(getLoginUser(session), getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_ADD,
|
||||||
|
OpLogManager.OP_OBJ_WARNING,
|
||||||
|
del_id + " deleted");
|
||||||
|
}
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.imdroid.beidou.service;
|
||||||
|
|
||||||
|
import com.imdroid.secapi.dto.OpLogMapper;
|
||||||
|
import com.imdroid.secapi.dto.OperationLog;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OpLogManager {
|
||||||
|
public final static Short OP_TYPE_ADD = 1;
|
||||||
|
public final static Short OP_TYPE_UPDATE = 2;
|
||||||
|
public final static Short OP_TYPE_DEL = 3;
|
||||||
|
public final static Short OP_TYPE_CMD = 4;
|
||||||
|
|
||||||
|
public final static Short OP_TYPE_LOGIN = 5;
|
||||||
|
public final static Short OP_TYPE_LOGOUT = 6;
|
||||||
|
|
||||||
|
public final static Short OP_OBJ_USER = 3;
|
||||||
|
public final static Short OP_OBJ_TENANT = 4;
|
||||||
|
public final static Short OP_OBJ_DEVICE = 5;
|
||||||
|
public final static Short OP_OBJ_GROUP = 6;
|
||||||
|
public final static Short OP_OBJ_WARNING = 7;
|
||||||
|
public final static Short OP_OBJ_SYS = 8;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
OpLogMapper opLogMapper;
|
||||||
|
|
||||||
|
public void addLog(String userName, Integer tenantId, Short type, Short obj, String content)
|
||||||
|
{
|
||||||
|
if(userName != null) {
|
||||||
|
OperationLog opLog = new OperationLog();
|
||||||
|
opLog.setUser_name(userName);
|
||||||
|
opLog.setTenantid(tenantId);
|
||||||
|
opLog.setOp_type(type);
|
||||||
|
opLog.setOp_object(obj);
|
||||||
|
if(content.length()>256) content = content.substring(0,250)+"...";
|
||||||
|
opLog.setContent(content);
|
||||||
|
opLogMapper.insert(opLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,9 +2,9 @@
|
|||||||
#spring.datasource.url=jdbc:mysql://192.168.101.54:3306/beidou?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
|
#spring.datasource.url=jdbc:mysql://192.168.101.54:3306/beidou?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
|
||||||
#spring.datasource.username=beidou
|
#spring.datasource.username=beidou
|
||||||
#spring.datasource.password=Passw0rd#123!
|
#spring.datasource.password=Passw0rd#123!
|
||||||
#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/beidou?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
|
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/beidou?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
|
||||||
spring.datasource.url=jdbc:mysql://139.9.51.237:3306/beidou?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
|
#spring.datasource.url=jdbc:mysql://139.9.51.237:3306/beidou?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true
|
||||||
spring.datasource.username=radmin
|
spring.datasource.username=admin
|
||||||
spring.datasource.password=DBMgr_2022
|
spring.datasource.password=DBMgr_2022
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.jpa.properties.hibernate.hbm2ddl.auto=update
|
spring.jpa.properties.hibernate.hbm2ddl.auto=update
|
||||||
@ -12,8 +12,8 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MYSQL5InnoDBDialec
|
|||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
||||||
|
|
||||||
spring.sql.init.mode=always
|
spring.sql.init.mode=always
|
||||||
#spring.datasource.initialize=true
|
spring.datasource.initialize=true
|
||||||
#spring.sql.init.schema-locations=classpath:db/schema.sql
|
spring.sql.init.schema-locations=classpath:db/schema.sql
|
||||||
|
|
||||||
#thymeleaf
|
#thymeleaf
|
||||||
spring.thymeleaf.cache=false
|
spring.thymeleaf.cache=false
|
||||||
|
|||||||
@ -289,3 +289,17 @@ CREATE TABLE IF NOT EXISTS `cachecmd` (
|
|||||||
`cmd` varchar(350) NOT NULL,
|
`cmd` varchar(350) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
/***
|
||||||
|
操作日志
|
||||||
|
*/
|
||||||
|
CREATE TABLE IF NOT EXISTS `OperationLog` (
|
||||||
|
`id` bigint AUTO_INCREMENT,
|
||||||
|
`user_name` varchar(20) NOT NULL,
|
||||||
|
`tenantid` int NOT NULL,
|
||||||
|
`op_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`op_type` smallint DEFAULT NULL,
|
||||||
|
`op_object` smallint DEFAULT NULL,
|
||||||
|
`content` varchar(256) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
@ -156,6 +156,12 @@
|
|||||||
"href": "sys/user",
|
"href": "sys/user",
|
||||||
"icon": "fa fa-user",
|
"icon": "fa fa-user",
|
||||||
"target": "_self"
|
"target": "_self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "操作日志",
|
||||||
|
"href": "sys/oplog",
|
||||||
|
"icon": "fa fa-book",
|
||||||
|
"target": "_self"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,6 +126,12 @@
|
|||||||
"href": "sys/user",
|
"href": "sys/user",
|
||||||
"icon": "fa fa-user",
|
"icon": "fa fa-user",
|
||||||
"target": "_self"
|
"target": "_self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "操作日志",
|
||||||
|
"href": "sys/oplog",
|
||||||
|
"icon": "fa fa-book",
|
||||||
|
"target": "_self"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
{field: 'fwd_device_num', title: '推送设备数'},
|
{field: 'fwd_device_num', title: '推送设备数'},
|
||||||
{field: 'result', title: '推送结果',templet: "<div>{{d.result==1?'成功':'失败'}}</div>"}
|
{field: 'result', title: '推送结果',templet: "<div>{{d.result==1?'成功':'失败'}}</div>"}
|
||||||
]],
|
]],
|
||||||
|
limits: [10, 20, 50],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
|
|||||||
@ -107,6 +107,7 @@
|
|||||||
{field: 'fwd_group_id', title: '推送组'},
|
{field: 'fwd_group_id', title: '推送组'},
|
||||||
{field: 'result', title: '状态',templet: "<div>{{d.result==1?'成功':'失败'}}</div>"}
|
{field: 'result', title: '状态',templet: "<div>{{d.result==1?'成功':'失败'}}</div>"}
|
||||||
]],
|
]],
|
||||||
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
|
|||||||
@ -157,8 +157,8 @@
|
|||||||
cols: [
|
cols: [
|
||||||
data_cols
|
data_cols
|
||||||
],
|
],
|
||||||
limits: [10, 50, 100, 200, 300],
|
limits: [20, 50, 100, 200, 300],
|
||||||
limit: 15,
|
limit: 20,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line',
|
skin: 'line',
|
||||||
done: function (result, curr, count) {
|
done: function (result, curr, count) {
|
||||||
|
|||||||
@ -115,8 +115,8 @@
|
|||||||
cols: [
|
cols: [
|
||||||
cfg_cols
|
cfg_cols
|
||||||
],
|
],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -76,6 +76,7 @@
|
|||||||
cols: [
|
cols: [
|
||||||
cfg_cols
|
cfg_cols
|
||||||
],
|
],
|
||||||
|
limits: [10, 20, 50],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
@ -169,7 +170,7 @@
|
|||||||
cols: [
|
cols: [
|
||||||
cfg2_cols
|
cfg2_cols
|
||||||
],
|
],
|
||||||
limit: 10,
|
limits: [10, 20, 50],
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -88,8 +88,8 @@
|
|||||||
{field: 'tx', title: '收发', templet: "<div>{{d.tx==1?'发':'收'}}</div>"},
|
{field: 'tx', title: '收发', templet: "<div>{{d.tx==1?'发':'收'}}</div>"},
|
||||||
{field: 'content', title: '内容', width: '50%'}
|
{field: 'content', title: '内容', width: '50%'}
|
||||||
]],
|
]],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -91,8 +91,8 @@
|
|||||||
cols: [
|
cols: [
|
||||||
cfg_cols
|
cfg_cols
|
||||||
],
|
],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -104,8 +104,8 @@
|
|||||||
cols: [
|
cols: [
|
||||||
data_cols
|
data_cols
|
||||||
],
|
],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -121,8 +121,8 @@
|
|||||||
cols: [
|
cols: [
|
||||||
cfg_cols
|
cfg_cols
|
||||||
],
|
],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
155
sec-beidou/src/main/resources/templates/page/operation_log.html
Normal file
155
sec-beidou/src/main/resources/templates/page/operation_log.html
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>操作日志</title>
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
|
<link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="../css/public.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layuimini-container">
|
||||||
|
<div class="layuimini-main">
|
||||||
|
|
||||||
|
<fieldset class="table-search-fieldset">
|
||||||
|
<legend>搜索信息</legend>
|
||||||
|
<div style="margin: 10px 10px 10px 10px">
|
||||||
|
<form class="layui-form layui-form-pane" action="" id="searchFrm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">用户名</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="sl_user_name" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">范围</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="dgt_op_time" autocomplete="off" id="ID-laydate-start-date" class="layui-input" placeholder="开始日期">
|
||||||
|
</div>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="dlt_op_time" autocomplete="off" id="ID-laydate-end-date" class="layui-input" placeholder="结束日期">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
|
||||||
|
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-export-btn"><i class="layui-icon"></i>导出</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||||||
|
<script th:inline="none">
|
||||||
|
layui.use(['form', 'table', 'laydate'], function () {
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form,
|
||||||
|
table = layui.table,
|
||||||
|
laydate = layui.laydate;
|
||||||
|
/**
|
||||||
|
* 初始化表单,要加上,不然刷新部分组件可能会不加载
|
||||||
|
*/
|
||||||
|
form.render();
|
||||||
|
|
||||||
|
laydate.render({
|
||||||
|
elem: '#ID-laydate-start-date',
|
||||||
|
type: 'datetime'
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#ID-laydate-end-date',
|
||||||
|
type: 'datetime'
|
||||||
|
});
|
||||||
|
|
||||||
|
table.render({
|
||||||
|
elem: '#currentTableId',
|
||||||
|
url: '/sys/list_oplog',
|
||||||
|
toolbar: '#toolbarDemo',//开启头部工具栏
|
||||||
|
defaultToolbar: ['filter'],
|
||||||
|
cols: [[
|
||||||
|
{field: 'user_name', title: '用户名'},
|
||||||
|
{field: 'op_time', title: '操作时间', templet: "<div>{{layui.util.toDateString(d.op_time, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
|
||||||
|
{field: 'op_type', title: '操作类型', templet: '#opTypeTrans'},
|
||||||
|
{field: 'op_object', title: '操作对象', templet: '#objTypeTrans'},
|
||||||
|
{field: 'content', title: '内容', width: '50%'}
|
||||||
|
]],
|
||||||
|
limits: [10, 20, 50, 100, 150],
|
||||||
|
limit: 10,
|
||||||
|
page: true,
|
||||||
|
skin: 'line'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听搜索操作
|
||||||
|
form.on('submit(data-search-btn)', function (data) {
|
||||||
|
var result = JSON.stringify(data.field);
|
||||||
|
|
||||||
|
//执行搜索重载
|
||||||
|
table.reload('currentTableId', {
|
||||||
|
page: {
|
||||||
|
curr: 1
|
||||||
|
}
|
||||||
|
, where: {
|
||||||
|
searchParams: result
|
||||||
|
}
|
||||||
|
}, 'data');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听导出操作
|
||||||
|
form.on('submit(data-export-btn)', function (data) {
|
||||||
|
var result = $('#searchFrm').serialize();
|
||||||
|
var u = "/sys/oplog/export?" + result;
|
||||||
|
window.open(u, "_blank");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="opTypeTrans">
|
||||||
|
{{# if(d.op_type == 1){ }}
|
||||||
|
<span>增加</span>
|
||||||
|
{{# } else if(d.op_type == 2){ }}
|
||||||
|
<span>修改</span>
|
||||||
|
{{# } else if(d.op_type == 3){ }}
|
||||||
|
<span>删除</span>
|
||||||
|
{{# } else if(d.op_type == 4){ }}
|
||||||
|
<span>发指令</span>
|
||||||
|
{{# } else if(d.op_type == 5){ }}
|
||||||
|
<span>登录</span>
|
||||||
|
{{# } else if(d.op_type == 6){ }}
|
||||||
|
<span>退出</span>
|
||||||
|
{{# } else { }}
|
||||||
|
<span>其他</span>
|
||||||
|
{{# } }}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="objTypeTrans">
|
||||||
|
{{# if(d.op_object == 1){ }}
|
||||||
|
<span>登录</span>
|
||||||
|
{{# } else if(d.op_object == 2){ }}
|
||||||
|
<span>退出</span>
|
||||||
|
{{# } else if(d.op_object == 3){ }}
|
||||||
|
<span>用户</span>
|
||||||
|
{{# } else if(d.op_object == 4){ }}
|
||||||
|
<span>组织</span>
|
||||||
|
{{# } else if(d.op_object == 5){ }}
|
||||||
|
<span>设备</span>
|
||||||
|
{{# } else if(d.op_object == 6){ }}
|
||||||
|
<span>参数组</span>
|
||||||
|
{{# } else if(d.op_object == 7){ }}
|
||||||
|
<span>告警</span>
|
||||||
|
{{# } else { }}
|
||||||
|
<span>其他</span>
|
||||||
|
{{# } }}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -96,6 +96,7 @@
|
|||||||
{field: 'fwd_group_id', title: '推送组'},
|
{field: 'fwd_group_id', title: '推送组'},
|
||||||
{field: 'state', title: '状态',templet: '#stateTrans'}
|
{field: 'state', title: '状态',templet: '#stateTrans'}
|
||||||
]],
|
]],
|
||||||
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
|
|||||||
@ -48,8 +48,8 @@
|
|||||||
{field: 'contact', title: '联系方式'},
|
{field: 'contact', title: '联系方式'},
|
||||||
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 120}
|
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 120}
|
||||||
]],
|
]],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -78,8 +78,8 @@
|
|||||||
{field: 'warning_enabled', title: '告警通知', templet: "<div>{{d.warning_enabled==1?'是':'否'}}</div>"},
|
{field: 'warning_enabled', title: '告警通知', templet: "<div>{{d.warning_enabled==1?'是':'否'}}</div>"},
|
||||||
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 120}
|
{title: '操作', toolbar: '#currentTableBar', align: "center", minWidth: 120}
|
||||||
]],
|
]],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -88,8 +88,8 @@
|
|||||||
{field: 'code', title: '告警类型'},
|
{field: 'code', title: '告警类型'},
|
||||||
{field: 'info', title: '告警内容', width: '35%'}
|
{field: 'info', title: '告警内容', width: '35%'}
|
||||||
]],
|
]],
|
||||||
limits: [10, 15, 20, 25, 50, 100],
|
limits: [10, 20, 50, 100, 150],
|
||||||
limit: 15,
|
limit: 10,
|
||||||
page: true,
|
page: true,
|
||||||
skin: 'line'
|
skin: 'line'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.imdroid.common.util;
|
||||||
|
|
||||||
|
public class ObjUtil {
|
||||||
|
public static String compare(Object obj1, Object obj2){
|
||||||
|
if(!obj1.getClass().equals(obj2.getClass())) return "";
|
||||||
|
|
||||||
|
String[] items = obj1.toString().split(",|:|\\s+");
|
||||||
|
String[] items2 = obj2.toString().split(",|:|\\s+");
|
||||||
|
String diff = "";
|
||||||
|
for(int i=0; i<items.length; i++){
|
||||||
|
if(!items[i].equals(items2[i])){
|
||||||
|
diff += items[i]+"->"+items2[i].substring(items2[i].indexOf('=')+1)+",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user