|
|
@@ -0,0 +1,192 @@
|
|
|
+package org.dromara.business.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import org.dromara.business.domain.UserComplaints;
|
|
|
+import org.dromara.business.domain.bo.UserComplaintsBo;
|
|
|
+import org.dromara.business.domain.enums.ComplaintsStatus;
|
|
|
+import org.dromara.business.domain.vo.UserComplaintsVo;
|
|
|
+import org.dromara.business.mapper.UserComplaintsMapper;
|
|
|
+import org.dromara.business.service.IUserComplaintsService;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用户申诉Service业务层处理
|
|
|
+ *
|
|
|
+ * @author Lion Li
|
|
|
+ * @date 2025-08-21
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class UserComplaintsServiceImpl implements IUserComplaintsService {
|
|
|
+
|
|
|
+ private final UserComplaintsMapper baseMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户申诉
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 用户申诉
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public UserComplaintsVo queryById(Long id){
|
|
|
+ return baseMapper.selectUserComplaintsPageById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询用户申诉列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 用户申诉分页列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<UserComplaintsVo> queryPageList(UserComplaintsBo bo, PageQuery pageQuery) {
|
|
|
+ Wrapper<UserComplaints> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<UserComplaintsVo> result = baseMapper.selectUserComplaintsPage(pageQuery.build(), lqw);
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合条件的用户申诉列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @return 用户申诉列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<UserComplaintsVo> queryList(UserComplaintsBo bo) {
|
|
|
+ Wrapper<UserComplaints> lqw = buildQueryWrapper(bo);
|
|
|
+ return baseMapper.selectUserComplaintsList(lqw);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Wrapper<UserComplaints> buildQueryWrapper(UserComplaintsBo bo) {
|
|
|
+ QueryWrapper<UserComplaints> wrapper = new QueryWrapper<>();
|
|
|
+ // 排序:按 a.id 升序
|
|
|
+ wrapper.orderByAsc("a.create_at");
|
|
|
+
|
|
|
+ // ======== 条件拼接 ========
|
|
|
+
|
|
|
+ // user_id
|
|
|
+ if (bo.getUserId() != null) {
|
|
|
+ wrapper.eq("a.user_id", bo.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // tournament_id
|
|
|
+ if (bo.getTournamentId() != null) {
|
|
|
+ wrapper.eq("a.tournament_id", bo.getTournamentId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // final_rank
|
|
|
+ if (bo.getFinalRank() != null) {
|
|
|
+ wrapper.eq("a.final_rank", bo.getFinalRank());
|
|
|
+ }
|
|
|
+
|
|
|
+ // complaint_reason:模糊匹配
|
|
|
+ if (StringUtils.isNotBlank(bo.getComplaintReason())) {
|
|
|
+ wrapper.like("a.complaint_reason", bo.getComplaintReason());
|
|
|
+ }
|
|
|
+
|
|
|
+ // create_at 时间范围查询(推荐做法)
|
|
|
+ if (bo.getTournamentBeginTime() != null && !bo.getTournamentBeginTime().isEmpty()) {
|
|
|
+ wrapper.ge("a.create_at", bo.getTournamentBeginTime());
|
|
|
+ }
|
|
|
+ if (bo.getTournamentEndTime() != null && !bo.getTournamentEndTime().isEmpty()) {
|
|
|
+ wrapper.le("a.create_at", bo.getTournamentEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // update_at(也可支持范围,这里保留原样)
|
|
|
+ if (bo.getUpdateAt() != null) {
|
|
|
+ wrapper.eq("a.update_at", bo.getUpdateAt());
|
|
|
+ }
|
|
|
+
|
|
|
+ // status
|
|
|
+ if (bo.getStatus() != null) {
|
|
|
+ wrapper.eq("a.status", bo.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ // status_text
|
|
|
+ if (StringUtils.isNotBlank(bo.getStatusText())) {
|
|
|
+ wrapper.eq("a.status_text", bo.getStatusText());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // ======== 多字段模糊搜索:手机号 或 昵称 ========
|
|
|
+ if (StringUtils.isNotBlank(bo.getUserIds())) {
|
|
|
+ wrapper.and(wrapper1 ->
|
|
|
+ wrapper1.like("b.phone", bo.getUserIds())
|
|
|
+ .or()
|
|
|
+ .like("b.nick_name", bo.getUserIds())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增用户申诉
|
|
|
+ *
|
|
|
+ * @param bo 用户申诉
|
|
|
+ * @return 是否新增成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(UserComplaintsBo bo) {
|
|
|
+ UserComplaints add = MapstructUtils.convert(bo, UserComplaints.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insertUserComplaints(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户申诉
|
|
|
+ *
|
|
|
+ * @param bo 用户申诉
|
|
|
+ * @return 是否修改成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(UserComplaintsBo bo) {
|
|
|
+ UserComplaints update = MapstructUtils.convert(bo, UserComplaints.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setOperateName(StringUtils.isEmpty(LoginHelper.getLoginUser().getUsername())?LoginHelper.getLoginUser().getNickname() : LoginHelper.getLoginUser().getUsername());
|
|
|
+ update.setStatusText(ComplaintsStatus.fromCode(bo.getStatus()).getDescription());
|
|
|
+ update.setAdvice(bo.getAdvice());
|
|
|
+ return baseMapper.updateUserComplaints(update) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(UserComplaints entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并批量删除用户申诉信息
|
|
|
+ *
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
+ * @return 是否删除成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return baseMapper.deleteUserComplaintsById(ids) > 0;
|
|
|
+ }
|
|
|
+}
|