浏览代码

意见反馈

刘俊驰 7 月之前
父节点
当前提交
131d1bb022

+ 42 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/SysSuggestionController.java

@@ -1,19 +1,26 @@
 package com.yonge.cooleshow.student.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.admin.io.request.SysSuggestionVo;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
+import com.yonge.cooleshow.biz.dal.entity.SysSuggestionV2;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.SysSuggestionService;
+import com.yonge.cooleshow.biz.dal.service.SysSuggestionV2Service;
 import com.yonge.cooleshow.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
 
 @Api(tags = "意见反馈")
 @RestController
@@ -28,6 +35,8 @@ public class SysSuggestionController extends BaseController {
     @Autowired
     private StudentService studentService;
 
+    @Autowired
+    private SysSuggestionV2Service sysSuggestionV2Service;
     @ApiOperation(value = "新增")
     @RequestMapping("sysSuggestion/add")
     public Object add(SysSuggestion sysSuggestion) {
@@ -50,4 +59,35 @@ public class SysSuggestionController extends BaseController {
         return succeed();
     }
 
+
+    /**
+     * 新增
+     *
+     * @param suggestion SysSuggestionVo.SysSuggestion
+     * @return R<Boolean>
+     */
+    @ApiOperation(value = "新增", notes = "传入sysSuggestion")
+    @PostMapping("sysSuggestion/save")
+    public R<Boolean> add(@Validated @RequestBody SysSuggestionVo.SysSuggestion suggestion,
+                          @RequestHeader(name = "user-agent") String userAgent) {
+        com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserFeignService.queryUserInfo();
+        suggestion.setUserId(sysUser.getId());
+        String userAgent1 = suggestion.getUserAgent();
+        if(StringUtils.isEmpty(userAgent1)){
+            userAgent1 = userAgent;
+        }
+        suggestion.setUserAgent(userAgent1);
+
+        Student student = studentService.getById(sysUser.getId());
+        if (student.getTenantId() != null && student.getTenantId() != -1) {
+            suggestion.setClientType(ClientEnum.TENANT_STUDENT);
+        } else {
+            suggestion.setClientType(ClientEnum.STUDENT);
+        }
+
+        SysSuggestionV2 sysSuggestion = JSON.parseObject(suggestion.jsonString(), SysSuggestionV2.class);
+        sysSuggestion.setCreateTime(new Date());
+        return R.from(sysSuggestionV2Service.add(sysSuggestion));
+    }
+
 }

+ 38 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/SysSuggestionController.java

@@ -1,16 +1,24 @@
 package com.yonge.cooleshow.teacher.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.admin.io.request.SysSuggestionVo;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
+import com.yonge.cooleshow.biz.dal.entity.SysSuggestionV2;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.service.SysSuggestionService;
+import com.yonge.cooleshow.biz.dal.service.SysSuggestionV2Service;
 import com.yonge.cooleshow.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
 
 @Api(tags = "意见反馈")
 @RestController
@@ -22,6 +30,9 @@ public class SysSuggestionController extends BaseController {
     @Autowired
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private SysSuggestionV2Service sysSuggestionV2Service;
+
     @ApiOperation(value = "新增")
     @RequestMapping("sysSuggestion/add")
     public Object add(SysSuggestion sysSuggestion) {
@@ -38,4 +49,29 @@ public class SysSuggestionController extends BaseController {
         return succeed();
     }
 
+
+    /**
+     * 新增
+     *
+     * @param suggestion SysSuggestionVo.SysSuggestion
+     * @return R<Boolean>
+     */
+    @ApiOperation(value = "新增", notes = "传入sysSuggestion")
+    @PostMapping("sysSuggestion/save")
+    public R<Boolean> add(@Validated @RequestBody SysSuggestionVo.SysSuggestion suggestion,
+                          @RequestHeader(name = "user-agent") String userAgent) {
+        com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserFeignService.queryUserInfo();
+        suggestion.setUserId(sysUser.getId());
+        String userAgent1 = suggestion.getUserAgent();
+        if(StringUtils.isEmpty(userAgent1)){
+            userAgent1 = userAgent;
+        }
+        suggestion.setUserAgent(userAgent1);
+        suggestion.setClientType(ClientEnum.TEACHER);
+
+        SysSuggestionV2 sysSuggestion = JSON.parseObject(suggestion.jsonString(), SysSuggestionV2.class);
+        sysSuggestion.setCreateTime(new Date());
+        return R.from(sysSuggestionV2Service.add(sysSuggestion));
+    }
+
 }