Pārlūkot izejas kodu

fix: 用户注册接口-异常事务回滚失效;需要把注解放到controller层

wuweihao 4 gadi atpakaļ
vecāks
revīzija
ffeca998a5

+ 1 - 0
gis_admin/src/main/java/com/gis/admin/controller/SysUserController.java

@@ -16,6 +16,7 @@ import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.transaction.Transactional;
 import javax.validation.Valid;
 
 /**

+ 0 - 3
gis_admin/src/main/java/com/gis/admin/service/impl/SysUserServiceImpl.java

@@ -22,7 +22,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 import tk.mybatis.mapper.entity.Condition;
 
 import java.time.LocalDateTime;
@@ -35,7 +34,6 @@ import java.util.Set;
  */
 @Slf4j
 @Service
-@Transactional
 public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> implements SysUserService {
 
     @Autowired
@@ -194,7 +192,6 @@ public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> im
         this.save(entity);
 
         // 设置默认角色, 2:sys_visitor游客角色
-//        int a = 1/0;
         Long userId = entity.getId();
         sysRoleService.saveUserRole(userId, Long.valueOf("2"));
 

+ 1 - 1
gis_application/src/main/resources/application-dev.properties

@@ -61,7 +61,7 @@ server.file.path=F:\\test\\ngin\\${project.en}_data
 #
 spring.mvc.static-path-pattern=/**
 ### \u5339\u914D\u8DEF\u5F84\uFF0C \u6CE8\u610Ffile\u540E\u9762\u7684/ \uFF0Cwindows:\\  , linxu:\u5168\u8DEF\u5F84, \u4E0D\u9700\u8981\u7279\u522B\u52A0\u659C\u6760
-spring.resources.static-locations=file:${server.file.path}
+spring.resources.static-locations=file:\\${server.file.path}
 
 # swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8
 swagger.package=com.gis

+ 10 - 1
gis_cms/src/main/java/com/gis/cms/controller/WebController.java

@@ -24,6 +24,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.transaction.Transactional;
 import javax.validation.Valid;
 
 
@@ -106,9 +107,17 @@ public class WebController {
         return newsService.search(param, 1);
     }
 
-    @WebControllerLog(description = "门户网站-用户注册")
+
+    /**
+     * 2021-07-12
+     * 回滚注解在这一层才有效, 在service不生效
+     * @param param
+     * @return
+     */
+    @WebControllerLog(description = "门户网站-用户注册", addDb = true)
     @ApiOperation("用户注册")
     @PostMapping("register")
+    @Transactional
     public Result register(@Valid @RequestBody RegisterDto param) {
         return sysUserService.register(param);
 

+ 5 - 3
gis_cms/src/main/java/com/gis/cms/tree/CommentTreeUtil.java

@@ -14,10 +14,12 @@ public class CommentTreeUtil {
     private List<CommentTree> resultNodes = new ArrayList<CommentTree>();//树形结构排序之后list内容
 
     private List<CommentTree> nodes = new ArrayList<CommentTree>();
-    //传入list参数
-
-    //过滤敏感词
 
+    /**
+     *
+     * @param nodesList 转换对象
+     * @param filterKey 敏感词集合
+     */
     public CommentTreeUtil(List<CommentVo> nodesList, Set<String> filterKey) {//通过构造函数初始化
 
         for (CommentVo n : nodesList) {

+ 0 - 1
gis_common/src/main/java/com/gis/common/base/service/impl/IBaseServiceImpl.java

@@ -29,7 +29,6 @@ import java.util.List;
  * Created by owen on 2020/2/18 0018 11:22
  */
 @Slf4j
-//@Transactional
 public abstract class IBaseServiceImpl<T extends BaseEntity, ID extends Serializable> implements IBaseService<T, ID> {