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

log

上级 daf1ee60
...@@ -107,10 +107,12 @@ public class WorkController { ...@@ -107,10 +107,12 @@ public class WorkController {
@RequestParam String userId, @RequestParam String userId,
@RequestParam int workloadCount, @RequestParam int workloadCount,
@RequestParam String msg) { @RequestParam String msg) {
Work work = workService.findById(workId);
workService.deleteWork(workId,personalWorkload,workloadCount); workService.deleteWork(workId,personalWorkload,workloadCount);
businessTreeManagement.saveAction(userId,workId,Action.DELETE_WORK,new Date(),msg); businessTreeManagement.saveAction(userId,workId,Action.DELETE_WORK,new Date(),msg);
logService.saveLog(new Log(null,"删除任务",new Date(),userId,null)); if(work!=null){
logService.saveLog(new Log(null,"删除任务"+work.getTitle(),new Date(),userId,null));
}
return ok(new JobResponse(workId)); return ok(new JobResponse(workId));
} }
...@@ -127,10 +129,12 @@ public class WorkController { ...@@ -127,10 +129,12 @@ public class WorkController {
@PutMapping(value = "/upDate/Workload") @PutMapping(value = "/upDate/Workload")
@ApiOperation(value = "修改任务的工作量、考评系数.") @ApiOperation(value = "修改任务的工作量、考评系数.")
public ResponseEntity<JobResponse> updateWorkload(@RequestBody UpdateWorkload updateWorkload) { public ResponseEntity<JobResponse> updateWorkload(@RequestBody UpdateWorkload updateWorkload) {
Work work = workService.findById(updateWorkload.getWorkId());
workService.updateWorkload(updateWorkload.getWorkId(),updateWorkload.getWorkload(),updateWorkload.getWorkCoefficient()); workService.updateWorkload(updateWorkload.getWorkId(),updateWorkload.getWorkload(),updateWorkload.getWorkCoefficient());
businessTreeManagement.saveAction(updateWorkload.getUserId(),updateWorkload.getWorkId(),Action.UPDATE_WORKLOAD,new Date(),updateWorkload.getMsg()); businessTreeManagement.saveAction(updateWorkload.getUserId(),updateWorkload.getWorkId(),Action.UPDATE_WORKLOAD,new Date(),updateWorkload.getMsg());
logService.saveLog(new Log(null,"修改任务的工作量",new Date(),updateWorkload.getUserId(),null)); if(work!=null){
logService.saveLog(new Log(null,"修改" + work.getTitle() + "任务的工作量",new Date(),updateWorkload.getUserId(),null));
}
return ok(new JobResponse(updateWorkload.getWorkId())); return ok(new JobResponse(updateWorkload.getWorkId()));
} }
...@@ -148,7 +152,11 @@ public class WorkController { ...@@ -148,7 +152,11 @@ public class WorkController {
@RequestParam String status, @RequestParam String status,
@RequestParam String msg, @RequestParam String msg,
@RequestParam String re) { @RequestParam String re) {
Work workServiceById = workService.findById(workId);
String title = null;
if(workServiceById!=null){
title = workServiceById.getTitle();
}
switch (status) { switch (status) {
case "ongoing": case "ongoing":
Work work=workService.findById(workId); Work work=workService.findById(workId);
...@@ -157,30 +165,30 @@ public class WorkController { ...@@ -157,30 +165,30 @@ public class WorkController {
//撤回 //撤回
workService.alterTaskStatus1(workId,status,userId); workService.alterTaskStatus1(workId,status,userId);
businessTreeManagement.saveAction(userId,workId,Action.COMMIT_BACK_WORK,new Date(),msg); businessTreeManagement.saveAction(userId,workId,Action.COMMIT_BACK_WORK,new Date(),msg);
logService.saveLog(new Log(null,"撤回任务",new Date(),userId,null)); logService.saveLog(new Log(null,"撤回任务"+title,new Date(),userId,null));
}else{ }else{
workService.alterTaskStatus(workId,status,userId); workService.alterTaskStatus(workId,status,userId);
businessTreeManagement.saveAction(userId,workId,Action.BACK_WORK,new Date(),msg); businessTreeManagement.saveAction(userId,workId,Action.BACK_WORK,new Date(),msg);
//审核不通过 //审核不通过
logService.saveLog(new Log(null,"审核任务",new Date(),userId,null)); logService.saveLog(new Log(null,"审核任务"+title,new Date(),userId,null));
} }
break; break;
case "audit": case "audit":
//执行者提交 //执行者提交
workService.alterTaskStatus(workId, status,userId); workService.alterTaskStatus(workId, status,userId);
businessTreeManagement.saveAction(userId, workId, Action.COMMIT_WORK, new Date(), msg); businessTreeManagement.saveAction(userId, workId, Action.COMMIT_WORK, new Date(), msg);
logService.saveLog(new Log(null,"提交任务",new Date(),userId,null)); logService.saveLog(new Log(null,"提交任务"+title,new Date(),userId,null));
break; break;
case "review": case "review":
//审核通过 //审核通过
workService.alterTaskStatus(workId, status,userId); workService.alterTaskStatus(workId, status,userId);
businessTreeManagement.saveAction(userId, workId, Action.FINISH_WORK, new Date(), msg); businessTreeManagement.saveAction(userId, workId, Action.FINISH_WORK, new Date(), msg);
logService.saveLog(new Log(null,"审核任务",new Date(),userId,null)); logService.saveLog(new Log(null,"审核任务"+title,new Date(),userId,null));
break; break;
case WorkStatus.FINISHED: case WorkStatus.FINISHED:
workService.alterTaskStatus(workId, status,userId); workService.alterTaskStatus(workId, status,userId);
businessTreeManagement.saveAction(userId, workId, Action.FINISHED_WORK, new Date(), msg); businessTreeManagement.saveAction(userId, workId, Action.FINISHED_WORK, new Date(), msg);
logService.saveLog(new Log(null,"完结任务",new Date(),userId,null)); logService.saveLog(new Log(null,"完结任务"+title,new Date(),userId,null));
break; break;
default: default:
log.warn("[job] 修改任务状态传入的参数有误,传入值为:{}", status); log.warn("[job] 修改任务状态传入的参数有误,传入值为:{}", status);
......
...@@ -54,6 +54,9 @@ public class ControllerAspect { ...@@ -54,6 +54,9 @@ public class ControllerAspect {
@Pointcut("execution(public * com.zjty.tynotes.attendance.controller.*.*(..))") @Pointcut("execution(public * com.zjty.tynotes.attendance.controller.*.*(..))")
public void privilege3(){} 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.*.*(..))") // @Pointcut("execution(public * com.zjty.tynotes.weekly.subject.controller.*.*(..))")
// public void privilege4(){} // public void privilege4(){}
...@@ -62,7 +65,7 @@ public class ControllerAspect { ...@@ -62,7 +65,7 @@ public class ControllerAspect {
* @param joinPoint * @param joinPoint
* @throws Throwable * @throws Throwable
*/ */
@Around("privilege1() || privilege3()") @Around("privilege1() || privilege3()||privilege4()")
public Object isLogMethod(ProceedingJoinPoint joinPoint) throws Throwable { public Object isLogMethod(ProceedingJoinPoint joinPoint) throws Throwable {
try { try {
// 接收到请求,记录请求内容 // 接收到请求,记录请求内容
...@@ -107,11 +110,13 @@ public class ControllerAspect { ...@@ -107,11 +110,13 @@ public class ControllerAspect {
} }
} }
Object proceed = joinPoint.proceed();
return proceed;
}catch (Exception e){ }catch (Exception e){
Object proceed = joinPoint.proceed();
e.printStackTrace(); e.printStackTrace();
logger.error("aop日志记录出现异常:{}",e.getMessage()); logger.error("aop日志记录出现异常:{}",e.getMessage());
return proceed;
} }
return null;
} }
} }
...@@ -25,4 +25,5 @@ public interface LogDao extends MongoRepository<Log,String> { ...@@ -25,4 +25,5 @@ public interface LogDao extends MongoRepository<Log,String> {
* @return * @return
*/ */
List<Log> findAllByLogTimeBetween(Date start,Date end); List<Log> findAllByLogTimeBetween(Date start,Date end);
} }
...@@ -13,9 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,9 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Optional;
/** /**
* @Author gwj * @Author gwj
...@@ -78,6 +76,12 @@ public class LogServiceImpl implements LogService { ...@@ -78,6 +76,12 @@ public class LogServiceImpl implements LogService {
logs = all; 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.setPageSize(pageRequest.getPageSize());
pageResponse.setCurrentPage(pageRequest.getCurrentPage()); pageResponse.setCurrentPage(pageRequest.getCurrentPage());
int currentPage = pageRequest.getCurrentPage(); int currentPage = pageRequest.getCurrentPage();
......
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 { ...@@ -56,6 +56,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
httpSecurity httpSecurity
.cors().and() .cors().and()
.authorizeRequests() .authorizeRequests()
.antMatchers("/pas/excel/upload").permitAll()
.antMatchers("/pas/user/findPublishUsers").permitAll() .antMatchers("/pas/user/findPublishUsers").permitAll()
.antMatchers("/ding/test/**").permitAll() .antMatchers("/ding/test/**").permitAll()
.antMatchers("/pas/user/judgeParent/**").permitAll() .antMatchers("/pas/user/judgeParent/**").permitAll()
......
package com.zjty.tynotes.pas.config.handler; package com.zjty.tynotes.pas.config.handler;
import com.fasterxml.jackson.databind.ObjectMapper; 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.Authority;
import com.zjty.tynotes.pas.entity.Role; import com.zjty.tynotes.pas.entity.Role;
import com.zjty.tynotes.pas.dao.AuthorityDao; import com.zjty.tynotes.pas.dao.AuthorityDao;
...@@ -74,6 +75,7 @@ public class MySuccessHandler implements AuthenticationSuccessHandler { ...@@ -74,6 +75,7 @@ public class MySuccessHandler implements AuthenticationSuccessHandler {
RedisTemplate redisTemplate; RedisTemplate redisTemplate;
@Override @Override
@Content(value = "登录操作")
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
Cookie[] cookies = httpServletRequest.getCookies(); Cookie[] cookies = httpServletRequest.getCookies();
if(cookies==null){ if(cookies==null){
......
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);
}
}
...@@ -160,4 +160,5 @@ public class UserController { ...@@ -160,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 { ...@@ -176,6 +176,10 @@ public class UserServiceImpl implements IUserService {
return pasUserDao.findAllByIdIn(ids); return pasUserDao.findAllByIdIn(ids);
} }
/**
* 查询所有用户
* @return
*/
@Override @Override
public List<User> findAll() { public List<User> findAll() {
List<User> userList = new ArrayList<>(); List<User> userList = new ArrayList<>();
...@@ -256,6 +260,12 @@ public class UserServiceImpl implements IUserService { ...@@ -256,6 +260,12 @@ public class UserServiceImpl implements IUserService {
return save; return save;
} }
/**
* 是否有某个权限
* @param userId
* @param authorityName
* @return
*/
@Override @Override
public boolean isHaveAuthority(String userId, String authorityName) { public boolean isHaveAuthority(String userId, String authorityName) {
List<UserRole> userRoles = userRoleDao.findAllByUserId(userId); List<UserRole> userRoles = userRoleDao.findAllByUserId(userId);
...@@ -324,6 +334,12 @@ public class UserServiceImpl implements IUserService { ...@@ -324,6 +334,12 @@ public class UserServiceImpl implements IUserService {
return null; return null;
} }
/**
* 查询能够分解权限、发布权限给哪些人
* @param userId
* @param authoryName
* @return
*/
@Override @Override
public List<User> findUserList(String userId,String authoryName){ public List<User> findUserList(String userId,String authoryName){
List<String> departmentList = findDepartmentList(userId,authoryName); List<String> departmentList = findDepartmentList(userId,authoryName);
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>notes-union</artifactId> <artifactId>notes-union</artifactId>
<!--<packaging>jar</packaging>--> <packaging>jar</packaging>
<packaging>war</packaging> <!--<packaging>war</packaging>-->
<profiles> <profiles>
<!--模拟环境--> <!--模拟环境-->
<profile> <profile>
...@@ -33,26 +33,26 @@ ...@@ -33,26 +33,26 @@
<dependencies> <dependencies>
<!-- 排除内置的tomcat --> <!--&lt;!&ndash; 排除内置的tomcat &ndash;&gt;-->
<dependency> <!--<dependency>-->
<groupId>org.springframework.boot</groupId> <!--<groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-web</artifactId> <!--<artifactId>spring-boot-starter-web</artifactId>-->
<exclusions> <!--<exclusions>-->
<exclusion> <!--<exclusion>-->
<groupId>org.springframework.boot</groupId> <!--<groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-tomcat</artifactId> <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
</exclusion> <!--</exclusion>-->
</exclusions> <!--</exclusions>-->
</dependency> <!--</dependency>-->
<!-- 使用自带的tomcat --> <!--&lt;!&ndash; 使用自带的tomcat &ndash;&gt;-->
<dependency> <!--<dependency>-->
<groupId>org.springframework.boot</groupId> <!--<groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-tomcat</artifactId> <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
<!--打包的时候可以不用包进去,别的设施会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。 <!--&lt;!&ndash;打包的时候可以不用包进去,别的设施会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。-->
相当于compile,但是打包阶段做了exclude操作--> <!--相当于compile,但是打包阶段做了exclude操作&ndash;&gt;-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
......
...@@ -32,12 +32,14 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -32,12 +32,14 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
}) })
@EnableCaching @EnableCaching
@EnableScheduling @EnableScheduling
public class UnionApplication extends SpringBootServletInitializer { public class UnionApplication
// extends SpringBootServletInitializer
{
@Override // @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(UnionApplication.class); // return builder.sources(UnionApplication.class);
} // }
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(UnionApplication.class, args); SpringApplication.run(UnionApplication.class, args);
......
...@@ -12,15 +12,15 @@ server.ssl.keyStoreType=PKCS12 ...@@ -12,15 +12,15 @@ server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias= alias server.ssl.keyAlias= alias
#mongodb configuration #mongodb configuration
spring.data.mongodb.uri=mongodb://localhost:27017/notes5 spring.data.mongodb.uri=mongodb://192.168.1.246:27017/notes5
# servlet configuration # servlet configuration
spring.servlet.multipart.max-file-size=100MB spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=1000MB spring.servlet.multipart.max-request-size=1000MB
spring.redis.host=localhost spring.redis.host=192.168.1.246
spring.redis.port=6379 spring.redis.port=6379
spring.redis.timeout=5000ms spring.redis.timeout=5000ms
# es configuraiton # es configuraiton
es.ip=localhost es.ip=192.168.1.246
logging.file=./log/note.log logging.file=./log/note.log
...@@ -35,6 +35,17 @@ ...@@ -35,6 +35,17 @@
</exclusions> </exclusions>
</dependency> </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> <dependency>
<groupId>com.zjty.tynotes</groupId> <groupId>com.zjty.tynotes</groupId>
<artifactId>notes-pas</artifactId> <artifactId>notes-pas</artifactId>
......
...@@ -10,7 +10,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -10,7 +10,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(scanBasePackages = { @SpringBootApplication(scanBasePackages = {
"com.zjty.tynotes.misc", "com.zjty.tynotes.misc",
"com.zjty.tynotes.pas" "com.zjty.tynotes.pas",
"com.zjty.tynotes.log",
"com.zjty.tynotes.job"
}) })
@EnableSwagger2 @EnableSwagger2
public class WeeklyApplication { public class WeeklyApplication {
......
package com.zjty.tynotes.weekly.subject.controller; 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.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content; import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.User; import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest; import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; 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.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.entity.vo.UserVo;
import com.zjty.tynotes.weekly.subject.service.UserManageService; import com.zjty.tynotes.weekly.subject.service.UserManageService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -13,15 +16,20 @@ import io.swagger.annotations.ApiOperation; ...@@ -13,15 +16,20 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.http.ResponseEntity;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date;
import java.util.List;
import static org.springframework.http.ResponseEntity.ok; import static org.springframework.http.ResponseEntity.ok;
...@@ -34,6 +42,10 @@ import static org.springframework.http.ResponseEntity.ok; ...@@ -34,6 +42,10 @@ import static org.springframework.http.ResponseEntity.ok;
@RequestMapping("/manage/user") @RequestMapping("/manage/user")
@AutoDocument @AutoDocument
public class UserManageController { public class UserManageController {
@Autowired
private LogService logService;
@Autowired @Autowired
private UserManageService userManageService; private UserManageService userManageService;
...@@ -81,6 +93,7 @@ public class UserManageController { ...@@ -81,6 +93,7 @@ public class UserManageController {
try { try {
User userById = userManageService.findUserById(user.getId()); User userById = userManageService.findUserById(user.getId());
User user1 = userManageService.updateSelf(user, userById); User user1 = userManageService.updateSelf(user, userById);
logService.saveLog(new Log(null,"更改自身信息",new Date(),user.getId(),user.getUsername()));
return ok(user1); return ok(user1);
} catch (Exception e) { } catch (Exception e) {
logger.error("更改当前用户自身信息失败"); logger.error("更改当前用户自身信息失败");
...@@ -90,17 +103,23 @@ public class UserManageController { ...@@ -90,17 +103,23 @@ public class UserManageController {
@Content(value = "更新当前用户密码") @Content(value = "更新当前用户密码")
@ApiOperation(value = "更新当前用户密码") @ApiOperation(value = "更新当前用户密码")
@PutMapping("/password") @PutMapping("/password/{oldPass}")
public ResponseEntity updatePassword(@RequestBody @NotNull User user){ public ResponseEntity updatePassword(@PathVariable String oldPass,@RequestBody @NotNull User user){
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
User principal = (User) authentication.getPrincipal(); System.out.println(oldPass);
User userByUsername = userManageService.findfindUserByUsername(principal.getUsername()); User userByUsername = userManageService.findfindUserByUsername(user.getUsername());
userByUsername.setPassword(user.getPassword()); System.out.println(userByUsername.getPassword());
boolean b = userManageService.updatePas(userByUsername);
if(b){ if(bCryptPasswordEncoder.matches(oldPass,userByUsername.getPassword())){
return ok("更改密码成功"); 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 = "上传建议以及使用中的问题") @ApiOperation(value = "上传建议以及使用中的问题")
...@@ -121,5 +140,17 @@ public class UserManageController { ...@@ -121,5 +140,17 @@ public class UserManageController {
return ok(userManageService.putProblem(problem)); 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; ...@@ -27,7 +27,7 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class UserVo { public class UserVo {
@Id
@ApiModelProperty(value = "id",example = "1") @ApiModelProperty(value = "id",example = "1")
private String id; private String id;
......
...@@ -5,6 +5,7 @@ import com.zjty.tynotes.pas.entity.User; ...@@ -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.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; 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.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.entity.vo.UserVo;
import java.text.ParseException; import java.text.ParseException;
...@@ -78,6 +79,12 @@ public interface UserManageService { ...@@ -78,6 +79,12 @@ public interface UserManageService {
*/ */
Problem putProblem(Problem problem); Problem putProblem(Problem problem);
/**
* 查询通讯录信息
* @return
*/
List<SimpleUserVo> findAddressBook();
// /** // /**
// * 根据任务状态查询人员任务列表 // * 根据任务状态查询人员任务列表
// * @param id // * @param id
......
...@@ -11,6 +11,7 @@ import com.zjty.tynotes.pas.entity.vo.PageRequest; ...@@ -11,6 +11,7 @@ import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.dao.ProblemDao; 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.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.entity.vo.UserVo;
import com.zjty.tynotes.weekly.subject.service.UserManageService; import com.zjty.tynotes.weekly.subject.service.UserManageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -345,6 +346,24 @@ public class UserManageServiceImpl implements UserManageService { ...@@ -345,6 +346,24 @@ public class UserManageServiceImpl implements UserManageService {
return problemDao.save(problem); 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 * @param des
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论