提交 0d4b313a authored 作者: gongwenjie's avatar gongwenjie

合并分支 'gongwenjie' 到 'master'

Gongwenjie 查看合并请求 !119
流水线 #172 已失败 于阶段
......@@ -5,6 +5,7 @@ import com.zjty.tynotes.attendance.entity.WorkoverAppro;
import com.zjty.tynotes.attendance.entity.vo.request.PageRequestAtten;
import com.zjty.tynotes.attendance.service.ApprovalInformationService;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
......@@ -37,6 +38,7 @@ public class ApprovalController {
@Autowired
private ApprovalInformationService approvalInformationService;
@Content(value = "提交审批")
@ApiOperation(value = "提交审批", response = ApprovalInformation.class)
@PostMapping("/submit")
public ResponseEntity submit(@RequestBody ApprovalInformation approvalInformation) {
......@@ -47,6 +49,7 @@ public class ApprovalController {
return ok("提交审批失败,是否是调休,并且是否有加班时长");
}
@Content(value = "删除请假审批")
@ApiOperation(value = "删除请假审批")
@DeleteMapping("/delete/{id}")
public ResponseEntity delete(@PathVariable("id") String id) {
......@@ -68,6 +71,7 @@ public class ApprovalController {
* @param approvalStatus
* @return
*/
@Content(value = "审核审批")
@ApiOperation(value = "审核审批")
@PostMapping("/audit/{userId}/{approvalStatus}")
public ResponseEntity audit(@PathVariable String userId,@PathVariable String approvalStatus,
......@@ -81,7 +85,6 @@ public class ApprovalController {
return ok("审核审批失败");
}
@ApiOperation(value = "查找所有我提交的审批")
@PostMapping("findAllSubmitApproval")
public ResponseEntity findAllSubmitApproval(@RequestBody PageRequestAtten pageRequest) {
......@@ -106,6 +109,7 @@ public class ApprovalController {
return ok("查找所有我审核的审批失败");
}
@Content(value = "提交加班申请")
@ApiOperation(value = "提交加班申请", response = WorkoverAppro.class)
@PostMapping("/submitWorkover")
public ResponseEntity submitWorkover(@RequestBody WorkoverAppro workoverAppro) {
......@@ -116,6 +120,7 @@ public class ApprovalController {
return ok("提交审批失败,是否可有加班时长");
}
@Content(value = "审批加班申请")
@ApiOperation(value = "审批加班申请", response = ApprovalInformation.class)
@PostMapping("/approWorkover/{userId}/{status}")
public ResponseEntity approWorkover(@RequestBody WorkoverAppro workoverAppro,
......@@ -163,6 +168,7 @@ public class ApprovalController {
return ok("查找可选择部门失败");
}
@Content(value = "删除加班审批")
@ApiOperation(value = "删除加班审批")
@DeleteMapping("/deleteWorkover/{id}")
public ResponseEntity deleteWorkover(@PathVariable("id") String id) {
......
......@@ -26,6 +26,7 @@ public class AttendanceController {
@Autowired
private AttendanceDetailsService attendanceDetailsService;
@ApiOperation(value = "查询个人考勤信息", response = ApprovalInformation.class)
@PostMapping("/personnel")
public ResponseEntity personnel(@RequestBody AttenRequest request){
......
......@@ -14,6 +14,7 @@ import com.zjty.tynotes.attendance.entity.CardResult;
import com.zjty.tynotes.attendance.task.CardTask;
import com.zjty.tynotes.attendance.task.MyInit;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -37,6 +38,7 @@ public class DingTestController {
@Autowired
private CardTask cardTask;
@GetMapping("/token")
public Object token(){
List<String> responses = new ArrayList<>();
......
......@@ -8,6 +8,7 @@ package com.zjty.tynotes.attendance.controller;
import com.zjty.tynotes.attendance.service.DingUserService;
import com.zjty.tynotes.attendance.task.MyInit;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
......@@ -36,6 +37,7 @@ public class DingUserController {
@Autowired
private MyInit init;
@Content(value = "手动获取钉钉token的接口")
@GetMapping("/getToken")
@ApiOperation(value = "手动获取钉钉token的接口")
public ResponseEntity getToken(){
......@@ -48,6 +50,7 @@ public class DingUserController {
return ok("重新获取token失败");
}
@Content(value = "手动获取钉钉的用户与本地用户进行绑定")
@GetMapping("/getDingUser")
@ApiOperation(value = "手动获取钉钉的用户与本地用户进行绑定")
public ResponseEntity getDingUser(){
......
......@@ -9,6 +9,7 @@ import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest;
import com.zjty.tynotes.attendance.service.AttendanceDetailsService;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.misc.utils.ExcelUtil;
import com.zjty.tynotes.pas.base.advise.Content;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
......@@ -34,6 +35,7 @@ public class ExlController {
@Autowired
private AttendanceDetailsService attendanceDetailsService;
@Content(value = "导出元数据excel表格")
@PostMapping("/excel")
@ApiOperation(value = "导出元数据excel表格")
public void exportCurrentPage(HttpServletRequest request, HttpServletResponse response,@RequestBody AttenRequest attenRequest) {
......
......@@ -13,7 +13,9 @@ import java.util.List;
*/
@Repository
public interface WorkoverApproDao extends MongoRepository<WorkoverAppro,String> {
WorkoverAppro findByUserIdContainsAndStatusAndOverDate(String userId, String status, Date date);
WorkoverAppro findByUserIdAndStatusAndOverDate(String userId, String status, Date date);
List<WorkoverAppro> findAllByGroupMenbersContainsAndStatusAndOverDate(String userId, String status, Date date);
List<WorkoverAppro> findAllByUserId(String userId);
......
......@@ -203,8 +203,9 @@ public class CardTask {
});
}
WorkoverAppro workoverAppro = workoverApproDao.findByUserIdContainsAndStatusAndOverDate(user.getId(), "1", parse);
// ApprovalInformation approvalInformation1 = approvalInformationDao.findByUserIdAndStatusAndApprovalType(user.getId(), "1", "加班");
WorkoverAppro workoverAppro = workoverApproDao.findByUserIdAndStatusAndOverDate(user.getId(), "1", parse);
List<WorkoverAppro> workoverAppros = workoverApproDao.findAllByGroupMenbersContainsAndStatusAndOverDate(user.getId(), "1", parse);
// ApprovalInformation approvalInformation1 = approvalInformationDao.findByUserIdAndStatusAndApprovalType(user.getId(), "1", "加班");
attendanceDetails.setUserId(user.getId());
if(cardResults1!=null){
List<CardResult> cardResults = new ArrayList<>();
......@@ -216,7 +217,7 @@ public class CardTask {
});
if(cardResults.size()>=2){
attendanceDetails.setLessCard(0);
if(workoverAppro!=null){
if(workoverAppro!=null || workoverAppros!=null){
cardResults.forEach(cardResult -> {
if(cardResult.getCheckType()!=null && cardResult.getCheckType().equals("OffDuty")){
Long l = cardResult.getUserCheckTime().getTime() - date1.getTime();
......@@ -335,10 +336,11 @@ public class CardTask {
cardResults.add(cardResult);
}
});
WorkoverAppro workoverAppro = workoverApproDao.findByUserIdContainsAndStatusAndOverDate(user.getId(), "1", parse);
WorkoverAppro workoverAppro = workoverApproDao.findByUserIdAndStatusAndOverDate(user.getId(), "1", parse);
List<WorkoverAppro> workoverAppros = workoverApproDao.findAllByGroupMenbersContainsAndStatusAndOverDate(user.getId(), "1", parse);
// ApprovalInformation approvalInformation1 = approvalInformationDao.findByUserIdAndStatusAndApprovalType(user.getId(), "1", "加班");
if(cardResults.size()>=2){
if(workoverAppro!=null){
if(workoverAppro!=null || workoverAppros!=null){
cardResults.forEach(cardResult -> {
if(cardResult.getCheckType()!=null && cardResult.getCheckType().equals("OffDuty")){
Long l = cardResult.getUserCheckTime().getTime() - date1.getTime();
......
......@@ -67,6 +67,17 @@
</exclusions>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-job</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -18,7 +18,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
"com.zjty.tynotes.search",
"com.zjty.tynotes.redis",
"com.zjty.tynotes.sms"
,"com.zjty.tynotes.log"
})
@EnableCaching
@EnableScheduling
......
......@@ -6,6 +6,8 @@ import com.zjty.tynotes.job.basic.entity.response.JobResponse;
import com.zjty.tynotes.job.basic.service.ScoreCoefficientService;
import com.zjty.tynotes.job.common.Action;
import com.zjty.tynotes.job.status.service.BusinessTreeManagement;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.server.LogService;
import com.zjty.tynotes.misc.config.AutoDocument;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -28,6 +30,9 @@ import static org.springframework.http.ResponseEntity.ok;
@RequestMapping("/job/sc")
public class ScController {
@Autowired
private LogService logService;
private final
ScoreCoefficientService scoreCoefficientService;
......@@ -40,12 +45,12 @@ public class ScController {
@PostMapping("/save")
@ApiOperation(value = "新增考评信息.", notes = "新增不可在数据中附带id.成功时返回新增数据保存的id.")
public ResponseEntity<JobResponse> add(@RequestBody ScRo scRo
) {
public ResponseEntity<JobResponse> add(@RequestBody ScRo scRo) {
ScoreCoefficient scoreCoefficient= scRo.toDb();
scoreCoefficient.setTime(new Date());
String saveId = scoreCoefficientService.add(scoreCoefficient);
businessTreeManagement.saveAction(scRo.getUserId(),scRo.getWorkId(),Action.APPRAISAL_WORD,new Date(),"自我评价");
logService.saveLog(new Log(null,"考评任务",new Date(),scRo.getUserId(),null));
return ok(new JobResponse(saveId));
}
......@@ -67,6 +72,7 @@ public class ScController {
}
String saveId = scoreCoefficientService.modify(scoreCoefficient);
businessTreeManagement.saveAction(userId,scoreCoefficient.getWordId(),Action.APPRAISAL_WORD,new Date(),msg);
logService.saveLog(new Log(null,"修改考评",new Date(),userId,null));
return ok(new JobResponse(saveId));
}
......
......@@ -12,7 +12,10 @@ import com.zjty.tynotes.job.basic.service.WorkTimeService;
import com.zjty.tynotes.job.common.Action;
import com.zjty.tynotes.job.common.constant.WorkStatus;
import com.zjty.tynotes.job.status.service.BusinessTreeManagement;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.server.LogService;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -35,6 +38,8 @@ import static org.springframework.http.ResponseEntity.ok;
@RequestMapping("/job/work")
@Slf4j
public class WorkController {
@Autowired
private LogService logService;
@Autowired
WorkService workService;
......@@ -52,16 +57,12 @@ public class WorkController {
private BusinessTreeManagement businessTreeManagement;
@GetMapping(value = "/{workId}")
@ApiOperation(value = "根据id查询工作.", notes = "在路径中指定要查询的工作id.")
public ResponseEntity<WorkVo> findById(@PathVariable String workId) {
return ok(conversionService.workToVo(workService.findById(workId)));
}
@PostMapping(value = "/save")
@ApiOperation(value = "新增工作.", notes = "新增不可在数据中附带id.成功时返回新增数据保存的id.")
public ResponseEntity<JobResponse> add(@RequestBody WorkRo workRo) {
......@@ -74,6 +75,7 @@ public class WorkController {
}else {
businessTreeManagement.saveAction(userId,workId,Action.SAVE_WORK,new Date(),remarks);
}
logService.saveLog(new Log(null,"新增工作"+workRo.getWork().getTitle(),new Date(),userId,null));
return ok(new JobResponse(workId));
}
......@@ -86,11 +88,11 @@ public class WorkController {
Work oldWork = workService.findById(newWork.getId());
String workId = workService.modify(newWork);
businessTreeManagement.saveAction(userId,workId,Action.SAVE_PUBLISH_WORK,new Date(),remarks);
logService.saveLog(new Log(null,"发布任务"+workRo.getWork().getTitle(),new Date(),userId,null));
return ok(new JobResponse(workId));
}
@PutMapping(value = "/delete")
@ApiOperation(value = "根据id删除工作.", notes = "本次删除选择是否要把个人工作量以及任务工作量纳入统计中.")
@ApiImplicitParams({
......@@ -105,9 +107,12 @@ public class WorkController {
@RequestParam String userId,
@RequestParam int workloadCount,
@RequestParam String msg) {
Work work = workService.findById(workId);
workService.deleteWork(workId,personalWorkload,workloadCount);
businessTreeManagement.saveAction(userId,workId,Action.DELETE_WORK,new Date(),msg);
if(work!=null){
logService.saveLog(new Log(null,"删除任务"+work.getTitle(),new Date(),userId,null));
}
return ok(new JobResponse(workId));
}
......@@ -117,20 +122,22 @@ public class WorkController {
workService.updateWorkCrew(updateCrew.getWorkId(),updateCrew.getUsers(),updateCrew.getWorkload());
businessTreeManagement.saveAction(updateCrew.getUserid(),updateCrew.getWorkId(),Action.UPDATE_WORK_CREW,new Date(),updateCrew.getMsg());
logService.saveLog(new Log(null,"修改任务的组员",new Date(),updateCrew.getUserid(),null));
return ok(new JobResponse(updateCrew.getWorkId()));
}
@PutMapping(value = "/upDate/Workload")
@ApiOperation(value = "修改任务的工作量、考评系数.")
public ResponseEntity<JobResponse> updateWorkload(@RequestBody UpdateWorkload updateWorkload) {
Work work = workService.findById(updateWorkload.getWorkId());
workService.updateWorkload(updateWorkload.getWorkId(),updateWorkload.getWorkload(),updateWorkload.getWorkCoefficient());
businessTreeManagement.saveAction(updateWorkload.getUserId(),updateWorkload.getWorkId(),Action.UPDATE_WORKLOAD,new Date(),updateWorkload.getMsg());
if(work!=null){
logService.saveLog(new Log(null,"修改" + work.getTitle() + "任务的工作量",new Date(),updateWorkload.getUserId(),null));
}
return ok(new JobResponse(updateWorkload.getWorkId()));
}
@PutMapping(value = "/status")
@ApiOperation(value = "修改工作状态")
@ApiImplicitParams({
......@@ -145,7 +152,11 @@ public class WorkController {
@RequestParam String status,
@RequestParam String msg,
@RequestParam String re) {
Work workServiceById = workService.findById(workId);
String title = null;
if(workServiceById!=null){
title = workServiceById.getTitle();
}
switch (status) {
case "ongoing":
Work work=workService.findById(workId);
......@@ -154,25 +165,30 @@ public class WorkController {
//撤回
workService.alterTaskStatus1(workId,status,userId);
businessTreeManagement.saveAction(userId,workId,Action.COMMIT_BACK_WORK,new Date(),msg);
logService.saveLog(new Log(null,"撤回任务"+title,new Date(),userId,null));
}else{
workService.alterTaskStatus(workId,status,userId);
businessTreeManagement.saveAction(userId,workId,Action.BACK_WORK,new Date(),msg);
//审核不通过
logService.saveLog(new Log(null,"审核任务"+title,new Date(),userId,null));
}
break;
case "audit":
//执行者提交
workService.alterTaskStatus(workId, status,userId);
businessTreeManagement.saveAction(userId, workId, Action.COMMIT_WORK, new Date(), msg);
logService.saveLog(new Log(null,"提交任务"+title,new Date(),userId,null));
break;
case "review":
//审核通过
workService.alterTaskStatus(workId, status,userId);
businessTreeManagement.saveAction(userId, workId, Action.FINISH_WORK, new Date(), msg);
logService.saveLog(new Log(null,"审核任务"+title,new Date(),userId,null));
break;
case WorkStatus.FINISHED:
workService.alterTaskStatus(workId, status,userId);
businessTreeManagement.saveAction(userId, workId, Action.FINISHED_WORK, new Date(), msg);
logService.saveLog(new Log(null,"完结任务"+title,new Date(),userId,null));
break;
default:
log.warn("[job] 修改任务状态传入的参数有误,传入值为:{}", status);
......
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>tynotes</artifactId>
<groupId>com.zjty.tynotes</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>notes-log</artifactId>
<dependencies>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-redis</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-misc</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-search</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-sms</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-pas</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>com.zjty.tynotes</groupId>-->
<!--<artifactId>notes-weekly</artifactId>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>com.zjty.tynotes</groupId>-->
<!--<artifactId>notes-log</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-attendance</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!-- 关于aop的依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.zjty.tynotes.log;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {
"com.zjty.tynotes.misc",
"com.zjty.tynotes.pas",
"com.zjty.tynotes.log",
"com.zjty.tynotes.search",
"com.zjty.tynotes.redis",
"com.zjty.tynotes.sms"
// "com.zjty.tynotes.weekly"
// ,"com.zjty.tynotes.attendance"
})
public class NotesLogApplication {
public static void main(String[] args) {
SpringApplication.run(NotesLogApplication.class, args);
}
}
package com.zjty.tynotes.log.base.aspect;
import com.zjty.tynotes.log.dao.LogDao;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.base.advise.ContentParse;
import com.zjty.tynotes.pas.dao.PasUserDao;
import com.zjty.tynotes.pas.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Date;
/**
* @Author gwj
* @create 2020/4/23 8:57
*/
@Aspect
@Component
@Slf4j
public class ControllerAspect {
@Autowired
private PasUserDao pasUserDao;
@Autowired
private LogDao logDao;
private final static Logger logger = LoggerFactory.getLogger(ControllerAspect.class);
/**
* 定义切点
*/
@Pointcut("execution(public * com.zjty.tynotes.pas.controller.*.*(..))")
public void privilege1(){}
// @Pointcut("execution(public * com.zjty.tynotes.job.basic.controller.*.*(..))")
// public void privilege2(){}
@Pointcut("execution(public * com.zjty.tynotes.attendance.controller.*.*(..))")
public void privilege3(){}
@Pointcut("execution(public * com.zjty.tynotes.pas.config.handler.MySuccessHandler.onAuthenticationSuccess(..))")
public void privilege4(){}
// @Pointcut("execution(public * com.zjty.tynotes.weekly.subject.controller.*.*(..))")
// public void privilege4(){}
/**
* 日志记录的环绕通知
* @param joinPoint
* @throws Throwable
*/
@Around("privilege1() || privilege3()||privilege4()")
public Object isLogMethod(ProceedingJoinPoint joinPoint) throws Throwable {
try {
// 接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
String loginSession = request.getHeader("session");
logger.info("loginSession:{}",loginSession);
//获取访问目标方法
MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature();
Method targetMethod = methodSignature.getMethod();
//得到方法的功能描述,生成日志信息
final Content content = ContentParse.privilegeParse(targetMethod);
//得到方法的访问权限
// final String[] methodAccess = AccessAnnotationParse.privilegeParse(targetMethod);
if(content!=null){
String contentValue = content.value();
User user = null;
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
if (authentication instanceof AnonymousAuthenticationToken) {
return null;
}
if (authentication instanceof UsernamePasswordAuthenticationToken) {
user = (User) authentication.getPrincipal();
}
}
if(authentication!=null){
String username = user.getUsername();
String description = username + "执行" + contentValue;
logger.info(description);
Log log = new Log(null,description,new Date(),null,username);
User byUsername = pasUserDao.findByUsername(username);
if(byUsername!=null){
log.setUserId(byUsername.getId());
}
logDao.save(log);
Object proceed = joinPoint.proceed();
return proceed;
}
}
Object proceed = joinPoint.proceed();
return proceed;
}catch (Exception e){
Object proceed = joinPoint.proceed();
e.printStackTrace();
logger.error("aop日志记录出现异常:{}",e.getMessage());
return proceed;
}
}
}
package com.zjty.tynotes.log.controller;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.entity.vo.LogPageRequest;
import com.zjty.tynotes.log.server.LogService;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import static org.springframework.http.ResponseEntity.ok;
/**
* @Author gwj
* @create 2020/4/23 15:43
*/
@Api(tags = "日志管理模块",protocols = "http")
@RestController
@RequestMapping("/pas/log")
@AutoDocument
public class LogController {
@Autowired
private LogService logService;
@ApiOperation("查询日志")
@PostMapping("/findAllLogs")
public ResponseEntity findAllLogs(@RequestBody LogPageRequest pageRequest){
PageResponse<Log> logPageResponse = logService.findLogs(pageRequest);
return ok(logPageResponse);
}
}
package com.zjty.tynotes.log.dao;
import com.zjty.tynotes.log.entity.Log;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.Date;
import java.util.List;
/**
* @Author gwj
* @create 2020/4/23 9:55
*/
public interface LogDao extends MongoRepository<Log,String> {
/**
* 根据日志生成时间查询日志
* @param date
* @return
*/
List<Log> findAllByLogTime(Date date);
/**
* 根据日志生成时间的区间段查询日志
* @param start
* @param end
* @return
*/
List<Log> findAllByLogTimeBetween(Date start,Date end);
}
package com.zjty.tynotes.log.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
* @Author gwj
* @create 2020/4/23 9:25
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "日志", description = "日志说明")
@Document(collection = "pas_log")
public class Log {
@Id
@ApiModelProperty(value = "id",example = "1")
private String id;
@ApiModelProperty(value = "日志描述",example = "进行登录")
private String description;
@ApiModelProperty(value = "生成日志时间",example = "2020-03-21 09:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date logTime;
@ApiModelProperty(value = "用户id",example = "123")
private String userId;
@ApiModelProperty(value = "用户名",example = "gwj")
private String userName;
}
package com.zjty.tynotes.log.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author gwj
* @create 2020/4/23 15:56
*/
@ApiModel(value = "日志请求分页类", description = "日志请求分页类")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LogPageRequest {
/**
* 每页显示个数
*/
@ApiModelProperty(value = "每页数据数量",example = "10")
private int pageSize;
/**
* 当前页数
*/
@ApiModelProperty(value = "当前页",example = "1")
private int currentPage;
/**
* 总记录数
*/
@ApiModelProperty(value = "总记录数",example = "10")
private int totalCount;
/**
* 起始时间
*/
@ApiModelProperty(value = "起始时间",example = "2020-04-01 09:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
/**
* 结束时间
*/
@ApiModelProperty(value = "结束时间",example = "2020-04-01 09:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
}
package com.zjty.tynotes.log.server;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.entity.vo.LogPageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
/**
* @Author gwj
* @create 2020/4/23 15:00
*/
public interface LogService {
Log saveLog(Log log);
PageResponse<Log> findLogs(LogPageRequest pageRequest);
}
package com.zjty.tynotes.log.server.impl;
import com.zjty.tynotes.log.dao.LogDao;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.entity.vo.LogPageRequest;
import com.zjty.tynotes.log.server.LogService;
import com.zjty.tynotes.pas.dao.PasUserDao;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotEmpty;
import java.util.*;
/**
* @Author gwj
* @create 2020/4/23 15:01
*/
@Service
public class LogServiceImpl implements LogService {
private final static Logger logger = LoggerFactory.getLogger(LogServiceImpl.class);
@Autowired
private LogDao logDao;
@Autowired
private PasUserDao pasUserDao;
@Override
public Log saveLog(Log log) {
if(log.getUserId()!=null){
String userId = log.getUserId();
Optional<User> op = pasUserDao.findById(userId);
if(op.isPresent()){
User user = op.get();
String username = user.getUsername();
log.setUserName(username);
log.setDescription(username+"执行"+log.getDescription());
Log save = logDao.save(log);
return save;
}
}
logger.error("保存进入log日志失败");
return null;
}
/**
* 分页查找日志
* @param pageRequest
* @return
*/
@Override
public PageResponse<Log> findLogs(LogPageRequest pageRequest) {
PageResponse<Log> pageResponse = new PageResponse();
List<Log> logList = new ArrayList<>();
List<Log> logs = new ArrayList<>();
if(pageRequest.getStartTime()!=null && pageRequest.getEndTime()!=null){
List<Log> logs1 = logDao.findAllByLogTime(pageRequest.getStartTime());
List<Log> logs2 = logDao.findAllByLogTimeBetween(pageRequest.getStartTime(), pageRequest.getEndTime());
List<Log> logs3 = logDao.findAllByLogTime(pageRequest.getEndTime());
if(logs1!=null){
logs.addAll(logs1);
}
if(logs2!=null){
logs.addAll(logs2);
}
if(logs3!=null){
logs.addAll(logs3);
}
}else{
List<Log> all = logDao.findAll();
if(all!=null){
logs = all;
}
}
Collections.sort(logs, new Comparator<Log>() {
@Override
public int compare(Log o1, Log o2) {
return o2.getLogTime().compareTo(o1.getLogTime());
}
});
pageResponse.setPageSize(pageRequest.getPageSize());
pageResponse.setCurrentPage(pageRequest.getCurrentPage());
int currentPage = pageRequest.getCurrentPage();
int pageSize = pageRequest.getPageSize();
int start = (currentPage-1)*pageSize;
int end = start+pageSize;
int totalPage = 0;
if((logs.size()/pageSize)==0){
totalPage = (logs.size())/pageSize;
}else{
totalPage = (logs.size())/pageSize + 1;
}
if(currentPage>=totalPage){
logList = logs.subList(start, logs.size());
pageResponse.setRows(logList);
pageResponse.setTotalCount(logs.size());
}else{
logList = logs.subList(start, end);
pageResponse.setRows(logList);
pageResponse.setTotalCount(logs.size());
}
return pageResponse;
}
}
package com.zjty.tynotes.log;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class NotesLogApplicationTests {
void contextLoads() {
}
}
......@@ -52,6 +52,12 @@
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--springboot aop 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.dingtalk</groupId>-->
<!--<artifactId>2</artifactId>-->
......
package com.zjty.tynotes.pas.base.advise;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Content {
//访问的方法描述
String value()default "";
// 0:不记录;1:记录
String flag() default "0";
// 0:操作员;1:管理员;2:安全员;3:审计员
String[] part() default {"0"};
// 是否需要用户登录才能请求该方法,0:不需要登录;1:需要登陆
String access() default "0";
}
package com.zjty.tynotes.pas.base.advise;
import java.lang.reflect.Method;
public class ContentParse {
/***
* 解析权限注解
* @return 返回注解的authorities值
* @throws Exception
*/
public static Content privilegeParse(Method method) throws Exception {
//获取该方法
if(method.isAnnotationPresent(Content.class)){
return method.getAnnotation(Content.class);
}
return null;
}
}
package com.zjty.tynotes.pas.base.response;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* <p>Description : 异常结果枚举类,用于统一异常状态码与相关描述信息
*
* @author : M@tr!x [xhyrzldf@foxmail.com]
* @Date : 2017/12/13 0:51
*/
@AllArgsConstructor
@Getter
public enum ResponseCode {
/**
* 服务器成功返回用户请求的数据
*/
OK(200, "[GET]:服务器成功返回用户请求的数据,返回资源对象"),
/**
* 用户新建或修改数据成功
*/
CREATED(201, "[POST/PUT/PATCH]:用户新建或修改数据成功,返回新生成或修改的资源对象"),
/**
* 表示一个请求已经进入后台排队(异步任务)
*/
ACCEPTED(202, "[*]:表示一个请求已经进入后台排队(异步任务)"),
/**
* 用户上传文件成功
*/
UPLOADED(203, "[POST]文件上传成功"),
/**
* 用户删除数据成功
*/
NO_CONTENT(204, " [DELETE]:用户删除数据成功"),
/**
* 用户发出的请求有错误,服务器没有进行新建或修改数据的操作
*/
INVALID_REQUEST(400, "[POST/PUT/PATCH]:用户发出的请求有错误,服务器没有进行新建或修改数据的操作"),
/**
* 表示用户没有权限(令牌、用户名、密码错误)
*/
UNAUTHORIZED(401, " [*]:表示用户没有权限(令牌、用户名、密码错误)"),
/**
* 表示用户得到授权(与401错误相对),但是访问是被禁止的
*/
FORBIDDEN(403, " [*] 表示用户得到授权(与401错误相对),但是访问是被禁止的"),
/**
* 用户发出的请求针对的是不存在的记录,服务器没有进行操作,该操作是幂等的
*/
NOT_FOUND(404, " [*]:用户发出的请求针对的是不存在的记录,服务器没有进行操作"),
/**
* 非法参数,请求中附带的参数不符合要求规范
*/
ILLEGAL_PARAMETER(405, "[*]:非法参数,请求中附带的参数不符合要求规范"),
/**
* 用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)
*/
NOT_ACCEPTABLE(406, " [GET]:用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)"),
/**
* 用户的参数不得为空
*/
NOT_NULL_PARAMETER(408, "传递的参数不能为空"),
/**
* 用户请求的资源被永久删除,且不会再得到的
*/
GONE(413, "[GET]:用户请求的资源被永久删除,且不会再得到的"),
/**
* [PUT,PATCH,POST,DELETE]:操作没有成功,并没有数据发生变化
*/
NO_CHANGED(414, "[PUT,PATCH,POST,DELETE]:操作没有成功,并没有数据发生变化"),
/**
* 创建一个对象时,发生一个验证错误
*/
UNPROCESSABLE_ENTITY(422, "[POST/PUT/PATCH] 当创建一个对象时,发生一个验证错误"),
/**
* 服务器发生错误
*/
INTERNAL_SERVER_ERROR(500, "服务器发生错误"),
SERVER_ERROR(500, "系统升级维护中!"),
// SERVER_SUCCESED(200, "操作成功!"),
PRICE_CANNOT_BE_NULL(400, "价格不能为空!"),
USER_ID_BE_NULL(400, "用户id不能为空!"),
USER_NOT_LOGIN(400, "当前用户未登录或登录已超时!"),
USER_LOGIN_TIME_OUT(400, "用户登录超时,请重新登录!"),
USER_NOT_FIND(404, "用户不存在!"),
/**
* 表示用户没有权限(令牌、用户名、密码错误)
*/
UN_POWER(401, "用户权限不足!");
/**
* 结果代码编号
*/
private Integer code;
/**
* 结果信息
*/
private String msg;
}
package com.zjty.tynotes.pas.base.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.Optional;
import static com.zjty.tynotes.pas.base.response.ResponseCode.*;
/**
* Description : 结果类,用于统一返回格式 对外提供关于响应结果的很多便利的静态方法
*
* @author : M@tr!x [xhyrzldf@foxmail.com]
* @Date : 2017/12/13 0:05
*/
@SuppressWarnings({"WeakerAccess", "unused"})
@Getter
@Setter
@ApiModel(value = "服务器返回体")
public class ServerResponse<T> {
/**
* 错误码
*/
@ApiModelProperty(value = "返回码", example = "100")
private Integer code;
/**
* 提示信息
*/
@ApiModelProperty(value = "信息", example = "操作成功")
private String msg;
/**
* 具体的内容
*/
@ApiModelProperty(value = "返回数据")
private T data;
/* 以下为返回成功响应结果的各类重载静态方法 */
public static <T> ServerResponse<T> success() {
return new ServerResponse<>(OK.getCode(), OK.getMsg());
}
public static <T> ServerResponse<T> success(T data) {
return new ServerResponse<>(OK.getCode(), OK.getMsg(), data);
}
public static <T> ServerResponse<T> success(String msg, T data) {
return new ServerResponse<>(OK.getCode(), msg, data);
}
public static <T> ServerResponse<T> saveSuccess(T data) {
return new ServerResponse<>(CREATED.getCode(), CREATED.getMsg(), data);
}
public static <T> ServerResponse<T> deleteSuccess() {
return new ServerResponse<>(NO_CONTENT.getCode(), NO_CONTENT.getMsg());
}
public static <T> ServerResponse<T> deleteSuccessWithCount(Number effectCount) {
return new ServerResponse<>(NO_CONTENT.getCode(), "删除成功,操作删除的数据条数为: " + effectCount);
}
public static <T> ServerResponse<T> deleteSuccessWithId(Number id) {
return new ServerResponse<>(NO_CONTENT.getCode(), "删除成功,操作删除的数据id为: " + id);
}
public static <T> ServerResponse<T> uploadSuccess(T data) {
return new ServerResponse<>(UPLOADED.getCode(), UPLOADED.getMsg(), data);
}
public static <T> ServerResponse<T> messageSuccess(String msg) {
return new ServerResponse<>(OK.getCode(), msg);
}
/* 以下为返回失败响应结果的各类重载静态方法 */
public static <T> ServerResponse<T> error() {
return new ServerResponse<>(INTERNAL_SERVER_ERROR.getCode(), INTERNAL_SERVER_ERROR.getMsg());
}
public static <T> ServerResponse<T> error(String errorMessage) {
return new ServerResponse<>(INTERNAL_SERVER_ERROR.getCode(), errorMessage);
}
public static <T> ServerResponse<T> error(ResponseCode responseCode) {
return new ServerResponse<>(responseCode.getCode(), responseCode.getMsg());
}
public static <T> ServerResponse<T> error(ResponseCode responseCode, String errorMessage) {
return new ServerResponse<>(responseCode.getCode(), errorMessage);
}
public static <T> ServerResponse<T> error(ResponseCode responseCode, String errorMessage, T data) {
return new ServerResponse<>(responseCode.getCode(), errorMessage, data);
}
// /* 以下为提供给CONTROL层向文件服务器操作文件获得相应结果的相关方法 */
//
// /**
// * <b>向文件服务器上传文件并且取得{@code {@link ServerResponse}}类型的响应结果</b>
// * <p>
// * <p>封装了control层的关于文件上传的代码
// * <p>
// * <p>例如file是a.txt,dirName=template, 在文件服务器上存放的位置就是{@code root(根目录)/template/a.txt }
// *
// * @param file {@link MultipartFile} 接受到的文件俺对象
// * @param dirName 在文件服务器上的文件夹名
// * @return {@link ServerResponse} (包含了成功与导致失败的结果)
// */
// public static ServerResponse uploadAndGet(
// @RequestParam("file") Optional<MultipartFile> file, String dirName) {
// // 空指针判断
// if (!file.isPresent()) return error(NOT_NULL_PARAMETER);
// // 上传文件并且获得相应结果
// MultipartFile uploadFile = file.get();
// FileServerResponse fsp =
// HttpClientUtil.uploadFileToServer(uploadFile, dirName, uploadFile.getOriginalFilename());
// // 根据返回结果的状态码确定相应的返回信息(200返回成功,否则error)
// return (fsp.getCode() == 200) ? uploadSuccess(fsp.getData()) : error(NO_CHANGED, fsp.getMsg());
// }
// /**
// * <b>向文件服务器删除文件并且取得{@code {@link ServerResponse}}类型的响应结果</b>
// * <p>
// * <p>封装了control层的关于文件上传的代码
// * <p>
// * <p>例如提供的参数如下
// * <li>fileName = reset-hv_20180115144834_wV9A9iVD.png
// * <li>dirName = templates
// * <li>那么实际删除的文件路径为: {@code root(根目录)/templates/reset-hv_20180115144834_wV9A9iVD.png}
// *
// * @param fileName 要删除的文件名<b>注意是文件服务器上的文件名,例如<b>reset-hv_20180115144834_wV9A9iVD.png</b> 格式为{@code
// * 原始文件名_timestamp_uuid8位}
// * @param dirName 要删除的文件所处的文件目录
// * @return {@link ServerResponse} (包含了成功与导致失败的结果)
// */
// public static ServerResponse deleteAndGet(
// @RequestParam(value = "fileName") Optional<String> fileName, String dirName) {
// // 空指针判断
// if (!fileName.isPresent()) return error(NOT_NULL_PARAMETER);
// // 发送删除文件的请求,附带文件所在的目录和在服务器中的文件名
// FileServerResponse fsp = HttpClientUtil.daleteFileToServer(dirName, fileName.get());
// // 根据返回结果的状态码确定相应的返回信息(200返回成功,否则error)
// return (fsp.getCode() == 200) ? deleteSuccess() : error(NO_CHANGED, fsp.getMsg());
// }
/* 将构造器私有,防止外部进行实例化 仅提供给内部静态方法调用 * */
private ServerResponse() {
}
private ServerResponse(Integer code) {
this.code = code;
}
private ServerResponse(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
private ServerResponse(String msg, T data) {
this.msg = msg;
this.data = data;
}
private ServerResponse(Integer code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
}
}
......@@ -56,6 +56,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
httpSecurity
.cors().and()
.authorizeRequests()
.antMatchers("/pas/excel/upload").permitAll()
.antMatchers("/pas/user/findPublishUsers").permitAll()
.antMatchers("/ding/test/**").permitAll()
.antMatchers("/pas/user/judgeParent/**").permitAll()
......@@ -69,7 +70,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/pas/user/**",
"/pas/authority/findAuthority",
"/pas/role/**","/pas/department").hasAuthority("用户管理")
.antMatchers("/pas/authority").hasAnyAuthority("权限管理")
.antMatchers("/pas/authority","/pas/log/findAllLogs").hasAnyAuthority("权限管理")
.antMatchers("/pas/config").hasAnyAuthority("考勤管理")
.antMatchers("/pas/role").hasAnyAuthority("角色管理")
.antMatchers("/pas/department").hasAnyAuthority("部门管理")
......
package com.zjty.tynotes.pas.config.handler;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Role;
import com.zjty.tynotes.pas.dao.AuthorityDao;
......@@ -74,6 +75,7 @@ public class MySuccessHandler implements AuthenticationSuccessHandler {
RedisTemplate redisTemplate;
@Override
@Content(value = "登录操作")
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
Cookie[] cookies = httpServletRequest.getCookies();
if(cookies==null){
......
package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.service.IAuthorityService;
import io.swagger.annotations.Api;
......@@ -26,12 +27,14 @@ public class AuthorityController {
@Autowired
private IAuthorityService iAuthorityService;
@Content(value = "新增权限")
@ApiOperation("新增权限")
@PostMapping("/addAuthority")
public ResponseEntity addAuthority(@RequestBody Authority authority){
return ok(iAuthorityService.addAuthority(authority));
}
@Content(value = "删除权限")
@ApiOperation("删除权限")
@DeleteMapping("/deleteAuthority/{id}")
public String deleteAuthority(@PathVariable("id") String id){
......@@ -46,6 +49,7 @@ public class AuthorityController {
return "删除失败";
}
@Content(value = "修改权限")
@ApiOperation("修改权限")
@PutMapping("/updateAuthority")
public String updateAuthority(@RequestBody Authority authority){
......@@ -60,6 +64,7 @@ public class AuthorityController {
return "修改权限失败";
}
@Content(value = "查询所有权限")
@ApiOperation("查询所有权限")
@GetMapping("/findAuthority")
public ResponseEntity findAuthority(){
......
package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Config;
import com.zjty.tynotes.pas.entity.Day;
......@@ -30,6 +31,7 @@ public class ConfigController {
@Autowired
private ConfigService configService;
@Content(value = "保存基础参数配置")
@ApiOperation("保存基础参数配置")
@PostMapping("/addConfig")
public ResponseEntity addConfig(@RequestBody Config config){
......@@ -49,6 +51,7 @@ public class ConfigController {
return ok(configService.findHolidays(holidayRequest));
}
@Content(value = "批量设置工作日,节假日")
@ApiOperation("批量设置工作日,节假日")
@PutMapping("/setHolidays")
public ResponseEntity setHolidays(@RequestBody List<Day> days){
......@@ -67,6 +70,7 @@ public class ConfigController {
return ok(configService.findHolidaysByMonth(date));
}
@Content(value = "清除所有节假日数据")
@ApiOperation("清除所有节假日数据")
@DeleteMapping("/deleteAll")
public ResponseEntity deleteAll(){return ok(configService.deleteAll());}
......
package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.service.IDepartmentService;
......@@ -28,12 +29,14 @@ public class DepartController {
@Autowired
private IDepartmentService departmentService;
@ApiOperation(value = "获得所有部门",response = Department.class)
@GetMapping
public ResponseEntity departments(){
return ok(departmentService.findAll());
}
@Content(value = "添加部门")
@ApiOperation(value = "添加部门",response = Department.class)
@PostMapping
public ResponseEntity addDepartments(@RequestBody @Valid Department department){
......@@ -41,6 +44,7 @@ public class DepartController {
return ok(departmentService.addDepartments(department));
}
@Content(value = "修改部门")
@ApiOperation(value = "修改部门",response = Department.class)
@PutMapping
public ResponseEntity updateDepartments(@RequestBody @Valid Department department){
......@@ -64,6 +68,7 @@ public class DepartController {
return ok(departmentService.findList());
}
@Content(value = "删除部门")
@ApiOperation(value = "删除部门")
@DeleteMapping("/deleteDepartment/{id}")
public ResponseEntity deleteDepartment(@PathVariable("id") String id){
......
package com.zjty.tynotes.pas.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.misc.utils.ExcelUtil;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.ImportUserExcel;
import com.zjty.tynotes.pas.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author gwj
* @create 2020/4/24 9:36
* excel导入视图层
*/
@Api(tags = "用户管理权限管理模块",protocols = "http")
@RestController
@RequestMapping("/pas/excel")
@AutoDocument
public class ExcelController {
@Autowired
private IUserService iUserService;
@ApiOperation(value = "上传excel通讯录")
@PostMapping("/import")
public List<ImportUserExcel> upload(@RequestParam("file") MultipartFile multipartFile) throws Exception {
ImportParams params = new ImportParams();
params.setHeadRows(2);
params.setNeedVerfiy(true);
// params.setTitleRows(0);
List<ImportUserExcel> result = ExcelImportUtil.importExcel(multipartFile.getInputStream(),
ImportUserExcel.class, params);
System.out.println(result);
return result;
}
@ApiOperation(value = "导出所有人的excel通讯录")
@PostMapping("/export")
public void export(HttpServletRequest request, HttpServletResponse response) throws Exception {
//把要导出的信息放在map里面
List<Map<String, Object>> excelList = new ArrayList<>();
//构建创建导出excel表格所需要的Workbook对象的map
//源数据
List<User> users = iUserService.findAll();
List<ImportUserExcel> importUserExcels = new ArrayList<>();
if(users!=null){
users.forEach(user -> {
importUserExcels.add(new ImportUserExcel(user));
});
}
Map<String, Object> map = new HashMap<>(8);
String FpName="用户通讯录";
map.put("subFpName", FpName);
map.put("title", new ExportParams(FpName,FpName));
map.put("entity", ImportUserExcel.class);
map.put("data",importUserExcels);
excelList.add(map);
Workbook workbook = ExcelExportUtil.exportExcel(excelList, ExcelType.HSSF);
ExcelUtil.downloadExcel(request, response, workbook, FpName);
}
}
package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Role;
import com.zjty.tynotes.pas.service.IRoleService;
......@@ -32,6 +33,7 @@ public class RoleController {
return ResponseEntity.ok(iRoleService.findAll());
}
@Content(value = "新增角色")
@ApiOperation(value = "新增角色",response = Role.class)
@PostMapping
public ResponseEntity addRole(@RequestBody @Valid Role role){
......@@ -45,6 +47,7 @@ public class RoleController {
// return ResponseEntity.ok(iRoleService.addRole(role));
// }
@Content(value = "删除角色")
@ApiOperation(value = "删除角色",response = Role.class)
@DeleteMapping("/deleteRole/{id}")
public String deleteRole(@PathVariable("id") String id){
......@@ -59,6 +62,7 @@ public class RoleController {
return "删除失败";
}
@Content(value = "修改角色")
@ApiOperation(value = "修改角色",response = Role.class)
@PutMapping("/updateRole")
public String updateRole(@RequestBody Role role){
......
package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.service.IUserService;
......@@ -37,6 +38,7 @@ public class UserController {
@Autowired
IUserService iUserService;
@ApiOperation(value = "查询所有用户", response = User.class)
@GetMapping
public ResponseEntity user() {
......@@ -52,12 +54,14 @@ public class UserController {
}
@Content(value = "用户登出")
@ApiOperation(value = "用户登出")
@GetMapping("/userLogout")
public void logout() {
logoutUtil.logout();
}
@Content(value = "删除用户")
@ApiOperation(value = "删除用户")
@DeleteMapping("/delete/{id}")
public ResponseEntity delete(@PathVariable @NotNull String id) {
......@@ -65,6 +69,7 @@ public class UserController {
return ok().build();
}
@Content(value = "更新任意用户信息")
@ApiOperation(value = "更新任意用户信息")
@PutMapping
public ResponseEntity update(@RequestBody @NotNull User user) {
......@@ -94,6 +99,7 @@ public class UserController {
// return ok(iUserService.updateUser(userByUsername));
// }
@Content(value = "新增用户")
@ApiOperation(value = "新增用户", response = User.class)
@PostMapping
public ResponseEntity addUser(@RequestBody @Valid User user) {
......@@ -154,4 +160,5 @@ public class UserController {
}
package com.zjty.tynotes.pas.entity.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.zjty.tynotes.pas.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author gwj
* @create 2020/4/24 9:33
* @des 导入excel模板的实体类
*/
@Data
@AllArgsConstructor
public class ImportUserExcel {
@Excel(name = "姓名*")
private String name;
@Excel(name = "性别*",replace = {"男_0","女_1"})
private Integer gender;
@Excel(name = "手机号*")
private String phone;
public ImportUserExcel(User user) {
this.name = user.getUsername();
this.phone = user.getPhone1();
}
}
......@@ -176,6 +176,10 @@ public class UserServiceImpl implements IUserService {
return pasUserDao.findAllByIdIn(ids);
}
/**
* 查询所有用户
* @return
*/
@Override
public List<User> findAll() {
List<User> userList = new ArrayList<>();
......@@ -256,6 +260,12 @@ public class UserServiceImpl implements IUserService {
return save;
}
/**
* 是否有某个权限
* @param userId
* @param authorityName
* @return
*/
@Override
public boolean isHaveAuthority(String userId, String authorityName) {
List<UserRole> userRoles = userRoleDao.findAllByUserId(userId);
......@@ -324,6 +334,12 @@ public class UserServiceImpl implements IUserService {
return null;
}
/**
* 查询能够分解权限、发布权限给哪些人
* @param userId
* @param authoryName
* @return
*/
@Override
public List<User> findUserList(String userId,String authoryName){
List<String> departmentList = findDepartmentList(userId,authoryName);
......
......@@ -11,7 +11,7 @@
<artifactId>notes-union</artifactId>
<packaging>jar</packaging>
<!--<packaging>war</packaging>-->
<profiles>
<!--模拟环境-->
<profile>
......@@ -33,6 +33,29 @@
<dependencies>
<!--&lt;!&ndash; 排除内置的tomcat &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-web</artifactId>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<!--&lt;!&ndash; 使用自带的tomcat &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
<!--&lt;!&ndash;打包的时候可以不用包进去,别的设施会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。-->
<!--相当于compile,但是打包阶段做了exclude操作&ndash;&gt;-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-weekly</artifactId>
......@@ -78,6 +101,11 @@
<artifactId>notes-attendance</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package com.zjty.tynotes.union;
import javafx.application.Application;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
......@@ -23,12 +26,21 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
"com.zjty.tynotes.redis",
"com.zjty.tynotes.weekly",
"com.zjty.tynotes.misc",
"com.zjty.tynotes.union"
"com.zjty.tynotes.union",
"com.zjty.tynotes.log"
// , "com.zjty.tynotes.attendance"
})
@EnableCaching
@EnableScheduling
public class UnionApplication {
public class UnionApplication
// extends SpringBootServletInitializer
{
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// return builder.sources(UnionApplication.class);
// }
public static void main(String[] args) {
SpringApplication.run(UnionApplication.class, args);
}
......
......@@ -35,6 +35,17 @@
</exclusions>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-weekly</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-pas</artifactId>
......
......@@ -10,7 +10,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(scanBasePackages = {
"com.zjty.tynotes.misc",
"com.zjty.tynotes.pas"
"com.zjty.tynotes.pas",
"com.zjty.tynotes.log",
"com.zjty.tynotes.job"
})
@EnableSwagger2
public class WeeklyApplication {
......
package com.zjty.tynotes.weekly.subject.controller;
import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.server.LogService;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
import com.zjty.tynotes.weekly.subject.service.UserManageService;
import io.swagger.annotations.Api;
......@@ -12,15 +16,20 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import static org.springframework.http.ResponseEntity.ok;
......@@ -33,6 +42,10 @@ import static org.springframework.http.ResponseEntity.ok;
@RequestMapping("/manage/user")
@AutoDocument
public class UserManageController {
@Autowired
private LogService logService;
@Autowired
private UserManageService userManageService;
......@@ -73,12 +86,14 @@ public class UserManageController {
// return ok(userManageService.findUserWork(id,status));
// }
@Content(value = "更新当前用户自身信息")
@ApiOperation(value = "更新当前用户自身信息")
@PutMapping("/updateSelf")
public ResponseEntity updateSelf(@RequestBody @NotNull User user){
try {
User userById = userManageService.findUserById(user.getId());
User user1 = userManageService.updateSelf(user, userById);
logService.saveLog(new Log(null,"更改自身信息",new Date(),user.getId(),user.getUsername()));
return ok(user1);
} catch (Exception e) {
logger.error("更改当前用户自身信息失败");
......@@ -86,18 +101,25 @@ public class UserManageController {
return ok("更改当前用户信息失败");
}
@Content(value = "更新当前用户密码")
@ApiOperation(value = "更新当前用户密码")
@PutMapping("/password")
public ResponseEntity updatePassword(@RequestBody @NotNull User user){
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User principal = (User) authentication.getPrincipal();
User userByUsername = userManageService.findfindUserByUsername(principal.getUsername());
@PutMapping("/password/{oldPass}")
public ResponseEntity updatePassword(@PathVariable String oldPass,@RequestBody @NotNull User user){
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
System.out.println(oldPass);
User userByUsername = userManageService.findfindUserByUsername(user.getUsername());
System.out.println(userByUsername.getPassword());
if(bCryptPasswordEncoder.matches(oldPass,userByUsername.getPassword())){
System.out.println(true);
userByUsername.setPassword(user.getPassword());
boolean b = userManageService.updatePas(userByUsername);
if(b){
logService.saveLog(new Log(null,"更改密码",new Date(),user.getId(),user.getUsername()));
return ok("更改密码成功");
}
return ok("更改密码失败");
}
return new ResponseEntity("更改密码失败",HttpStatus.INTERNAL_SERVER_ERROR);
}
@ApiOperation(value = "上传建议以及使用中的问题")
......@@ -118,5 +140,17 @@ public class UserManageController {
return ok(userManageService.putProblem(problem));
}
@ApiOperation(value = "查询通讯录基本信息")
@GetMapping("/findAddressBook")
public ResponseEntity findAddressBook(){
try {
List<SimpleUserVo> simpleUserVos = userManageService.findAddressBook();
return ok(simpleUserVos);
} catch (Exception e) {
logger.error("查询通讯录信息失败");
}
return ok("查询通讯录信息失败");
}
}
package com.zjty.tynotes.weekly.subject.entity.vo;
import com.zjty.tynotes.pas.entity.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author gwj
* @create 2020/4/24 10:21
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SimpleUserVo {
@ApiModelProperty(value = "id",example = "1")
private String id;
@ApiModelProperty(value = "姓名",example = "gwj")
private String username;
@ApiModelProperty(value = "电话1",example = "13211111111")
private String phone1;
@ApiModelProperty(value = "岗位",example = "后端程序员")
private String jobs;
@ApiModelProperty(value = "邮箱",example = "123456789@qq.com")
private String email;
public SimpleUserVo(User user) {
this.id = user.getId();
this.username = user.getUsername();
this.phone1 = user.getPhone1();
this.jobs = user.getJobs();
this.email = user.getEmail();
}
}
......@@ -27,7 +27,7 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
public class UserVo {
@Id
@ApiModelProperty(value = "id",example = "1")
private String id;
......
......@@ -5,6 +5,7 @@ import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
import java.text.ParseException;
......@@ -78,6 +79,12 @@ public interface UserManageService {
*/
Problem putProblem(Problem problem);
/**
* 查询通讯录信息
* @return
*/
List<SimpleUserVo> findAddressBook();
// /**
// * 根据任务状态查询人员任务列表
// * @param id
......
......@@ -11,6 +11,7 @@ import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.dao.ProblemDao;
import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
import com.zjty.tynotes.weekly.subject.service.UserManageService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -345,6 +346,24 @@ public class UserManageServiceImpl implements UserManageService {
return problemDao.save(problem);
}
/**
* 查询通讯录信息
* @return
*/
@Override
public List<SimpleUserVo> findAddressBook() {
List<User> users = pasUserDao.findAll();
List<SimpleUserVo> userList = new ArrayList<>();
if(users!=null){
users.forEach(user -> {
if(user.getUsername()!="root" && user.getUsername()!="HR"){
userList.add(new SimpleUserVo(user));
}
});
}
return userList;
}
/**
* 暂时没有用到
* @param des
......
......@@ -38,6 +38,7 @@
<module>notes-redis</module>
<module>notes-weekly</module>
<module>notes-attendance</module>
<module>notes-log</module>
</modules>
<dependencyManagement>
......@@ -97,6 +98,12 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-log</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论