|
@@ -1,43 +1,19 @@
|
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.microsvc.toolkit.common.response.paging.PageInfo;
|
|
|
-import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
-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.SysSuggestionType;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.SysUser;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.queryInfo.SysSuggestionQueryInfo;
|
|
|
import com.yonge.cooleshow.biz.dal.service.SysSuggestionService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysSuggestionTypeService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysUserService;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionWrapper;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
@Api(tags = "意见反馈")
|
|
|
@RestController
|
|
|
@RequestMapping("${app-config.url.admin:}/")
|
|
@@ -45,145 +21,39 @@ public class SysSuggestionController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private SysSuggestionService sysSuggestionService;
|
|
|
- @Resource
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
-
|
|
|
@Autowired
|
|
|
- private SysUserService sysUserService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysSuggestionTypeService sysSuggestionTypeService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询单条
|
|
|
- *
|
|
|
- * @param id 详情ID
|
|
|
- * @return R<SysSuggestionVo.SysSuggestion>
|
|
|
- */
|
|
|
- @ApiOperation(value = "详情", notes = "传入id")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('sysSuggestion/detail')")
|
|
|
- @GetMapping("/detail/{id}")
|
|
|
- public R<SysSuggestionWrapper.SysSuggestion> detail(@PathVariable("id") Long id) {
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
- // 建议详情
|
|
|
- SysSuggestion wrapper = sysSuggestionService.detail(id);
|
|
|
- SysSuggestionWrapper.SysSuggestion suggestion =
|
|
|
- SysSuggestionWrapper.SysSuggestion.from(JSON.toJSONString(wrapper));
|
|
|
- if (wrapper != null && wrapper.getSuggestionTypeId() != null) {
|
|
|
- SysSuggestionType suggestionType = sysSuggestionTypeService.getById(wrapper.getSuggestionTypeId());
|
|
|
- if (suggestionType != null) {
|
|
|
- suggestion.setSuggestionTypeName(suggestionType.getName());
|
|
|
- }
|
|
|
- com.yonge.cooleshow.auth.api.entity.SysUser createUser = sysUserService.getByUserId(wrapper.getUserId());
|
|
|
- String clientType = wrapper.getClientType();
|
|
|
- if (ClientEnum.STUDENT.getCode().equals(clientType) || ClientEnum.TENANT_STUDENT.getCode().equals(clientType)) {
|
|
|
- suggestion.setNickname(createUser.getUsername());
|
|
|
- } else {
|
|
|
- suggestion.setNickname(createUser.getRealName());
|
|
|
- }
|
|
|
- Long handleBy = wrapper.getHandleBy();
|
|
|
- if (handleBy != null) {
|
|
|
- com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserService.getByUserId(handleBy);
|
|
|
- suggestion.setHandleName(sysUser.getUsername());
|
|
|
- }
|
|
|
+ @ApiOperation(value = "新增")
|
|
|
+ @RequestMapping("sysSuggestion/add")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('sysSuggestion/add')")
|
|
|
+ public Object add(SysSuggestion sysSuggestion) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
}
|
|
|
- return R.from(suggestion);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询分页
|
|
|
- *
|
|
|
- * @param query SysSuggestionWrapper.SysSuggestionQuery
|
|
|
- * @return R<PageInfo < SysSuggestionWrapper.SysSuggestion>>
|
|
|
- */
|
|
|
- @ApiOperation(value = "查询分页")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
|
|
|
- @PostMapping("/queryPage")
|
|
|
- public R<PageInfo<SysSuggestionWrapper.SysSuggestion>> page(@RequestBody SysSuggestionWrapper.SysSuggestionQuery query) {
|
|
|
-
|
|
|
- IPage<SysSuggestionWrapper.SysSuggestion> pages = sysSuggestionService.selectPage(QueryInfo.getPage(query), query);
|
|
|
-
|
|
|
- List<SysSuggestionWrapper.SysSuggestion> records = pages.getRecords();
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(records)) {
|
|
|
- List<Long> handlerList = records.stream().map(SysSuggestionWrapper.SysSuggestion::getHandleBy).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
- Map<Long, SysUser> mapByIds = new HashMap<>();
|
|
|
- if (CollectionUtils.isNotEmpty(handlerList)) {
|
|
|
- mapByIds.putAll(sysUserService.getMapByIds(handlerList));
|
|
|
- }
|
|
|
- for (SysSuggestionWrapper.SysSuggestion item : records) {
|
|
|
- Long handleBy = item.getHandleBy();
|
|
|
- if (handleBy != null && mapByIds.containsKey(handleBy)) {
|
|
|
- item.setHandleName(mapByIds.getOrDefault(handleBy, new SysUser()).getUsername());
|
|
|
- }
|
|
|
- }
|
|
|
+ sysSuggestion.setUserId(sysUser.getId().longValue());
|
|
|
+ sysSuggestion.setClientType("TEACHER");
|
|
|
+ if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
|
|
|
+ sysSuggestion.setMobileNo(sysUser.getPhone());
|
|
|
}
|
|
|
- return R.from(QueryInfo.pageInfo(pages, records));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增
|
|
|
- *
|
|
|
- * @param suggestion SysSuggestionVo.SysSuggestion
|
|
|
- * @return R<Boolean>
|
|
|
- */
|
|
|
- @ApiOperation(value = "新增", notes = "传入sysSuggestion")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('sysSuggestion/page')")
|
|
|
- @PostMapping("/add")
|
|
|
- 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());
|
|
|
- suggestion.setClientType(sysUser.getUserType());
|
|
|
- suggestion.setUserAgent(userAgent);
|
|
|
-
|
|
|
- return R.from(sysSuggestionService.save(JSON.parseObject(suggestion.jsonString(), SysSuggestion.class)));
|
|
|
+ sysSuggestionService.insert(sysSuggestion);
|
|
|
+ return succeed();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- *
|
|
|
- * @param suggestion SysSuggestionVo.SysSuggestion
|
|
|
- * @return R<Boolean>
|
|
|
- */
|
|
|
- @ApiOperation(value = "修改", notes = "传入sysSuggestion")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('sysSuggestion/update')")
|
|
|
-// @PostMapping("/update")
|
|
|
- public R<Boolean> update(@Validated @RequestBody SysSuggestionVo.SysSuggestion suggestion) {
|
|
|
- return R.from(sysSuggestionService.update(JSON.parseObject(suggestion.jsonString(), SysSuggestionWrapper.SysSuggestion.class)));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除
|
|
|
- *
|
|
|
- * @param id 详情ID
|
|
|
- * @return R<Boolean>
|
|
|
- */
|
|
|
- @ApiOperation(value = "删除", notes = "传入id")
|
|
|
+ @ApiOperation(value = "删除")
|
|
|
+ @RequestMapping("sysSuggestion/del")
|
|
|
@PreAuthorize("@pcs.hasPermissions('sysSuggestion/del')")
|
|
|
-// @PostMapping("/del")
|
|
|
- public R<Boolean> remove(@RequestParam Long id) {
|
|
|
- return R.from(sysSuggestionService.removeById(id));
|
|
|
+ public Object del(Long id) {
|
|
|
+ sysSuggestionService.delete(id);
|
|
|
+ return succeed();
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "修改")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('sysSuggestion/handleSuggestion')")
|
|
|
- @PostMapping("/handleSuggestion")
|
|
|
- public R<Boolean> handleSuggestion(@Validated @RequestBody SysSuggestionWrapper.HandleSuggestion handleSuggestion) {
|
|
|
- com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- handleSuggestion.setHandleBy(sysUser.getId());
|
|
|
- return R.from(sysSuggestionService.handleSuggestion(handleSuggestion));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询未处理的建议数量")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryUnHandleNum')")
|
|
|
- @GetMapping("/queryUnHandleNum")
|
|
|
- public R<Integer> queryUnHandleNum() {
|
|
|
- Integer count = sysSuggestionService.lambdaQuery()
|
|
|
- .eq(SysSuggestion::getHandleStatus, false)
|
|
|
- .count();
|
|
|
- return R.from(count);
|
|
|
+ @ApiOperation(value = "分页查询")
|
|
|
+ @RequestMapping("sysSuggestion/queryPage")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
|
|
|
+ public Object queryPage(SysSuggestionQueryInfo queryInfo) {
|
|
|
+ return succeed(sysSuggestionService.queryPage(queryInfo));
|
|
|
}
|
|
|
|
|
|
}
|