|
|
@@ -0,0 +1,75 @@
|
|
|
+package com.izouma.nineth.web;
|
|
|
+
|
|
|
+import com.izouma.nineth.domain.UserDetail;
|
|
|
+import com.izouma.nineth.service.ContentAuditService;
|
|
|
+import com.izouma.nineth.service.UserDetailService;
|
|
|
+import com.izouma.nineth.dto.PageQuery;
|
|
|
+import com.izouma.nineth.exception.BusinessException;
|
|
|
+import com.izouma.nineth.utils.ObjUtils;
|
|
|
+import com.izouma.nineth.utils.SecurityUtils;
|
|
|
+import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.security.core.Authentication;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/userDetail")
|
|
|
+@AllArgsConstructor
|
|
|
+public class UserDetailController extends BaseController {
|
|
|
+// private UserDetailService userDetailService;
|
|
|
+// private UserDetailRepo userDetailRepo;
|
|
|
+// private ContentAuditService contentAuditService;
|
|
|
+//
|
|
|
+// //@PreAuthorize("hasRole('ADMIN')")
|
|
|
+// @PostMapping("/save")
|
|
|
+// public UserDetail save(@RequestBody UserDetail record) {
|
|
|
+// Long currentUserId = SecurityUtils.getAuthenticatedUser().getId();
|
|
|
+// if (currentUserId != record.getUserId()) {
|
|
|
+// throw new BusinessException("当前修改用户与登录用户不一致");
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(record.getAutograph())) {
|
|
|
+// if (!contentAuditService.auditText(record.getAutograph())) {
|
|
|
+// throw new BusinessException("简介包含非法内容");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (record.getUserId() != null) {
|
|
|
+// UserDetail orig = userDetailRepo.findById(record.getUserId()).orElseThrow(new BusinessException("无记录"));
|
|
|
+// ObjUtils.merge(orig, record);
|
|
|
+// return userDetailRepo.save(orig);
|
|
|
+// }
|
|
|
+// return userDetailRepo.save(record);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //@PreAuthorize("hasRole('ADMIN')")
|
|
|
+// @PostMapping("/all")
|
|
|
+// public Page<UserDetail> all(@RequestBody PageQuery pageQuery) {
|
|
|
+// return userDetailService.all(pageQuery);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @GetMapping("/get/{id}")
|
|
|
+// public UserDetail get(@PathVariable Long id) {
|
|
|
+// return userDetailRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @PostMapping("/del/{id}")
|
|
|
+// public void del(@PathVariable Long id) {
|
|
|
+// userDetailRepo.softDelete(id);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @GetMapping("/excel")
|
|
|
+// @ResponseBody
|
|
|
+// public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
|
+// List<UserDetail> data = all(pageQuery).getContent();
|
|
|
+// ExcelUtils.export(response, data);
|
|
|
+// }
|
|
|
+}
|
|
|
+
|