添加系统信息管理和日志部分
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.hcframe.user.common.log;
|
||||
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
import com.hcframe.base.module.log.annotation.LogAnno;
|
||||
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
* @date 2020.01.17
|
||||
*/
|
||||
@Order(3)
|
||||
@Aspect
|
||||
@Component
|
||||
public class OprateLog {
|
||||
|
||||
private static final String LOG_ID = "LOG_ID";
|
||||
private static final String OS_SYS_TITLE = "GB_LOGS";
|
||||
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_TITLE).tablePk(LOG_ID).build();
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
public OprateLog(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@Around("@annotation(com.hcframe.base.module.log.annotation.LogAnno)")
|
||||
public Object aroundAdvice(ProceedingJoinPoint pjp) throws Throwable {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
assert attributes != null;
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 1.方法执行前的处理,相当于前置通知
|
||||
// 获取方法签名
|
||||
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
|
||||
// 获取方法
|
||||
Method method = methodSignature.getMethod();
|
||||
// 获取方法上面的注解
|
||||
LogAnno logAnno = method.getAnnotation(LogAnno.class);
|
||||
ResultVO result = ResultVO.getSuccess();
|
||||
if (!logAnno.isBefore()) {
|
||||
result= (ResultVO) pjp.proceed();
|
||||
}
|
||||
|
||||
String operateType = logAnno.operateType();
|
||||
// 获取操作记录的日志表
|
||||
Map<String,Object> log=new HashMap<String,Object>();
|
||||
log.put("CREATE_TIME", new Date());
|
||||
log.put("IP", request.getRemoteAddr());
|
||||
log.put("CURL", request.getRequestURI());
|
||||
log.put("ACTTYPE", request.getMethod());
|
||||
log.put("CLOG", operateType + "参数:" + request.getQueryString());
|
||||
// log.put("USERID", value);
|
||||
log.put("STATUS", (byte) 1);
|
||||
|
||||
tableService.saveWithDate(TABLE_INFO, log);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.hcframe.user.module.userinfo.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.user.module.userinfo.service.OrgService;
|
||||
import com.hcframe.user.module.userinfo.service.OsService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("os")
|
||||
@Api(tags = "应用系统管理")
|
||||
public class OsController {
|
||||
|
||||
final OsService osService;
|
||||
|
||||
public OsController(OsService osService) {
|
||||
this.osService = osService;
|
||||
}
|
||||
|
||||
@GetMapping("/{oscode}")
|
||||
@ApiOperation(value = "校验系统编码是否存在", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> checkExistOs(@PathVariable String oscode) {
|
||||
return osService.checkExistOs(oscode);
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@ApiOperation(value = "新增系统", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> addOs(@RequestParam Map<String,Object> os) {
|
||||
return osService.addOs(os);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@ApiOperation(value = "更新系统信息")
|
||||
public ResultVO<Integer> updateOs(@RequestParam Map<String,Object> os,@PathVariable Integer version) {
|
||||
return osService.updateOs(os,version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation(value = "删除系统信息")
|
||||
public ResultVO<Object> deleteOs(@PathVariable String ids) {
|
||||
return osService.deleteOs(ids);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@ApiOperation(value = "获取系统信息列表")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getOsList(String data, WebPageInfo webPageInfo) {
|
||||
return osService.getOsList(data, webPageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.module.log.annotation.LogAnno;
|
||||
import com.hcframe.user.module.userinfo.service.OrgService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
|
||||
@@ -30,6 +31,12 @@ public class TitleController {
|
||||
public TitleController(TitleService titleService) {
|
||||
this.titleService = titleService;
|
||||
}
|
||||
|
||||
@GetMapping("/{titlecode}")
|
||||
@ApiOperation(value = "校验职称编码是否存在", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> checkExistTitle(@PathVariable String titlecode) {
|
||||
return titleService.checkExistTitle(titlecode);
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@ApiOperation(value = "新增title", notes = "将自动传承key-value对象模式即可")
|
||||
@@ -50,6 +57,7 @@ public class TitleController {
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@LogAnno(operateType="getTitleList",tableName="title")
|
||||
@ApiOperation(value = "获取职称列表")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getTitleList(String data, WebPageInfo webPageInfo) {
|
||||
return titleService.getTitleList(data, webPageInfo);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hcframe.user.module.userinfo.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
|
||||
public interface OsService {
|
||||
|
||||
ResultVO<Object> checkExistOs(String oscode);
|
||||
|
||||
ResultVO<Object> addOs(Map<String, Object> os);
|
||||
|
||||
ResultVO<Integer> updateOs(Map<String, Object> os, Integer version);
|
||||
|
||||
ResultVO<Object> deleteOs(String ids);
|
||||
|
||||
ResultVO<PageInfo<Map<String, Object>>> getOsList(String data, WebPageInfo webPageInfo);
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
|
||||
public interface TitleService {
|
||||
|
||||
ResultVO<Object> checkExistTitle(String titlecode);
|
||||
|
||||
ResultVO<Object> addTitle(Map<String, Object> title);
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.hcframe.user.module.userinfo.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.module.Condition;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
|
||||
import com.hcframe.user.module.userinfo.service.OsService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
|
||||
@Service
|
||||
public class OsServiceImpl implements OsService{
|
||||
|
||||
private static final String OS_ID = "OS_ID";
|
||||
private static final String OS_SYS_OS = "OS_SYS_OS";
|
||||
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_OS).tablePk(OS_ID).build();
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
|
||||
public OsServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> checkExistOs(String oscode){
|
||||
Condition condition = Condition.creatCriteria().andEqual("OS_CODE",oscode).andEqual("DELETED",1).build();
|
||||
Long i = baseMapper.count(OS_SYS_OS, condition);
|
||||
if (i > 0L) {
|
||||
return ResultVO.getFailed("系统编码不能重复");
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> addOs(Map<String, Object> os) {
|
||||
return ResultVO.getSuccess(tableService.saveWithDate(TABLE_INFO, os));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Integer> updateOs(Map<String, Object> os, Integer version) {
|
||||
return tableService.updateWithDate(TABLE_INFO,os,version);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> deleteOs(String ids) {
|
||||
String[] idArr = ids.split(",");
|
||||
tableService.delete(TABLE_INFO, ids);
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getOsList(String data, WebPageInfo webPageInfo) {
|
||||
PageInfo<Map<String,Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
|
||||
return ResultVO.getSuccess(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.hcframe.user.module.userinfo.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -33,10 +35,21 @@ public class TitleServiceImpl implements TitleService{
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> checkExistTitle(String titlecode){
|
||||
Condition condition = Condition.creatCriteria().andEqual("TITLE_CODE",titlecode).andEqual("DELETED",1).build();
|
||||
Long i = baseMapper.count(OS_SYS_TITLE, condition);
|
||||
if (i > 0L) {
|
||||
return ResultVO.getFailed("职称编码不能重复");
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> addTitle(Map<String, Object> title) {
|
||||
return ResultVO.getSuccess(tableService.saveWithDate(TABLE_INFO, title));
|
||||
|
||||
return ResultVO.getSuccess(tableService.saveWithDate(TABLE_INFO, title));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user