Przeglądaj źródła

修改基础功能bug

zhoupeng 1 rok temu
rodzic
commit
e122c2b130

+ 3 - 0
chaunyi_opc/opc_common/src/main/java/com/example/opc_common/entity/Role.java

@@ -4,6 +4,7 @@ import com.example.opc_common.util.ConstantStr;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.Date;
 import java.util.List;
 
 @Data
@@ -28,4 +29,6 @@ public class Role implements Serializable {
     private Integer isDelete = ConstantStr.PUBLIC_NO_DELETE;
 
     private List<Menu> menuList;
+
+    private Date createTime;
 }

+ 2 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/controller/DataSourceController.java

@@ -161,6 +161,7 @@ public class DataSourceController {
      * @return
      */
     @PostMapping("/addDataSourceDriver")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DATASOURCE, OperationEnum = OperationEnum.ADD)
     public Result addDataSourceDriver(@RequestBody DataSourceDriver dataSourceDriver) {
         if (Blank.isEmpty(dataSourceDriver, dataSourceDriver.getDriverName(), dataSourceDriver.getClsId())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据源驱动名称、驱动不能为空");
@@ -175,6 +176,7 @@ public class DataSourceController {
      * @return
      */
     @PostMapping("/updateDataSourceDriver")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DATASOURCE, OperationEnum = OperationEnum.UPDATE)
     public Result updateDataSourceDriver(@RequestBody DataSourceDriver dataSourceDriver) {
         if (Blank.isEmpty(dataSourceDriver, dataSourceDriver.getId(), dataSourceDriver.getDriverName(), dataSourceDriver.getClsId())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据源id、驱动名称、驱动不能为空");

+ 2 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/dao/PermissionDao.java

@@ -27,6 +27,8 @@ public interface PermissionDao {
 
     Integer deleteMenuPermissionById(Integer permissionId);
 
+    Integer getPermissionMenuByCount(Integer permissionId);
+
     /**
      * 查询权限所属菜单
      */

+ 3 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/PermissionServiceImpl.java

@@ -67,6 +67,9 @@ public class PermissionServiceImpl implements PermissionService {
 
     @Override
     public synchronized Result deletePermissionById(Integer id) {
+        if (permissionDao.getPermissionMenuByCount(id) > 0) {
+            return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "该权限已被使用");
+        }
         if (permissionDao.deletePermissionById(id) <= 0) {
             return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "删除权限失败");
         }

+ 8 - 5
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/UserServiceImpl.java

@@ -85,7 +85,7 @@ public class UserServiceImpl implements UserService {
         }
         Integer userName = userDao.queryUserName(user.getUserName());
         if (userName <= 0) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "帐号不存在");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "帐号或密码不正确");
         }
         User isExistUser = userDao.getUserByNamePass(user.getUserName(), EncryptUtils.StrToMD5(user.getPassword()));
 //        // 校验验证码
@@ -173,7 +173,7 @@ public class UserServiceImpl implements UserService {
         //判断账号是否存在
         Integer userName = userDao.queryUserName(user.getUserName());
         if (userName <= 0) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "帐号不存在");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "帐号或密码不正确");
         }
         // 校验验证码
 //        String storeCode = Convert.toStr(redisUtil.get(user.getUid() + "-captcha"));
@@ -483,12 +483,15 @@ public class UserServiceImpl implements UserService {
             throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
         if (Blank.isEmpty(oldPassword, newPassword)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据有误");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "参数错误");
+        }
+        if (oldPassword.equals(newPassword)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "新密码与原密码不能一致");
         }
         //判断原始密码是否正确
         User isExistUser = userDao.getUserByNamePassByUpdate(user.getUserName(), EncryptUtils.StrToMD5(oldPassword));
         if (isExistUser == null) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "用户不存在");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "原密码不正确");
         }
         //修改密码
         user.setNewPassword(EncryptUtils.StrToMD5(newPassword));
@@ -613,7 +616,7 @@ public class UserServiceImpl implements UserService {
         }
         Integer userName = userDao.queryUserName(user.getUserName());
         if (userName <= 0) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "帐号不存在");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "帐号或密码不正确");
         }
         User isExistUser = userDao.getUserByNamePass(user.getUserName(), EncryptUtils.StrToMD5(user.getPassword()));
         if (Blank.isEmpty(isExistUser)) {

+ 7 - 1
chaunyi_opc/opc_da/src/main/resources/mapper/PermissionDao.xml

@@ -24,6 +24,12 @@
         where permission_id = #{permissionId}
     </delete>
 
+    <select id="getPermissionMenuByCount" resultType="Integer">
+        select count(1)
+        from sys_menu_permission
+        where permission_id = #{permissionId}
+    </select>
+
     <select id="getPermissionByUrl" resultType="com.example.opc_common.entity.Permission">
         select id, permission_url, permission_name
         from sys_permission
@@ -86,4 +92,4 @@
         SELECT count(*) FROM sys_menu WHERE id IN (SELECT menu_id from sys_menu_permission WHERE permission_id=#{permissionId})
     </select>
 
-</mapper>
+</mapper>

+ 9 - 7
chaunyi_opc/opc_da/src/main/resources/mapper/RoleDao.xml

@@ -3,8 +3,8 @@
 <mapper namespace="com.example.opc_da.dao.RoleDao">
 
     <insert id="addRole">
-        INSERT INTO sys_role (role_name, role_code, is_delete)
-            VALUE (#{roleName}, #{roleCode}, #{isDelete})
+        INSERT INTO sys_role (role_name, role_code, is_delete, create_time)
+            VALUE (#{roleName}, #{roleCode}, #{isDelete}, NOW())
     </insert>
 
     <insert id="addRoleMenuList">
@@ -43,14 +43,15 @@
     <select id="getRoleByName" resultType="com.example.opc_common.entity.Role">
         SELECT id,
                role_name,
-               role_code
+               role_code,
+               create_time
         FROM sys_role
         WHERE role_name = #{roleName}
         and is_delete !=1
     </select>
 
     <select id="getRoleByNoIdName" resultType="com.example.opc_common.entity.Role">
-        select id, role_name
+        select id, role_name, create_time
         from sys_role
         where id != #{id}
         and role_name = #{roleName}
@@ -70,7 +71,7 @@
     </select>
 
     <select id="getRoleListByPage" resultType="com.example.opc_common.entity.Role">
-        select id, role_name, role_code
+        select id, role_name, role_code, create_time
         from sys_role
         where is_delete=#{noDelete}
         <if test="roleName != null">
@@ -79,11 +80,12 @@
         <if test="roleCode != null">
             AND role_code LIKE CONCAT('%', #{roleCode}, '%')
         </if>
+        order by create_time desc
         limit #{startNum},#{limitNum}
     </select>
 
     <select id="getRoleById" resultType="com.example.opc_common.entity.Role">
-        select id, role_name
+        select id, role_name, create_time
         from sys_role
         where id = #{id}
           and is_delete = #{noDelete}
@@ -370,4 +372,4 @@
         SELECT count(*) FROM sys_role WHERE is_delete = #{PUBLIC_NO_DELETE}
     </select>
 
-</mapper>
+</mapper>