|
@@ -5,6 +5,7 @@ import com.izouma.nineth.service.ContentAuditService;
|
|
|
import com.izouma.nineth.service.UserDetailService;
|
|
import com.izouma.nineth.service.UserDetailService;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
|
|
+import com.izouma.nineth.repo.UserDetailRepo;
|
|
|
import com.izouma.nineth.utils.ObjUtils;
|
|
import com.izouma.nineth.utils.ObjUtils;
|
|
|
import com.izouma.nineth.utils.SecurityUtils;
|
|
import com.izouma.nineth.utils.SecurityUtils;
|
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
@@ -24,52 +25,62 @@ import java.util.List;
|
|
|
@RequestMapping("/userDetail")
|
|
@RequestMapping("/userDetail")
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class UserDetailController extends BaseController {
|
|
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) {
|
|
|
|
|
+ UserDetail userDetail = userDetailRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
|
|
+ userDetail.setNftCount(userDetailRepo.findNftCountById(id));
|
|
|
|
|
+ userDetail.setBuildCount(userDetailRepo.findBuildCountById(id));
|
|
|
|
|
+ userDetail.setPlotCount(userDetailRepo.findPlotCountById(id));
|
|
|
|
|
+ userDetail.setFansCount(userDetailRepo.findFansCountById(id));
|
|
|
|
|
+ userDetail.setReikiCount(userDetailRepo.findReikiCountById(id));
|
|
|
|
|
+ userDetail.setMedalCount(userDetailRepo.findMedalCountById(id));
|
|
|
|
|
+ userDetail.setPersonalheatCount(userDetailRepo.findPersonalHeatCountById(id));
|
|
|
|
|
+
|
|
|
|
|
+ return userDetail;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @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);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|