liurunyu
2024-04-24 e430bfca38cdae9dd230f951e108a75caebccb61
完善代码
2 文件已重命名
5个文件已修改
1个文件已删除
93 ■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/Log.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/QueryVo.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/Log.java
File was renamed from pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationDescription.java
@@ -7,6 +7,6 @@
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface OperationDescription {
public @interface Log {
    String value();
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
File was renamed from pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationLogAspect.java
@@ -27,7 +27,7 @@
@Aspect
@Component
public class OperationLogAspect {
public class LogAspect {
    @Value("${pms.sso.curUserUrl}")
    public String SsoCurUserUrl ;
@@ -43,11 +43,11 @@
        this.restTemplate = restTemplate ;
    }
    @AfterReturning(pointcut = "@annotation(com.dy.pmsGlobal.aop.OperationDescription)", returning = "result")
    @AfterReturning(pointcut = "@annotation(com.dy.pmsGlobal.aop.Log)", returning = "result")
    public void logAfterReturning(JoinPoint joinPoint, Object result) {
        // 获取方法的中文描述
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        OperationDescription operationDescription = methodSignature.getMethod().getAnnotation(OperationDescription.class);
        Log operationDescription = methodSignature.getMethod().getAnnotation(Log.class);
        String operationName = operationDescription.value();
        //结果
        BaseResponse response = (BaseResponse)result;
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java
@@ -26,32 +26,4 @@
        dao.insert(log);
    }
    /**
     * 得到日志
     *
     * @param id 日志ID
     * @return 实体
     */
    public BaLog selectById(Long id) {
        return dao.selectByPrimaryKey(id);
    }
    /**
     * 获取日志列表
     */
    public QueryResultVo<List<BaLog>> selectSome(QueryVo queryVo) {
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        //查询符合条件的记录总数
        Long itemTotal = dao.selectSomeCount(params);
        QueryResultVo<List<BaLog>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
        //计算分页等信息
        rsVo.calculateAndSet(itemTotal, params);
        //查询符合条件的记录
        rsVo.obj = this.dao.selectSome(params) ;
        return rsVo ;
    }
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/QueryVo.java
File was deleted
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java
@@ -5,8 +5,7 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.aop.LogSv;
import com.dy.pmsGlobal.aop.OperationDescription;
import com.dy.pmsGlobal.aop.QueryVo;
import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +31,7 @@
     */
    @GetMapping(path = "one")
    @SsoPowerAop(power = "10100010") //登录与权限同时验证
    @OperationDescription("查询单条日志")
    @Log("查询单条日志")
    public BaseResponse<BaLog> one(String id){
        try {
            return BaseResponseUtils.buildSuccess(sv.selectById(Long.parseLong(id)));
@@ -48,7 +47,7 @@
     */
    @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoPowerAop(power = "10100010") //登录与权限同时验证
    @OperationDescription("分页查询日志")
    @Log("分页查询日志")
    public BaseResponse<QueryResultVo<List<BaLog>>> some(@RequestBody QueryVo vo){
        try {
            QueryResultVo<List<BaLog>> res = sv.selectSome(vo);
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java
@@ -5,7 +5,7 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.aop.OperationDescription;
import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaRole;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
@@ -37,7 +37,7 @@
     */
    @PostMapping(path="save")
    @SsoPowerAop(power = "10100011")
    @OperationDescription("保存角色信息")
    @Log("保存角色信息")
    public BaseResponse<BaRole> save(@RequestBody @Valid BaRole role,BindingResult bindingResult){
        try {
            role.setDeleted(false);
@@ -58,7 +58,7 @@
     */
    @PostMapping(path="update")
    @SsoPowerAop(power = "10100011")
    @OperationDescription("更新角色信息")
    @Log("更新角色信息")
    public BaseResponse<BaRole> update(@RequestBody @Valid BaRole role,BindingResult bindingResult){
        try {
            return BaseResponseUtils.buildSuccess(roleSv.update(role));
@@ -76,7 +76,7 @@
     */
    @PostMapping(path="delete")
    @SsoPowerAop(power = "10100011")
    @OperationDescription("删除角色信息")
    @Log("删除角色信息")
    public BaseResponse<BaRole> delete(String id,BindingResult bindingResult){
        try {
            return BaseResponseUtils.buildSuccess(roleSv.delete(Long.parseLong(id)));
@@ -93,7 +93,7 @@
     */
    @GetMapping(path="one")
    @SsoPowerAop(power = "10100010") //登录与权限同时验证
    @OperationDescription("根据ID查询角色信息")
    @Log("根据ID查询角色信息")
    public BaseResponse<BaRole> one(String id){
        try{
            BaRole role=roleSv.selectById(id);
@@ -111,7 +111,7 @@
     */
    @PostMapping(path="some")
    @SsoPowerAop(power = "10100010")
    @OperationDescription("分页查询角色信息")
    @Log("分页查询角色信息")
    public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody QueryVo vo){
        try {
            QueryResultVo<List<BaRole>> list = roleSv.selectSome(vo) ;
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
@@ -6,7 +6,7 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.aop.OperationDescription;
import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.util.Constant;
import com.mysql.cj.util.StringUtils;
@@ -45,7 +45,7 @@
     * @return 默认密码
     */
    @GetMapping(path = "defaultPassword")
    @OperationDescription("客户端请求得到默认密码")
    @Log("客户端请求得到默认密码")
    public BaseResponse<String> defaultPassword(){
        if(defaultTrueRandomFalsePassword){
            return BaseResponseUtils.buildSuccess(defaultPassword) ;
@@ -62,7 +62,7 @@
    @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop() //只有登录验证,没有权限验证
    @SsoPowerAop(power = "10100010") //登录与权限同时验证
    @OperationDescription("分页查询用户")
    @Log("分页查询用户")
    public BaseResponse<QueryResultVo<List<BaUser>>> some(@RequestBody QueryVo vo) {
        try {
            QueryResultVo<List<BaUser>> res = this.sv.selectSome(vo);
@@ -81,7 +81,7 @@
    @GetMapping(path = "one")
    //@SsoAop() //只有登录验证,没有权限验证
    @SsoPowerAop(power = "10100010") //登录与权限同时验证
    @OperationDescription("查询单个用户")
    @Log("查询单个用户")
    public BaseResponse<BaUser> one(String id) {
        try {
            return BaseResponseUtils.buildSuccess(this.sv.selectById(Long.parseLong(id)));
@@ -100,7 +100,7 @@
    @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop() //只有登录验证,没有权限验证
    @SsoPowerAop(power = "10100011") //登录与权限同时验证
    @OperationDescription("保存用户信息")
    @Log("保存用户信息")
    public BaseResponse<Boolean> save(@RequestBody @Valid BaUser po, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
@@ -141,7 +141,7 @@
    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop() //只有登录验证,没有权限验证
    @SsoPowerAop(power = "10100011") //登录与权限同时验证
    @OperationDescription("更新用户信息")
    @Log("更新用户信息")
    public BaseResponse<Boolean> update(@RequestBody @Validated BaUser po, BindingResult bindingResult) {
        int count;
        try {
@@ -174,7 +174,7 @@
    //@GetMapping(path = "changePassword", consumes = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping(path = "changePassword")
    @SsoAop()
    @OperationDescription("修改密码")
    @Log("修改密码")
    public BaseResponse<Boolean> changePassword(String id, String oldPassword, String newPassword) {
        int count;
        try {
@@ -227,7 +227,7 @@
    @PostMapping(path = "resetPassword", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop() //只有登录验证,没有权限验证
    @SsoPowerAop(power = "10100011") //登录与权限同时验证
    @OperationDescription("重置密码")
    @Log("重置密码")
    public BaseResponse<Boolean> resetPassword(@RequestBody @Validated ResetPasswordVo vo, BindingResult bindingResult) {
        int count;
        try {
pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -4,7 +4,7 @@
import com.dy.common.util.MD5;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pmsGlobal.aop.OperationDescription;
import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.mysql.cj.util.StringUtils;
import jakarta.servlet.http.HttpServletRequest;
@@ -46,7 +46,7 @@
     * @return 登录用户值对象
     */
    @PostMapping(path = "login", consumes = MediaType.APPLICATION_JSON_VALUE)//前端提交json数据
    @OperationDescription("用户登录(json)")
    @Log("用户登录(json)")
    public BaseResponse<UserVo> login(@RequestBody  @Valid LoginVo vo, BindingResult bindingResult) {
        try {
            if(bindingResult != null && bindingResult.hasErrors()){
@@ -65,7 +65,7 @@
     * @return 登录用户值对象
     */
    @PostMapping(path = "loginForm", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)//前端提交form表单数据
    @OperationDescription("用户登录(form)")
    @Log("用户登录(form)")
    public BaseResponse<UserVo> loginForm(@RequestBody @Valid LoginVo vo, BindingResult bindingResult){
        try{
            if(bindingResult != null && bindingResult.hasErrors()){
@@ -85,7 +85,7 @@
     * @return 正常退出登录返回true,否则返回false
     */
    @GetMapping(path = "logout")
    @OperationDescription("退出登录")
    @Log("退出登录")
    public BaseResponse<Boolean> logout(HttpServletRequest hr){
        try{
            String token = hr.getHeader("token") ;