|
|
@@ -5,7 +5,6 @@ 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.repo.UserDetailRepo;
|
|
|
import com.izouma.nineth.utils.ObjUtils;
|
|
|
import com.izouma.nineth.utils.SecurityUtils;
|
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
|
@@ -25,52 +24,52 @@ import java.util.List;
|
|
|
@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);
|
|
|
- }
|
|
|
+// 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);
|
|
|
+// }
|
|
|
}
|
|
|
|