Commit 22a6c2f1 authored by yuwenwen's avatar yuwenwen
parents 6cc1d54f 2f3f5e92
...@@ -6,6 +6,7 @@ import com.tangguo.common.core.domain.entity.SysMenu; ...@@ -6,6 +6,7 @@ import com.tangguo.common.core.domain.entity.SysMenu;
import com.tangguo.common.core.domain.entity.SysUser; import com.tangguo.common.core.domain.entity.SysUser;
import com.tangguo.common.core.domain.model.LoginBody; import com.tangguo.common.core.domain.model.LoginBody;
import com.tangguo.common.utils.SecurityUtils; import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.core.domain.model.WxcpCodeLogin;
import com.tangguo.framework.web.service.SysLoginService; import com.tangguo.framework.web.service.SysLoginService;
import com.tangguo.framework.web.service.SysPermissionService; import com.tangguo.framework.web.service.SysPermissionService;
import com.tangguo.system.service.ISysMenuService; import com.tangguo.system.service.ISysMenuService;
...@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
...@@ -80,4 +82,32 @@ public class SysLoginController { ...@@ -80,4 +82,32 @@ public class SysLoginController {
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus)); return AjaxResult.success(menuService.buildMenus(menus));
} }
/**
* 企微用户Code登录
*
* @param bo 登录参数
* @return 登录结果
*/
@PostMapping("/bbs/mobile/user/code/login")
public AjaxResult codeLogin(@RequestBody WxcpCodeLogin bo) {
Map<String, Object> tokenMap = this.loginService.codeLogin(bo);
return AjaxResult.success(tokenMap);
}
/**
* 查询用户信息
*
* @return 用户信息
*/
@GetMapping("/bbs/mobile/user/profile")
public AjaxResult getUserProfile() {
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
return AjaxResult.success(sysUser);
}
} }
...@@ -13,13 +13,6 @@ spring: ...@@ -13,13 +13,6 @@ spring:
url: jdbc:mysql://47.110.32.247:3306/safe_campus_bbs?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true url: jdbc:mysql://47.110.32.247:3306/safe_campus_bbs?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true
username: mysql username: mysql
password: passWd2025@tangguo.ren password: passWd2025@tangguo.ren
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url: jdbc:mysql://47.110.32.247:3306/qyweixin-campus-dev?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&tinyInt1isBit=false&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true
username: mysql
password: passWd2025@tangguo.ren
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5
# 最小连接池数量 # 最小连接池数量
...@@ -104,5 +97,5 @@ wx: ...@@ -104,5 +97,5 @@ wx:
cp: cp:
corp-id: ww63ca87d5f8647514 corp-id: ww63ca87d5f8647514
app-config: app-config:
agent-id: 1000044 agent-id: 1000072
secret: GqApjJ2aDuntiU5iQ9yqx8JKQwYDMrg1tTHdeeF0BWA secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<el-input v-model="queryParams.content" placeholder="请输入"></el-input> <el-input v-model="queryParams.content" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="姓名"> <el-form-item label="姓名">
<el-input v-model="queryParams.nikeName" placeholder="请输入"></el-input> <el-input v-model="queryParams.nickName" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="账号"> <el-form-item label="账号">
<el-input v-model="queryParams.userName" placeholder="请输入"></el-input> <el-input v-model="queryParams.userName" placeholder="请输入"></el-input>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<el-table-column label="评论内容" prop="content" align="center"></el-table-column> <el-table-column label="评论内容" prop="content" align="center"></el-table-column>
<el-table-column label="所属动态" prop="momentContent" align="center"></el-table-column> <el-table-column label="所属动态" prop="momentContent" align="center"></el-table-column>
<el-table-column label="账号" prop="userName" align="center"></el-table-column> <el-table-column label="账号" prop="userName" align="center"></el-table-column>
<el-table-column label="姓名" prop="nikeName" align="center"></el-table-column> <el-table-column label="姓名" prop="nickName" align="center"></el-table-column>
<el-table-column label="创建时间" prop="createTime" align="center"></el-table-column> <el-table-column label="创建时间" prop="createTime" align="center"></el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template #default="{ row }"> <template #default="{ row }">
...@@ -110,4 +110,4 @@ export default { ...@@ -110,4 +110,4 @@ export default {
overflow: auto; overflow: auto;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="dynamic-item"> <div class="dynamic-item">
<div class="user-info-box"> <div class="user-info-box">
<img class="avatar" src="@/assets/images/default-avatar.png"></img> <img class="avatar" src="@/assets/images/default-avatar.png"></img>
<div class="user-name">{{ form.nikeName }}</div> <div class="user-name">{{ form.nickName }}</div>
<img class="more-icon" src="@/assets/images/more-icon.png"></img> <img class="more-icon" src="@/assets/images/more-icon.png"></img>
</div> </div>
<div class="topics-box" v-if="form.topicNames && form.topicNames.length > 0"> <div class="topics-box" v-if="form.topicNames && form.topicNames.length > 0">
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<div class="comment-display-box" v-if="form.comments && form.comments.length > 0"> <div class="comment-display-box" v-if="form.comments && form.comments.length > 0">
<div class="comment-item" v-for="(item, index) in form.comments"> <div class="comment-item" v-for="(item, index) in form.comments">
<div class="user-info"> <div class="user-info">
<div class="username">{{ item.nikeName }}:</div> <div class="username">{{ item.nickName }}:</div>
<div class="datetime">2025-07-01 04:21:21</div> <div class="datetime">2025-07-01 04:21:21</div>
</div> </div>
<div class="content">{{ item.content }}</div> <div class="content">{{ item.content }}</div>
...@@ -333,4 +333,4 @@ export default { ...@@ -333,4 +333,4 @@ export default {
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<el-table-column label="动态内容" prop="content" align="center"></el-table-column> <el-table-column label="动态内容" prop="content" align="center"></el-table-column>
<el-table-column label="话题" align="center" prop="topicNames" width="240"></el-table-column> <el-table-column label="话题" align="center" prop="topicNames" width="240"></el-table-column>
<el-table-column label="帐号" prop="userName" align="center" width="140"></el-table-column> <el-table-column label="帐号" prop="userName" align="center" width="140"></el-table-column>
<el-table-column label="姓名" prop="nikeName" align="center" width="120"></el-table-column> <el-table-column label="姓名" prop="nickName" align="center" width="120"></el-table-column>
<el-table-column label="点赞数" prop="likeCount" align="center" width="100"></el-table-column> <el-table-column label="点赞数" prop="likeCount" align="center" width="100"></el-table-column>
<el-table-column label="评论数" prop="commentCount" align="center" width="100"></el-table-column> <el-table-column label="评论数" prop="commentCount" align="center" width="100"></el-table-column>
<el-table-column label="创建时间" prop="createTime" align="center" width="160"></el-table-column> <el-table-column label="创建时间" prop="createTime" align="center" width="160"></el-table-column>
...@@ -76,7 +76,7 @@ export default { ...@@ -76,7 +76,7 @@ export default {
this.total = res.total this.total = res.total
}) })
}, },
// 新增 // 新增
handleDetail(row) { handleDetail(row) {
this.$refs.detailDialogRef.openModal(row) this.$refs.detailDialogRef.openModal(row)
...@@ -121,4 +121,4 @@ export default { ...@@ -121,4 +121,4 @@ export default {
overflow: auto; overflow: auto;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</el-row> </el-row>
<el-table :data="tableList"> <el-table :data="tableList">
<el-table-column label="序号" width="55" type="index" align="center"></el-table-column> <el-table-column label="序号" width="55" type="index" align="center"></el-table-column>
<el-table-column label="兑换人" prop="nikeName" align="center"></el-table-column> <el-table-column label="兑换人" prop="nickName" align="center"></el-table-column>
<el-table-column label="兑换商品" align="center" prop="goodsName"></el-table-column> <el-table-column label="兑换商品" align="center" prop="goodsName"></el-table-column>
<el-table-column label="兑换积分" prop="goodsExchangePoints" align="center"></el-table-column> <el-table-column label="兑换积分" prop="goodsExchangePoints" align="center"></el-table-column>
<el-table-column label="兑换时间" prop="createTime" align="center"></el-table-column> <el-table-column label="兑换时间" prop="createTime" align="center"></el-table-column>
...@@ -145,4 +145,4 @@ export default { ...@@ -145,4 +145,4 @@ export default {
overflow: auto; overflow: auto;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<el-form-item label="兑换人"> <el-form-item label="兑换人">
<el-select placeholder="请选择" style="width: 100%;" v-model="form.userName" @change="handleUserChange"> <el-select placeholder="请选择" style="width: 100%;" v-model="form.userName" @change="handleUserChange">
<el-option v-for="(item, index) in userList" :key="index" :value="item.userName" <el-option v-for="(item, index) in userList" :key="index" :value="item.userName"
:label="item.nikeName"></el-option> :label="item.nickName"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="会员等级"> <el-form-item label="会员等级">
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
if (row && row.userName) { if (row && row.userName) {
res.data.forEach((item) => { res.data.forEach((item) => {
if (item.userName == row.userName) { if (item.userName == row.userName) {
this.form.nikeName = item.nikeName; this.form.nickName = item.nickName;
this.form.gradeName = item.gradeName this.form.gradeName = item.gradeName
} }
}) })
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
handleUserChange(val) { handleUserChange(val) {
this.userList.forEach((item) => { this.userList.forEach((item) => {
if (item.userName == val) { if (item.userName == val) {
this.form.nikeName = item.nikeName; this.form.nickName = item.nickName;
this.form.gradeName = item.gradeName this.form.gradeName = item.gradeName
this.form.currentPoints = item.currentPoints this.form.currentPoints = item.currentPoints
} }
...@@ -85,8 +85,8 @@ export default { ...@@ -85,8 +85,8 @@ export default {
}) })
}, },
handleConfirm() { handleConfirm() {
let { nikeName, userName, userGradeName, goodsCode } = this.form let { nickName, userName, userGradeName, goodsCode } = this.form
let data = { nikeName, userName, userGradeName, goodsCode } let data = { nickName, userName, userGradeName, goodsCode }
this.$refs.formRef.validate((valid) => { this.$refs.formRef.validate((valid) => {
if (valid) { if (valid) {
exchange(data).then(res => { exchange(data).then(res => {
...@@ -115,4 +115,4 @@ export default { ...@@ -115,4 +115,4 @@ export default {
padding: 0 20px !important; padding: 0 20px !important;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="page-container"> <div class="page-container">
<el-form :model="queryParams" :inline="true" label-width="80px"> <el-form :model="queryParams" :inline="true" label-width="80px">
<el-form-item label="姓名"> <el-form-item label="姓名">
<el-input v-model="queryParams.nikeName" placeholder="请输入" style="width: 220px;"></el-input> <el-input v-model="queryParams.nickName" placeholder="请输入" style="width: 220px;"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="handleQuery">查询</el-button> <el-button type="primary" @click="handleQuery">查询</el-button>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</el-row> </el-row>
<el-table :data="tableList"> <el-table :data="tableList">
<el-table-column label="序号" width="55" type="index" align="center"></el-table-column> <el-table-column label="序号" width="55" type="index" align="center"></el-table-column>
<el-table-column label="姓名" prop="nikeName" align="center"></el-table-column> <el-table-column label="姓名" prop="nickName" align="center"></el-table-column>
<el-table-column label="帐号" prop="userName" align="center"></el-table-column> <el-table-column label="帐号" prop="userName" align="center"></el-table-column>
<el-table-column label="部门" prop="deptName" align="center"></el-table-column> <el-table-column label="部门" prop="deptName" align="center"></el-table-column>
<el-table-column label="总积分" prop="accumulatedPoints" align="center"></el-table-column> <el-table-column label="总积分" prop="accumulatedPoints" align="center"></el-table-column>
...@@ -180,4 +180,4 @@ export default { ...@@ -180,4 +180,4 @@ export default {
overflow: auto; overflow: auto;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<view class="comment-display-box" v-else> <view class="comment-display-box" v-else>
<view class="comment-item" v-for="(item,index) in list"> <view class="comment-item" v-for="(item,index) in list">
<view class="user-info"> <view class="user-info">
<view class="username">{{item.nikeName}}</view> <view class="username">{{item.nickName}}</view>
<view class="datetime">{{item.createTime}}</view> <view class="datetime">{{item.createTime}}</view>
</view> </view>
<view class="content"> <view class="content">
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<view v-if="form.isSelf==1&&activeIndex==1" @click="handleDelete(item)">删除</view> <view v-if="form.isSelf==1&&activeIndex==1" @click="handleDelete(item)">删除</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.add-text { .add-text {
...@@ -231,4 +231,4 @@ ...@@ -231,4 +231,4 @@
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view class="dynamic-item" @click="toDynamicDetailPage"> <view class="dynamic-item" @click="toDynamicDetailPage">
<view class="user-info-box"> <view class="user-info-box">
<image class="avatar" src="/static/images/default-avatar.png"></image> <image class="avatar" src="/static/images/default-avatar.png"></image>
<view class="user-name">{{form.nikeName}}</view> <view class="user-name">{{form.nickName}}</view>
<image class="more-icon" src="/static/images/more-icon.png"></image> <image class="more-icon" src="/static/images/more-icon.png"></image>
</view> </view>
<view class="topics-box" v-if="form.topicNames && form.topicNames.length >0"> <view class="topics-box" v-if="form.topicNames && form.topicNames.length >0">
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<view class="results-item right-item"></view> <view class="results-item right-item"></view>
</view> </view>
</view> </view>
<view class="results-sum" @click.stop="toPKDetailPage(0)"> <view class="results-sum" @click.stop="toPKDetailPage(0)">
<view>{{form.voteCount}}人参与</view> <view>{{form.voteCount}}人参与</view>
<image src="/static/images/detail-icon.png" class="icon"></image> <image src="/static/images/detail-icon.png" class="icon"></image>
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<view class="comment-display-box" v-if="form.comments&& form.comments.length>0"> <view class="comment-display-box" v-if="form.comments&& form.comments.length>0">
<view class="comment-item" v-for="(item,index) in form.comments"> <view class="comment-item" v-for="(item,index) in form.comments">
<view class="user-info"> <view class="user-info">
<view class="username">{{item.nikeName}}:</view> <view class="username">{{item.nickName}}:</view>
<view class="datetime">2025-07-01 04:21:21</view> <view class="datetime">2025-07-01 04:21:21</view>
</view> </view>
<view class="content" v-if="!item.replyNikeName" @click.stop="handleReplayComment(item)">{{item.content}}</view> <view class="content" v-if="!item.replyNikeName" @click.stop="handleReplayComment(item)">{{item.content}}</view>
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
<script> <script>
import { import {
dynamicLikeUnlike, dynamicLikeUnlike,
dynamicVote dynamicVote
} from '@/api/api.js' } from '@/api/api.js'
import PublishComment from './PublishComment.vue'; import PublishComment from './PublishComment.vue';
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
console.log(item) console.log(item)
this.$refs.publishCommentRef.openModal(item) this.$refs.publishCommentRef.openModal(item)
}, },
// 投票 // 投票
handleVote(item) { handleVote(item) {
let data = { let data = {
...@@ -195,4 +195,4 @@ ...@@ -195,4 +195,4 @@
<style lang="scss"> <style lang="scss">
@import '@/static/styles/index.scss'; @import '@/static/styles/index.scss';
</style> </style>
\ No newline at end of file
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
if(item){ if(item){
// 不为空为回复 // 不为空为回复
this.parentId = item.id; this.parentId = item.id;
this.placeholder = '回复:'+item.nikeName this.placeholder = '回复:'+item.nickName
} }
}, },
// 关闭评论区 // 关闭评论区
...@@ -66,4 +66,4 @@ ...@@ -66,4 +66,4 @@
<style lang="scss"> <style lang="scss">
@import '@/static/styles/index.scss'; @import '@/static/styles/index.scss';
</style> </style>
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<image v-if="!userInfo.avatarUrl" src="/static/images/default-avatar.png" class="avatar"></image> <image v-if="!userInfo.avatarUrl" src="/static/images/default-avatar.png" class="avatar"></image>
<image v-else :src="userInfo.avatarUrl" class="avatar"></image> <image v-else :src="userInfo.avatarUrl" class="avatar"></image>
<view class="name-class"> <view class="name-class">
<view class="name">{{userInfo.nikeName}}</view> <view class="name">{{userInfo.nickName}}</view>
<view class="class-name">{{userInfo.deptName}}</view> <view class="class-name">{{userInfo.deptName}}</view>
</view> </view>
<image src="/static/images/mine/detail-icon-white.png" class="more"></image> <image src="/static/images/mine/detail-icon-white.png" class="more"></image>
...@@ -172,4 +172,4 @@ ...@@ -172,4 +172,4 @@
margin-top: 40rpx; margin-top: 40rpx;
height: calc(100vh - 570rpx); height: calc(100vh - 570rpx);
} }
</style> </style>
\ No newline at end of file
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
<scroll-view class="scroll-view-pk" v-if="list.length>0"> <scroll-view class="scroll-view-pk" v-if="list.length>0">
<view class="list-item" v-for="(item,index) in list"> <view class="list-item" v-for="(item,index) in list">
<image src="/static/images/default-avatar.png" class="avatar"></image> <image src="/static/images/default-avatar.png" class="avatar"></image>
<view class="name">{{item.nikeName}}</view> <view class="name">{{item.nickName}}</view>
<view class="datetime">{{item.createTime}}</view> <view class="datetime">{{item.createTime}}</view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</template> </template>
...@@ -127,4 +127,4 @@ ...@@ -127,4 +127,4 @@
} }
} }
} }
</style> </style>
\ No newline at end of file
package com.tangguo.domain.bo; package com.tangguo.common.core.domain.model;
import lombok.Data; import lombok.Data;
...@@ -9,7 +9,7 @@ import lombok.Data; ...@@ -9,7 +9,7 @@ import lombok.Data;
* @createTime 2025-09-02 14:53:19 星期二 * @createTime 2025-09-02 14:53:19 星期二
*/ */
@Data @Data
public class CodeLoginBO { public class WxcpCodeLogin {
/** /**
* 企微Code * 企微Code
......
package com.tangguo.common.domain;
import lombok.Data;
/**
* 企微门户用户
*
* @author 谈笑
* @createTime 2025-08-29 16:13:32 星期五
*/
@Data
public class QwmhUserInfo {
/**
* 用户Id
*/
private String userId;
/**
* 用户名
*/
private String userName;
/**
* 用户姓名
*/
private String nikeName;
/**
* 用户头像
*/
private String avatarUrl;
/**
* 部门名称
*/
private String deptName;
/**
* 用户等级
*/
private String gradeName;
/**
* 当前积分
*/
private Integer currentPoints;
/**
* 累计积分
*/
private Integer accumulatedPoints;
}
package com.tangguo.common.mauth;
import lombok.Getter;
/**
* 移动端用户身份认证失败异常类
*
* @author 谈笑
* @createTime 2025-09-02 14:42:17 星期二
*/
@Getter
public class Mobile401Exception extends RuntimeException {
private static final long serialVersionUID = -4189845692674690824L;
/**
* 状态码
*/
private final int code = 401;
/**
* 异常消息
*/
private final String message;
public Mobile401Exception(String message) {
this.message = message;
}
public Mobile401Exception(String message, Throwable cause) {
super(message, cause);
this.message = message;
}
}
package com.tangguo.common.mauth;
import lombok.Getter;
/**
* 移动端用户鉴权失败异常类
*
* @author 谈笑
* @createTime 2025-09-02 14:42:17 星期二
*/
@Getter
public class Mobile403Exception extends RuntimeException {
private static final long serialVersionUID = 4027402152375922779L;
/**
* 状态码
*/
private final int code = 403;
/**
* 异常消息
*/
private final String message;
public Mobile403Exception(String message) {
this.message = message;
}
public Mobile403Exception(String message, Throwable cause) {
super(message, cause);
this.message = message;
}
}
package com.tangguo.common.mauth;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 移动端用户身份认证注解
*
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MobileAuth {
}
package com.tangguo.common.mauth;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.time.Duration;
/**
* 移动端用户Token配置参数
*
* @author 谈笑
* @createTime 2025-09-02 14:42:17 星期二
*/
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "mobile.auth")
public class MobileProperties {
/**
* 生成时Token参数名
*/
private String resTokenName;
/**
* 请求时Token参数名
*/
private String reqTokenName;
/**
* Token签发人
*/
private String issuer = "MobileAuth";
/**
* Token签名算法
*/
private String algorithmId = "HS512";
/**
* Token签名密钥
*/
private String signKey = "SignKey2025@.";
/**
* Token有效时间
*/
private Duration effectiveTime = Duration.ofDays(7);
/**
* 拦截器拦截路径
*/
private String[] pathPatterns = {"/mobile/**"};
}
package com.tangguo.common.mauth;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTValidator;
import cn.hutool.jwt.signers.JWTSigner;
import cn.hutool.jwt.signers.JWTSignerUtil;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.Instant;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/**
* 移动端用户Token处理
*
* @author 谈笑
* @createTime 2025-09-02 14:42:17 星期二
*/
@Component
public class MobileTokenHelper {
private static MobileProperties properties;
@Resource
public void setProperties(MobileProperties properties) {
MobileTokenHelper.properties = properties;
}
/**
* 计算Token过期时间
*
* @return Token过期时间
*/
private static Date getTokenExpiredTime() {
return Date.from(Instant.now().plus(properties.getEffectiveTime()));
}
/**
* 获取Token签名器
*
* @return Token签名器
*/
private static JWTSigner getTokenSigner() {
return JWTSignerUtil.createSigner(
properties.getAlgorithmId(), properties.getSignKey().getBytes()
);
}
/**
* 构建JWT实体 (只填充了关键参数,并未签名。)
*
* @return JWT实体
*/
private static JWT buildJWT() {
JWT jwtToken = JWT.create();
jwtToken.setIssuer(properties.getIssuer());
jwtToken.setIssuedAt(new Date());
jwtToken.setExpiresAt(getTokenExpiredTime());
jwtToken.setSigner(getTokenSigner());
return jwtToken;
}
/**
* 创建Token
*
* @param payloads 荷载参数
* @return Token字符串
*/
public static String createToken(Map<String, Object> payloads) {
JWT jwtToken = buildJWT();
if (MapUtil.isNotEmpty(payloads)) {
payloads.forEach(jwtToken::setPayload);
}
return jwtToken.sign();
}
/**
* 创建Token,并返回Token明细信息。
*
* @param payloads 荷载参数
* @return Token字符串
*/
public static Map<String, Object> createDetailToken(Map<String, Object> payloads) {
String token = createToken(payloads);
Map<String, Object> detailTokenMap = new LinkedHashMap<>(2);
detailTokenMap.put(properties.getResTokenName(), token);
detailTokenMap.put("expiredTime", DateUtil.formatDateTime(getTokenExpiredTime()));
return detailTokenMap;
}
/**
* 获取当前用户Token
*
* @return 用户Token
*/
public static String getCurrentToken() {
try {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) attributes;
if (Objects.isNull(requestAttributes)) {
return null;
}
HttpServletRequest request = requestAttributes.getRequest();
String tokenValue = request.getHeader(properties.getReqTokenName());
if (tokenValue.startsWith("Bearer")) {
tokenValue = tokenValue.replace("Bearer ", "");
}
return tokenValue;
} catch (Exception e) {
return null;
}
}
/**
* 验证Token
*
* @param token Token字符串
* @return 验证结果
*/
public static boolean verifyToken(String token) {
if (StrUtil.isBlank(token)) {
return false;
}
try {
// 验证Token的签名和时效
return JWT.of(token).setSigner(getTokenSigner()).validate(0L);
} catch (Exception e) {
return false;
}
}
/**
* 校验Token
*
* @param token Token字符串
*/
public static JWT verifyParseToken(String token) {
if (StrUtil.isBlank(token)) {
throw new Mobile401Exception("身份认证失败,未获取到用户认证信息。");
}
try {
// 验证Token的签名和时效
JWTValidator.of(token).validateAlgorithm(getTokenSigner()).validateDate();
return JWT.of(token);
} catch (Exception e) {
throw new Mobile401Exception("身份认证失败,当前用户认证信息已失效或已过期。");
}
}
/**
* 获取当前用户Token荷载信息
*
* @return Token荷载信息
*/
public static JSONObject getTokenPayloads() {
return verifyParseToken(getCurrentToken()).getPayloads();
}
/**
* 获取当前用户名
*
* @return 用户名
*/
public static String getUserName() {
try {
String username = getTokenPayloads().getStr("userName");
if (StrUtil.isNotBlank(username)) {
return username;
} else {
throw new Mobile401Exception("身份认证失败,未获取到当前用户身份信息。");
}
} catch (Mobile401Exception e) {
throw e;
} catch (Exception e) {
throw new Mobile401Exception("获取当前用户身份信息获取失败。");
}
}
/**
* 获取当前用户姓名
*
* @return 用户名
*/
public static String getNikeName() {
try {
String nikeName = getTokenPayloads().getStr("nikeName");
if (StrUtil.isNotBlank(nikeName)) {
return nikeName;
} else {
throw new Mobile401Exception("身份认证失败,未获取到当前用户身份信息。");
}
} catch (Mobile401Exception e) {
throw e;
} catch (Exception e) {
throw new Mobile401Exception("获取当前用户身份信息获取失败。");
}
}
}
...@@ -2,7 +2,6 @@ package com.tangguo.framework.config; ...@@ -2,7 +2,6 @@ package com.tangguo.framework.config;
import com.tangguo.common.config.RuoYiConfig; import com.tangguo.common.config.RuoYiConfig;
import com.tangguo.common.constant.Constants; import com.tangguo.common.constant.Constants;
import com.tangguo.common.mauth.MobileProperties;
import com.tangguo.framework.interceptor.RepeatSubmitInterceptor; import com.tangguo.framework.interceptor.RepeatSubmitInterceptor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -28,9 +27,6 @@ public class ResourcesConfig implements WebMvcConfigurer { ...@@ -28,9 +27,6 @@ public class ResourcesConfig implements WebMvcConfigurer {
@Autowired @Autowired
private RepeatSubmitInterceptor repeatSubmitInterceptor; private RepeatSubmitInterceptor repeatSubmitInterceptor;
@Resource
private MobileProperties mobileProperties;
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
...@@ -50,8 +46,7 @@ public class ResourcesConfig implements WebMvcConfigurer { ...@@ -50,8 +46,7 @@ public class ResourcesConfig implements WebMvcConfigurer {
*/ */
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**") registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
.excludePathPatterns(this.mobileProperties.getPathPatterns());
} }
/** /**
......
package com.tangguo.framework.config; package com.tangguo.framework.config;
import com.tangguo.common.mauth.MobileProperties;
import com.tangguo.framework.config.properties.PermitAllUrlProperties; import com.tangguo.framework.config.properties.PermitAllUrlProperties;
import com.tangguo.framework.security.filter.JwtAuthenticationTokenFilter; import com.tangguo.framework.security.filter.JwtAuthenticationTokenFilter;
import com.tangguo.framework.security.handle.AuthenticationEntryPointImpl; import com.tangguo.framework.security.handle.AuthenticationEntryPointImpl;
...@@ -66,10 +65,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -66,10 +65,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
private PermitAllUrlProperties permitAllUrl; private PermitAllUrlProperties permitAllUrl;
@Resource
private MobileProperties mobileProperties;
/** /**
* 解决 无法直接注入 AuthenticationManager * 解决 无法直接注入 AuthenticationManager
* *
...@@ -115,14 +110,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -115,14 +110,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").permitAll() .antMatchers("/login", "/bbs/mobile/user/code/login", "/register", "/captchaImage").permitAll()
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 移动端接口
.antMatchers(this.mobileProperties.getPathPatterns()).permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
......
package com.tangguo.framework.mauth;
import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.mauth.MobileTokenHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Objects;
/**
* 移动端用户认证拦截器
*
* @author 谈笑
* @createTime 2025-09-02 14:42:17 星期二
*/
@Slf4j
@Component
public class MobileAuthInterceptor implements HandlerInterceptor {
/**
* 请求被处理之前调用
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
if (!(handler instanceof HandlerMethod)) {
return true;
}
// 获取处理器方法上的标识注解
Method method = ((HandlerMethod) handler).getMethod();
MobileAuth mobileAuth = method.getAnnotation(MobileAuth.class);
if (Objects.isNull(mobileAuth)) {
return true;
}
String username = MobileTokenHelper.getUserName();
log.info("=> 当前移动端请求用户:{}", username);
return true;
}
}
package com.tangguo.framework.mauth;
import com.tangguo.common.mauth.MobileProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 移动端Web配置
*
* @author 谈笑
* @createTime 2025-09-02 14:42:17 星期二
*/
@RequiredArgsConstructor
@Configuration
public class MobileWebMvcConfig implements WebMvcConfigurer {
private final MobileProperties mobileProperties;
private final MobileAuthInterceptor mobileAuthInterceptor;
/**
* 自定义拦截规则
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(this.mobileAuthInterceptor).addPathPatterns(this.mobileProperties.getPathPatterns());
}
}
...@@ -5,8 +5,6 @@ import com.tangguo.common.core.domain.AjaxResult; ...@@ -5,8 +5,6 @@ import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.domain.R; import com.tangguo.common.core.domain.R;
import com.tangguo.common.exception.DemoModeException; import com.tangguo.common.exception.DemoModeException;
import com.tangguo.common.exception.ServiceException; import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.mauth.Mobile401Exception;
import com.tangguo.common.mauth.Mobile403Exception;
import com.tangguo.common.utils.StringUtils; import com.tangguo.common.utils.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -107,22 +105,4 @@ public class GlobalExceptionHandler { ...@@ -107,22 +105,4 @@ public class GlobalExceptionHandler {
return AjaxResult.error("演示模式,不允许操作"); return AjaxResult.error("演示模式,不允许操作");
} }
/**
* 处理用户身份认证失败异常
*/
@ExceptionHandler(Mobile401Exception.class)
public R<Object> mobile401Exception(Mobile401Exception e) {
return R.fail(401, e.getMessage());
}
/**
* 处理用户权限校验失败异常
*/
@ExceptionHandler(Mobile403Exception.class)
public R<Object> mobile403Exception(Mobile403Exception e) {
return R.fail(403, e.getMessage());
}
} }
...@@ -5,6 +5,7 @@ import com.tangguo.common.constant.Constants; ...@@ -5,6 +5,7 @@ import com.tangguo.common.constant.Constants;
import com.tangguo.common.constant.UserConstants; import com.tangguo.common.constant.UserConstants;
import com.tangguo.common.core.domain.entity.SysUser; import com.tangguo.common.core.domain.entity.SysUser;
import com.tangguo.common.core.domain.model.LoginUser; import com.tangguo.common.core.domain.model.LoginUser;
import com.tangguo.common.core.domain.model.WxcpCodeLogin;
import com.tangguo.common.core.redis.RedisCache; import com.tangguo.common.core.redis.RedisCache;
import com.tangguo.common.exception.ServiceException; import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.exception.user.*; import com.tangguo.common.exception.user.*;
...@@ -17,20 +18,29 @@ import com.tangguo.framework.manager.factory.AsyncFactory; ...@@ -17,20 +18,29 @@ import com.tangguo.framework.manager.factory.AsyncFactory;
import com.tangguo.framework.security.context.AuthenticationContextHolder; import com.tangguo.framework.security.context.AuthenticationContextHolder;
import com.tangguo.system.service.ISysConfigService; import com.tangguo.system.service.ISysConfigService;
import com.tangguo.system.service.ISysUserService; import com.tangguo.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/** /**
* 登录校验方法 * 登录校验方法
* *
* @author ruoyi * @author ruoyi
*/ */
@Slf4j
@Component @Component
public class SysLoginService { public class SysLoginService {
@Autowired @Autowired
...@@ -48,6 +58,13 @@ public class SysLoginService { ...@@ -48,6 +58,13 @@ public class SysLoginService {
@Autowired @Autowired
private ISysConfigService configService; private ISysConfigService configService;
@Autowired
private UserDetailsServiceImpl userDetailsServiceImpl;
@Autowired
private WxCpService wxCpService;
/** /**
* 登录验证 * 登录验证
* *
...@@ -156,4 +173,35 @@ public class SysLoginService { ...@@ -156,4 +173,35 @@ public class SysLoginService {
sysUser.setLoginDate(DateUtils.getNowDate()); sysUser.setLoginDate(DateUtils.getNowDate());
userService.updateUserProfile(sysUser); userService.updateUserProfile(sysUser);
} }
/**
* 企微用户Code登录
*
* @param bo 登录参数
* @return 登录结果
*/
public Map<String, Object> codeLogin(WxcpCodeLogin bo) {
String userName;
try {
log.info("=> 移动端用户登录:{}", bo);
WxCpOauth2UserInfo authUserInfo = this.wxCpService.getOauth2Service().getAuthUserInfo(bo.getCode());
userName = authUserInfo.getUserId();
} catch (WxErrorException e) {
log.error("=> 移动端用户登录失败,查询当前企微用户数据失败:", e);
throw new ServiceException("登录失败,查询当前企微用户数据失败。");
}
try {
UserDetails userDetails = this.userDetailsServiceImpl.loadUserByUsername2(userName);
String token = this.tokenService.createToken((LoginUser) userDetails);
Map<String, Object> resultMap = new LinkedHashMap<>(2);
resultMap.put("token", token);
return resultMap;
} catch (Exception e) {
log.error("=> 移动端用户登录失败,生成用户Token失败:", e);
throw new ServiceException("登录失败:" + e.getMessage());
}
}
} }
...@@ -51,6 +51,23 @@ public class UserDetailsServiceImpl implements UserDetailsService { ...@@ -51,6 +51,23 @@ public class UserDetailsServiceImpl implements UserDetailsService {
return createLoginUser(user); return createLoginUser(user);
} }
public UserDetails loadUserByUsername2(String username) throws UsernameNotFoundException {
SysUser user = userService.selectUserByUserName(username);
if (StringUtils.isNull(user)) {
log.info("登录用户:{} 不存在.", username);
throw new ServiceException("登录用户:" + username + " 不存在");
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
log.info("登录用户:{} 已被删除.", username);
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", username);
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
}
return createLoginUser(user);
}
public UserDetails createLoginUser(SysUser user) { public UserDetails createLoginUser(SysUser user) {
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
} }
......
...@@ -2,9 +2,8 @@ package com.tangguo.controller.mobile; ...@@ -2,9 +2,8 @@ package com.tangguo.controller.mobile;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo; import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.mauth.MobileTokenHelper;
import com.tangguo.common.utils.PageUtils; import com.tangguo.common.utils.PageUtils;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.utils.ValidateOperations; import com.tangguo.common.utils.ValidateOperations;
import com.tangguo.domain.bo.*; import com.tangguo.domain.bo.*;
import com.tangguo.domain.vo.BbsCommentDetailVO; import com.tangguo.domain.vo.BbsCommentDetailVO;
...@@ -50,7 +49,6 @@ public class MBbsMomentController { ...@@ -50,7 +49,6 @@ public class MBbsMomentController {
* *
* @return 动态 * @return 动态
*/ */
@MobileAuth
@GetMapping("/moments") @GetMapping("/moments")
public TableDataInfo getMoments(QueryMomentBO bo) { public TableDataInfo getMoments(QueryMomentBO bo) {
PageUtils.clearPage(); PageUtils.clearPage();
...@@ -64,7 +62,6 @@ public class MBbsMomentController { ...@@ -64,7 +62,6 @@ public class MBbsMomentController {
* *
* @return 动态 * @return 动态
*/ */
@MobileAuth
@GetMapping("/{id}") @GetMapping("/{id}")
public AjaxResult getMomentDetail(@PathVariable Long id) { public AjaxResult getMomentDetail(@PathVariable Long id) {
BbsMomentListVO dbMoment = this.momentService.getMomentDetail(id); BbsMomentListVO dbMoment = this.momentService.getMomentDetail(id);
...@@ -78,7 +75,6 @@ public class MBbsMomentController { ...@@ -78,7 +75,6 @@ public class MBbsMomentController {
* @param bo 动态 * @param bo 动态
* @return 创建结果 * @return 创建结果
*/ */
@MobileAuth
@PostMapping("/create") @PostMapping("/create")
public AjaxResult createMoment(@RequestBody CreateMomentBO bo) { public AjaxResult createMoment(@RequestBody CreateMomentBO bo) {
this.momentService.userCreateMoment(bo); this.momentService.userCreateMoment(bo);
...@@ -92,7 +88,6 @@ public class MBbsMomentController { ...@@ -92,7 +88,6 @@ public class MBbsMomentController {
* @param momentId 动态Id * @param momentId 动态Id
* @return 删除结果 * @return 删除结果
*/ */
@MobileAuth
@DeleteMapping("/delete/{momentId}") @DeleteMapping("/delete/{momentId}")
public AjaxResult deleteMoment(@PathVariable Long momentId) { public AjaxResult deleteMoment(@PathVariable Long momentId) {
this.momentService.userDeleteMoment(momentId); this.momentService.userDeleteMoment(momentId);
...@@ -106,7 +101,6 @@ public class MBbsMomentController { ...@@ -106,7 +101,6 @@ public class MBbsMomentController {
* @param bo 动态 * @param bo 动态
* @return 点赞结果 * @return 点赞结果
*/ */
@MobileAuth
@PostMapping("/like") @PostMapping("/like")
public AjaxResult likeMoment(@RequestBody LikeMomentBO bo) { public AjaxResult likeMoment(@RequestBody LikeMomentBO bo) {
ValidateOperations.generalValidate(bo); ValidateOperations.generalValidate(bo);
...@@ -123,7 +117,6 @@ public class MBbsMomentController { ...@@ -123,7 +117,6 @@ public class MBbsMomentController {
* @param bo 动态 * @param bo 动态
* @return 投票结果 * @return 投票结果
*/ */
@MobileAuth
@PostMapping("/vote") @PostMapping("/vote")
public AjaxResult voteMoment(@RequestBody VoteMomentBO bo) { public AjaxResult voteMoment(@RequestBody VoteMomentBO bo) {
ValidateOperations.generalValidate(bo); ValidateOperations.generalValidate(bo);
...@@ -140,7 +133,6 @@ public class MBbsMomentController { ...@@ -140,7 +133,6 @@ public class MBbsMomentController {
* @param momentId 动态Id * @param momentId 动态Id
* @return 投票结果 * @return 投票结果
*/ */
@MobileAuth
@GetMapping("/vote/count") @GetMapping("/vote/count")
public AjaxResult getMomentVoteCount(@RequestParam Long momentId) { public AjaxResult getMomentVoteCount(@RequestParam Long momentId) {
List<BbsVoteOptionVO> dbOptionCount = this.momentVoteOptionService.getVoteOptionCount(momentId); List<BbsVoteOptionVO> dbOptionCount = this.momentVoteOptionService.getVoteOptionCount(momentId);
...@@ -158,7 +150,6 @@ public class MBbsMomentController { ...@@ -158,7 +150,6 @@ public class MBbsMomentController {
* @param momentId 动态Id * @param momentId 动态Id
* @return 投票记录 * @return 投票记录
*/ */
@MobileAuth
@GetMapping("/votes") @GetMapping("/votes")
public TableDataInfo getMomentVotes(@RequestParam Long momentId, @RequestParam String optionCode) { public TableDataInfo getMomentVotes(@RequestParam Long momentId, @RequestParam String optionCode) {
PageUtils.startPage(); PageUtils.startPage();
...@@ -172,12 +163,11 @@ public class MBbsMomentController { ...@@ -172,12 +163,11 @@ public class MBbsMomentController {
* *
* @return 动态 * @return 动态
*/ */
@MobileAuth
@GetMapping("/comments") @GetMapping("/comments")
public TableDataInfo getMomentComments(@RequestParam Long momentId) { public TableDataInfo getMomentComments(@RequestParam Long momentId) {
String userName = MobileTokenHelper.getUserName(); String username = SecurityUtils.getUsername();
PageUtils.clearPage(); PageUtils.clearPage();
List<BbsCommentDetailVO> dbComments = this.momentCommentService.getMomentComments(momentId, userName); List<BbsCommentDetailVO> dbComments = this.momentCommentService.getMomentComments(momentId, username);
return TableDataInfo.getDataTable(dbComments); return TableDataInfo.getDataTable(dbComments);
} }
...@@ -188,7 +178,6 @@ public class MBbsMomentController { ...@@ -188,7 +178,6 @@ public class MBbsMomentController {
* @param bo 动态 * @param bo 动态
* @return 投票结果 * @return 投票结果
*/ */
@MobileAuth
@PostMapping("/comment") @PostMapping("/comment")
public AjaxResult commentMoment(@RequestBody CommentMomentBO bo) { public AjaxResult commentMoment(@RequestBody CommentMomentBO bo) {
ValidateOperations.generalValidate(bo); ValidateOperations.generalValidate(bo);
...@@ -205,7 +194,6 @@ public class MBbsMomentController { ...@@ -205,7 +194,6 @@ public class MBbsMomentController {
* @param commentId 评论Id * @param commentId 评论Id
* @return 删除结果 * @return 删除结果
*/ */
@MobileAuth
@DeleteMapping("/comment/delete/{commentId}") @DeleteMapping("/comment/delete/{commentId}")
public AjaxResult deleteComment(@PathVariable Long commentId) { public AjaxResult deleteComment(@PathVariable Long commentId) {
this.momentService.userDeleteComment(commentId); this.momentService.userDeleteComment(commentId);
...@@ -219,7 +207,6 @@ public class MBbsMomentController { ...@@ -219,7 +207,6 @@ public class MBbsMomentController {
* @param bo 评论 * @param bo 评论
* @return 精选结果 * @return 精选结果
*/ */
@MobileAuth
@PostMapping("/comment/featured") @PostMapping("/comment/featured")
public AjaxResult featuredComment(@RequestBody FeaturedCommentBO bo) { public AjaxResult featuredComment(@RequestBody FeaturedCommentBO bo) {
ValidateOperations.generalValidate(bo); ValidateOperations.generalValidate(bo);
......
...@@ -2,7 +2,6 @@ package com.tangguo.controller.mobile; ...@@ -2,7 +2,6 @@ package com.tangguo.controller.mobile;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo; import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.utils.PageUtils; import com.tangguo.common.utils.PageUtils;
import com.tangguo.common.utils.ValidateOperations; import com.tangguo.common.utils.ValidateOperations;
import com.tangguo.domain.bo.CreateTopicBO; import com.tangguo.domain.bo.CreateTopicBO;
...@@ -39,7 +38,6 @@ public class MBbsTopicController { ...@@ -39,7 +38,6 @@ public class MBbsTopicController {
* @param name 话题名称 * @param name 话题名称
* @return 话题 * @return 话题
*/ */
@MobileAuth
@GetMapping("/select") @GetMapping("/select")
public TableDataInfo getSelectTopics(String name) { public TableDataInfo getSelectTopics(String name) {
PageUtils.startPage(); PageUtils.startPage();
...@@ -54,7 +52,6 @@ public class MBbsTopicController { ...@@ -54,7 +52,6 @@ public class MBbsTopicController {
* @param bo 话题 * @param bo 话题
* @return 创建结果 * @return 创建结果
*/ */
@MobileAuth
@PostMapping("/create") @PostMapping("/create")
public AjaxResult createTopic(@RequestBody CreateTopicBO bo) { public AjaxResult createTopic(@RequestBody CreateTopicBO bo) {
ValidateOperations.generalValidate(bo); ValidateOperations.generalValidate(bo);
...@@ -68,7 +65,6 @@ public class MBbsTopicController { ...@@ -68,7 +65,6 @@ public class MBbsTopicController {
* *
* @return 话题 * @return 话题
*/ */
@MobileAuth
@GetMapping("/ranking") @GetMapping("/ranking")
public AjaxResult getRankingTopic() { public AjaxResult getRankingTopic() {
List<BbsTopicListVO> dbTopics = this.topicService.getRankingTopic(); List<BbsTopicListVO> dbTopics = this.topicService.getRankingTopic();
...@@ -82,7 +78,6 @@ public class MBbsTopicController { ...@@ -82,7 +78,6 @@ public class MBbsTopicController {
* @param bo 查询参数 * @param bo 查询参数
* @return 话题明细 * @return 话题明细
*/ */
@MobileAuth
@GetMapping("/moments") @GetMapping("/moments")
public TableDataInfo getTopicMoments(QueryMomentBO bo) { public TableDataInfo getTopicMoments(QueryMomentBO bo) {
PageUtils.clearPage(); PageUtils.clearPage();
......
...@@ -2,19 +2,17 @@ package com.tangguo.controller.mobile; ...@@ -2,19 +2,17 @@ package com.tangguo.controller.mobile;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo; import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.mauth.MobileAuth;
import com.tangguo.common.mauth.MobileTokenHelper;
import com.tangguo.common.utils.PageUtils; import com.tangguo.common.utils.PageUtils;
import com.tangguo.domain.bo.CodeLoginBO; import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.domain.vo.BbsMomentListVO; import com.tangguo.domain.vo.BbsMomentListVO;
import com.tangguo.domain.vo.BbsUserMomentCountVO; import com.tangguo.domain.vo.BbsUserMomentCountVO;
import com.tangguo.service.IBbsMomentService; import com.tangguo.service.IBbsMomentService;
import com.tangguo.service.impl.BbsUserService; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 移动端用户控制器 * 移动端用户控制器
...@@ -26,48 +24,18 @@ import java.util.Map; ...@@ -26,48 +24,18 @@ import java.util.Map;
@RequestMapping("/bbs/mobile/user") @RequestMapping("/bbs/mobile/user")
public class MBbsUserController { public class MBbsUserController {
@Resource
private BbsUserService bbsUserService;
@Resource @Resource
private IBbsMomentService momentService; private IBbsMomentService momentService;
/**
* 企微用户Code登录
*
* @param bo 登录参数
* @return 登录结果
*/
@PostMapping("/code/login")
public AjaxResult codeLogin(@RequestBody CodeLoginBO bo) {
Map<String, Object> tokenMap = this.bbsUserService.codeLogin(bo);
return AjaxResult.success(tokenMap);
}
/**
* 查询用户信息
*
* @return 用户信息
*/
@MobileAuth
@GetMapping("/profile")
public AjaxResult getUserProfile() {
Map<String, Object> profileMap = this.bbsUserService.getUserProfile();
return AjaxResult.success(profileMap);
}
/** /**
* 查询用户动态统计 * 查询用户动态统计
* *
* @return 动态统计 * @return 动态统计
*/ */
@MobileAuth
@GetMapping("/moment/count") @GetMapping("/moment/count")
public AjaxResult getUserMomentCount() { public AjaxResult getUserMomentCount() {
String username = MobileTokenHelper.getUserName(); String username = SecurityUtils.getUsername();
BbsUserMomentCountVO momentCount = this.momentService.getUserMomentCount(username); BbsUserMomentCountVO momentCount = this.momentService.getUserMomentCount(username);
return AjaxResult.success(momentCount); return AjaxResult.success(momentCount);
} }
...@@ -78,10 +46,9 @@ public class MBbsUserController { ...@@ -78,10 +46,9 @@ public class MBbsUserController {
* *
* @return 动态 * @return 动态
*/ */
@MobileAuth
@GetMapping("/moments") @GetMapping("/moments")
public TableDataInfo getUserMoments(String content) { public TableDataInfo getUserMoments(String content) {
String username = MobileTokenHelper.getUserName(); String username = SecurityUtils.getUsername();
PageUtils.clearPage(); PageUtils.clearPage();
List<BbsMomentListVO> moments = this.momentService.getUserMoments(username, content); List<BbsMomentListVO> moments = this.momentService.getUserMoments(username, content);
return TableDataInfo.getDataTable(moments); return TableDataInfo.getDataTable(moments);
......
...@@ -51,7 +51,7 @@ public class BbsMomentController extends BaseController { ...@@ -51,7 +51,7 @@ public class BbsMomentController extends BaseController {
@PreAuthorize("@ss.hasPermi('bbs:moment:query')") @PreAuthorize("@ss.hasPermi('bbs:moment:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult getInfo(@PathVariable("id") Long id) {
BbsMomentListVO dbMoment = this.bbsMomentService.getMomentDetail(id); BbsMomentListVO dbMoment = this.bbsMomentService.selectBbsMoment(id);
return success(dbMoment); return success(dbMoment);
} }
......
...@@ -121,7 +121,7 @@ public class BbsMoment extends BaseEntity { ...@@ -121,7 +121,7 @@ public class BbsMoment extends BaseEntity {
/** 用户姓名 */ /** 用户姓名 */
@TableField(exist = false) @TableField(exist = false)
private String nikeName; private String nickName;
/** 用户部门 */ /** 用户部门 */
@TableField(exist = false) @TableField(exist = false)
......
...@@ -43,7 +43,7 @@ public class BbsMomentComment extends BaseEntity { ...@@ -43,7 +43,7 @@ public class BbsMomentComment extends BaseEntity {
/** 评论用户姓名 */ /** 评论用户姓名 */
@Excel(name = "评论用户姓名") @Excel(name = "评论用户姓名")
@ApiModelProperty("评论用户姓名") @ApiModelProperty("评论用户姓名")
private String nikeName; private String nickName;
/** 评论用户名 */ /** 评论用户名 */
@Excel(name = "评论用户名") @Excel(name = "评论用户名")
......
...@@ -22,7 +22,7 @@ public class BbsCommentDetailVO { ...@@ -22,7 +22,7 @@ public class BbsCommentDetailVO {
private Date createTime; private Date createTime;
/** 评论用户姓名 */ /** 评论用户姓名 */
private String nikeName; private String nickName;
/** 评论用户名 */ /** 评论用户名 */
private String userName; private String userName;
......
...@@ -22,7 +22,7 @@ public class BbsCommentVO { ...@@ -22,7 +22,7 @@ public class BbsCommentVO {
private Date createTime; private Date createTime;
/** 评论用户姓名 */ /** 评论用户姓名 */
private String nikeName; private String nickName;
/** 评论用户名 */ /** 评论用户名 */
private String userName; private String userName;
......
...@@ -25,7 +25,7 @@ public class BbsMomentDetailVO { ...@@ -25,7 +25,7 @@ public class BbsMomentDetailVO {
private Long id; private Long id;
/** 发布人用户姓名 */ /** 发布人用户姓名 */
private String nikeName; private String nickName;
/** 发布人用户名 */ /** 发布人用户名 */
private String userName; private String userName;
......
...@@ -25,7 +25,7 @@ public class BbsMomentListVO { ...@@ -25,7 +25,7 @@ public class BbsMomentListVO {
private Long id; private Long id;
/** 发布人用户姓名 */ /** 发布人用户姓名 */
private String nikeName; private String nickName;
/** 发布人用户名 */ /** 发布人用户名 */
private String userName; private String userName;
......
...@@ -19,6 +19,6 @@ public class BbsVoteVO { ...@@ -19,6 +19,6 @@ public class BbsVoteVO {
private Date createTime; private Date createTime;
/** 用户姓名 */ /** 用户姓名 */
private String nikeName; private String nickName;
} }
package com.tangguo.mapper;
import com.tangguo.common.domain.QwmhUserInfo;
import org.apache.ibatis.annotations.Param;
/**
* 动态用户Mapper
*
* @author 谈笑
* @createTime 2025-09-02 15:30:05 星期二
*/
public interface BbsUserMapper {
QwmhUserInfo selectQwmhUserInfo(@Param("userName") String userName);
}
...@@ -25,6 +25,15 @@ public interface IBbsMomentService extends IService<BbsMoment> { ...@@ -25,6 +25,15 @@ public interface IBbsMomentService extends IService<BbsMoment> {
List<BbsMoment> selectBbsMomentList(BbsMoment bbsMoment); List<BbsMoment> selectBbsMomentList(BbsMoment bbsMoment);
/**
* 查询动态详情
*
* @param momentId 动态Id
* @return 动态列表
*/
BbsMomentListVO selectBbsMoment(Long momentId);
/** /**
* 删除动态 * 删除动态
* *
......
...@@ -5,9 +5,10 @@ import cn.hutool.core.util.StrUtil; ...@@ -5,9 +5,10 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.dfa.FoundWord; import cn.hutool.dfa.FoundWord;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.core.domain.entity.SysUser;
import com.tangguo.common.enums.*; import com.tangguo.common.enums.*;
import com.tangguo.common.exception.ServiceException; import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.mauth.MobileTokenHelper; import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.utils.SensitiveWordUtils; import com.tangguo.common.utils.SensitiveWordUtils;
import com.tangguo.domain.BbsMoment; import com.tangguo.domain.BbsMoment;
import com.tangguo.domain.BbsMomentAttachment; import com.tangguo.domain.BbsMomentAttachment;
...@@ -68,6 +69,22 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -68,6 +69,22 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
} }
/**
* 查询动态详情
*
* @param momentId 动态Id
* @return 动态列表
*/
@Override
public BbsMomentListVO selectBbsMoment(Long momentId) {
String userName = SecurityUtils.getUsername();
BbsMomentListVO dbMoment = this.baseMapper.selectMomentDetail(momentId, userName);
this.fillMoment(Collections.singletonList(dbMoment), userName);
dbMoment.setComments(null);
return dbMoment;
}
/** /**
* 删除动态 * 删除动态
* *
...@@ -114,7 +131,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -114,7 +131,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
*/ */
@Override @Override
public List<BbsMomentListVO> getMoments(QueryMomentBO bo) { public List<BbsMomentListVO> getMoments(QueryMomentBO bo) {
String userName = MobileTokenHelper.getUserName(); String userName = SecurityUtils.getUsername();
List<BbsMomentListVO> dbMoments = this.baseMapper.selectMoments(userName, bo); List<BbsMomentListVO> dbMoments = this.baseMapper.selectMoments(userName, bo);
this.fillMoment(dbMoments, userName); this.fillMoment(dbMoments, userName);
return dbMoments; return dbMoments;
...@@ -129,7 +146,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -129,7 +146,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
*/ */
@Override @Override
public BbsMomentListVO getMomentDetail(Long momentId) { public BbsMomentListVO getMomentDetail(Long momentId) {
String userName = MobileTokenHelper.getUserName(); String userName = SecurityUtils.getUsername();
BbsMomentListVO dbMoment = this.baseMapper.selectMomentDetail(momentId, userName); BbsMomentListVO dbMoment = this.baseMapper.selectMomentDetail(momentId, userName);
this.fillMoment(Collections.singletonList(dbMoment), userName); this.fillMoment(Collections.singletonList(dbMoment), userName);
dbMoment.setComments(null); dbMoment.setComments(null);
...@@ -146,7 +163,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -146,7 +163,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
@Override @Override
public void userCreateMoment(CreateMomentBO bo) { public void userCreateMoment(CreateMomentBO bo) {
// 添加动态 // 添加动态
String username = MobileTokenHelper.getUserName(); String username = SecurityUtils.getUsername();
BbsMoment newMoment = this.buildMoment(bo); BbsMoment newMoment = this.buildMoment(bo);
newMoment.setUserName(username); newMoment.setUserName(username);
this.save(newMoment); this.save(newMoment);
...@@ -173,7 +190,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -173,7 +190,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public void userDeleteMoment(Long momentId) { public void userDeleteMoment(Long momentId) {
String username = MobileTokenHelper.getUserName(); String username = SecurityUtils.getUsername();
BbsMoment dbMoment = this.getById(momentId); BbsMoment dbMoment = this.getById(momentId);
if (Objects.isNull(dbMoment)) { if (Objects.isNull(dbMoment)) {
throw new ServiceException("删除失败,未查询到当前动态数据。"); throw new ServiceException("删除失败,未查询到当前动态数据。");
...@@ -198,7 +215,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -198,7 +215,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("点赞失败,未查询到当前动态数据。"); throw new ServiceException("点赞失败,未查询到当前动态数据。");
} }
String userName = MobileTokenHelper.getUserName(); String userName = SecurityUtils.getUsername();
long likeStatus = this.likeService.getUserMomentLikeCount(dbMoment.getId(), userName); long likeStatus = this.likeService.getUserMomentLikeCount(dbMoment.getId(), userName);
int likeCount = dbMoment.getLikeCount(); int likeCount = dbMoment.getLikeCount();
...@@ -242,7 +259,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -242,7 +259,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("投票失败,当前动态未开启投票。"); throw new ServiceException("投票失败,当前动态未开启投票。");
} }
String username = MobileTokenHelper.getUserName(); String username = SecurityUtils.getUsername();
long voteCount = this.voteService.getUserMomentVoteCount(dbMoment.getId(), username); long voteCount = this.voteService.getUserMomentVoteCount(dbMoment.getId(), username);
if (voteCount > 0) { if (voteCount > 0) {
throw new ServiceException("投票失败,已对当前动态投票。"); throw new ServiceException("投票失败,已对当前动态投票。");
...@@ -296,13 +313,14 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -296,13 +313,14 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
} }
// 添加动态评论 // 添加动态评论
SysUser dbUser = SecurityUtils.getLoginUser().getUser();
BbsMomentComment newComment = new BbsMomentComment(); BbsMomentComment newComment = new BbsMomentComment();
newComment.setMomentId(dbMoment.getId()); newComment.setMomentId(dbMoment.getId());
newComment.setUserName(MobileTokenHelper.getUserName()); newComment.setUserName(dbUser.getUserName());
newComment.setNikeName(MobileTokenHelper.getNikeName()); newComment.setNickName(dbUser.getNickName());
newComment.setContent(bo.getContent()); newComment.setContent(bo.getContent());
newComment.setStatus(CommentStatus.ZC.getStatus()); newComment.setStatus(CommentStatus.ZC.getStatus());
newComment.setIsFeatured(1); newComment.setIsFeatured(0);
this.commentService.save(newComment); this.commentService.save(newComment);
// 更新动态评论 // 更新动态评论
...@@ -310,7 +328,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -310,7 +328,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
updComment.setId(newComment.getId()); updComment.setId(newComment.getId());
if (Objects.nonNull(dbParentComment)) { if (Objects.nonNull(dbParentComment)) {
updComment.setParentId(dbParentComment.getId()); updComment.setParentId(dbParentComment.getId());
updComment.setReplyNikeName(dbParentComment.getNikeName()); updComment.setReplyNikeName(dbParentComment.getNickName());
updComment.setAncestorPath(dbParentComment.getAncestorPath() + "," + newComment.getId()); updComment.setAncestorPath(dbParentComment.getAncestorPath() + "," + newComment.getId());
} else { } else {
updComment.setAncestorPath(String.valueOf(newComment.getId())); updComment.setAncestorPath(String.valueOf(newComment.getId()));
...@@ -338,7 +356,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -338,7 +356,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("删除失败,未查询到当前动态评论数据。"); throw new ServiceException("删除失败,未查询到当前动态评论数据。");
} }
String userName = MobileTokenHelper.getUserName(); String userName = SecurityUtils.getUsername();
if (!dbComment.getUserName().equals(userName)) { if (!dbComment.getUserName().equals(userName)) {
throw new ServiceException("删除失败,没有对当前动态评论的操作权限。"); throw new ServiceException("删除失败,没有对当前动态评论的操作权限。");
} }
...@@ -363,7 +381,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -363,7 +381,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("操作失败,未查询到当前动态数据。"); throw new ServiceException("操作失败,未查询到当前动态数据。");
} }
String userName = MobileTokenHelper.getUserName(); String userName = SecurityUtils.getUsername();
if (!dbMoment.getUserName().equals(userName)) { if (!dbMoment.getUserName().equals(userName)) {
throw new ServiceException("操作失败,没有对当前动态评论的操作权限。"); throw new ServiceException("操作失败,没有对当前动态评论的操作权限。");
} }
...@@ -568,7 +586,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -568,7 +586,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
BbsCommentVO cv = new BbsCommentVO(); BbsCommentVO cv = new BbsCommentVO();
cv.setId(c.getId()); cv.setId(c.getId());
cv.setCreateTime(c.getCreateTime()); cv.setCreateTime(c.getCreateTime());
cv.setNikeName(c.getNikeName()); cv.setNickName(c.getNickName());
cv.setUserName(c.getUserName()); cv.setUserName(c.getUserName());
cv.setContent(c.getContent()); cv.setContent(c.getContent());
cvs.add(cv); cvs.add(cv);
......
...@@ -10,7 +10,7 @@ import com.tangguo.common.constant.TopicConstant; ...@@ -10,7 +10,7 @@ import com.tangguo.common.constant.TopicConstant;
import com.tangguo.common.core.redis.RedisCache; import com.tangguo.common.core.redis.RedisCache;
import com.tangguo.common.enums.TopicTopStatus; import com.tangguo.common.enums.TopicTopStatus;
import com.tangguo.common.exception.ServiceException; import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.mauth.MobileTokenHelper; import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.utils.SensitiveWordUtils; import com.tangguo.common.utils.SensitiveWordUtils;
import com.tangguo.common.utils.StringUtils; import com.tangguo.common.utils.StringUtils;
import com.tangguo.domain.BbsTopic; import com.tangguo.domain.BbsTopic;
...@@ -211,7 +211,7 @@ public class BbsTopicServiceImpl extends ServiceImpl<BbsTopicMapper, BbsTopic> i ...@@ -211,7 +211,7 @@ public class BbsTopicServiceImpl extends ServiceImpl<BbsTopicMapper, BbsTopic> i
} }
BbsTopic newTopic = new BbsTopic(); BbsTopic newTopic = new BbsTopic();
newTopic.setCreateBy(MobileTokenHelper.getUserName()); newTopic.setCreateBy(SecurityUtils.getUsername());
newTopic.setSource("移动端用户"); newTopic.setSource("移动端用户");
newTopic.setName(topicName); newTopic.setName(topicName);
this.save(newTopic); this.save(newTopic);
......
package com.tangguo.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.tangguo.common.domain.QwmhUserInfo;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.mauth.MobileTokenHelper;
import com.tangguo.domain.bo.CodeLoginBO;
import com.tangguo.mapper.BbsUserMapper;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/**
* 动态用户业务类
*
* @author 谈笑
* @createTime 2025-09-02 14:55:04 星期二
*/
@Slf4j
@Service
public class BbsUserService {
@Resource
private WxCpService wxCpService;
@Resource
private BbsUserMapper bbsUserMapper;
/**
* 企微用户Code登录
*
* @param bo 登录参数
* @return 登录结果
*/
public Map<String, Object> codeLogin(CodeLoginBO bo) {
String userName;
try {
log.info("=> 移动端用户登录:{}", bo);
WxCpOauth2UserInfo authUserInfo = this.wxCpService.getOauth2Service().getAuthUserInfo(bo.getCode());
userName = authUserInfo.getUserId();
} catch (WxErrorException e) {
log.error("=> 移动端用户登录失败,查询当前企微用户数据失败:", e);
throw new ServiceException("登录失败,查询当前企微用户数据失败。");
}
QwmhUserInfo dbUser = this.bbsUserMapper.selectQwmhUserInfo(userName);
if (Objects.nonNull(dbUser)) {
Map<String, Object> payloads = new LinkedHashMap<>(2);
payloads.put("userName", dbUser.getUserName());
payloads.put("nikeName", dbUser.getNikeName());
return MobileTokenHelper.createDetailToken(payloads);
} else {
throw new ServiceException("登录失败,未查询到当前登录用户数据。");
}
}
/**
* 查询用户信息
*
* @return 用户信息
*/
public Map<String, Object> getUserProfile() {
String username = MobileTokenHelper.getUserName();
QwmhUserInfo dbUser = this.bbsUserMapper.selectQwmhUserInfo(username);
if (Objects.nonNull(dbUser)) {
return BeanUtil.beanToMap(dbUser, false, false);
} else {
throw new ServiceException("操作失败,未查询到当前登录用户信息。");
}
}
}
...@@ -45,11 +45,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -45,11 +45,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.id, c.id,
c.create_time, c.create_time,
c.moment_id, c.moment_id,
c.nike_name, c.nick_name,
c.user_name, c.user_name,
c.content, c.content,
c.parent_id, c.parent_id,
c.reply_nike_name, c.reply_nick_name,
ROW_NUMBER() OVER (PARTITION BY moment_id ORDER BY create_time) AS rn ROW_NUMBER() OVER (PARTITION BY moment_id ORDER BY create_time) AS rn
FROM FROM
bbs_moment_comment c bbs_moment_comment c
...@@ -85,11 +85,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -85,11 +85,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.id, c.id,
c.create_time, c.create_time,
c.moment_id, c.moment_id,
c.nike_name, c.nick_name,
c.user_name, c.user_name,
c.content, c.content,
c.parent_id, c.parent_id,
c.reply_nike_name, c.reply_nick_name,
c.is_featured, c.is_featured,
IF(c.user_name = #{userName}, 1, 0) AS is_self IF(c.user_name = #{userName}, 1, 0) AS is_self
FROM FROM
......
...@@ -7,12 +7,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -7,12 +7,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBbsMomentList" resultType="com.tangguo.domain.BbsMoment"> <select id="selectBbsMomentList" resultType="com.tangguo.domain.BbsMoment">
SELECT SELECT
m.*, m.*,
uv.nike_name, uv.nick_name,
uv.dept_name ud.dept_name
FROM FROM
bbs_moment m bbs_moment m
LEFT JOIN LEFT JOIN
qwmh_sys_user_view uv ON uv.user_name = m.user_name sys_user uv ON uv.user_name = m.user_name
LEFT JOIN
sys_dept ud ON ud.dept_id = uv.dept_id
<where> <where>
<if test="moment.content != null and moment.content != ''"> <if test="moment.content != null and moment.content != ''">
m.content LIKE CONCAT('%', #{moment.content}, '%') m.content LIKE CONCAT('%', #{moment.content}, '%')
...@@ -31,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -31,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectUserMomentCount" resultType="com.tangguo.domain.vo.BbsUserMomentCountVO"> <select id="selectUserMomentCount" resultType="com.tangguo.domain.vo.BbsUserMomentCountVO">
SELECT SELECT
(SELECT COUNT(*) FROM bbs_moment WHERE user_name = #{userName}) AS monent_count, (SELECT COUNT(*) FROM bbs_moment WHERE user_name = #{userName}) AS moment_count,
(SELECT COUNT(*) FROM bbs_moment_comment WHERE user_name = #{userName}) AS comment_count, (SELECT COUNT(*) FROM bbs_moment_comment WHERE user_name = #{userName}) AS comment_count,
(SELECT COUNT(*) FROM bbs_moment_like WHERE user_name = #{userName}) AS like_count (SELECT COUNT(*) FROM bbs_moment_like WHERE user_name = #{userName}) AS like_count
</select> </select>
...@@ -78,14 +80,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -78,14 +80,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMoments" resultType="com.tangguo.domain.vo.BbsMomentListVO"> <select id="selectMoments" resultType="com.tangguo.domain.vo.BbsMomentListVO">
SELECT SELECT
m.*, m.*,
uv.nike_name, uv.nick_name,
IF(l.id IS NOT NULL, 1, 0) AS is_like, IF(l.id IS NOT NULL, 1, 0) AS is_like,
IF(v.id IS NOT NULL, 1, 0) AS is_vote, IF(v.id IS NOT NULL, 1, 0) AS is_vote,
IF(m.user_name = #{userName}, 1, 0) AS is_self IF(m.user_name = #{userName}, 1, 0) AS is_self
FROM FROM
bbs_moment m bbs_moment m
LEFT JOIN LEFT JOIN
qwmh_sys_user_view uv ON uv.user_name = m.user_name sys_user uv ON uv.user_name = m.user_name
LEFT JOIN LEFT JOIN
( (
SELECT SELECT
...@@ -120,14 +122,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -120,14 +122,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMomentDetail" resultType="com.tangguo.domain.vo.BbsMomentListVO"> <select id="selectMomentDetail" resultType="com.tangguo.domain.vo.BbsMomentListVO">
SELECT SELECT
m.*, m.*,
uv.nike_name, uv.nick_name,
IF(l.id IS NOT NULL, 1, 0) AS is_like, IF(l.id IS NOT NULL, 1, 0) AS is_like,
IF(v.id IS NOT NULL, 1, 0) AS is_vote, IF(v.id IS NOT NULL, 1, 0) AS is_vote,
IF(m.user_name = #{userName}, 1, 0) AS is_self IF(m.user_name = #{userName}, 1, 0) AS is_self
FROM FROM
bbs_moment m bbs_moment m
LEFT JOIN LEFT JOIN
qwmh_sys_user_view uv ON uv.user_name = m.user_name sys_user uv ON uv.user_name = m.user_name
LEFT JOIN LEFT JOIN
( (
SELECT SELECT
......
...@@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectVotes" resultType="com.tangguo.domain.vo.BbsVoteVO"> <select id="selectVotes" resultType="com.tangguo.domain.vo.BbsVoteVO">
SELECT SELECT
v.create_time, v.create_time,
uv.nike_name uv.nick_name
FROM FROM
bbs_moment_vote v bbs_moment_vote v
LEFT JOIN LEFT JOIN
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsUserMapper">
<select id="selectQwmhUserInfo" resultType="com.tangguo.common.domain.QwmhUserInfo">
SELECT
uv.nike_name,
uv.user_name,
uv.dept_name,
IFNULL(p.current_points, 0) AS current_points,
IFNULL(p.accumulated_points, 0) AS accumulated_points,
IFNULL(p.grade_name, ug.name) AS grade_name
FROM
qwmh_sys_user_view uv
LEFT JOIN
bbs_user_points p ON p.user_name = uv.user_name
CROSS JOIN (
SELECT (SELECT name FROM bbs_grade WHERE is_initial = 1 ORDER BY create_time DESC LIMIT 1) AS name
) ug
WHERE
uv.user_name = #{userName}
</select>
</mapper>
...@@ -7,12 +7,10 @@ import com.tangguo.common.annotation.RepeatSubmit; ...@@ -7,12 +7,10 @@ import com.tangguo.common.annotation.RepeatSubmit;
import com.tangguo.common.core.controller.BaseController; import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo; import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.domain.QwmhUserInfo;
import com.tangguo.common.enums.BusinessType; import com.tangguo.common.enums.BusinessType;
import com.tangguo.common.utils.poi.ExcelUtil; import com.tangguo.common.utils.poi.ExcelUtil;
import com.tangguo.domain.BbsPointsGoods; import com.tangguo.domain.BbsPointsGoods;
import com.tangguo.domain.BbsUserPointsExchange; import com.tangguo.domain.BbsUserPointsExchange;
import com.tangguo.mapper.BbsUserPointsExchangeMapper;
import com.tangguo.service.IBbsPointsGoodsService; import com.tangguo.service.IBbsPointsGoodsService;
import com.tangguo.service.IBbsUserPointsExchangeService; import com.tangguo.service.IBbsUserPointsExchangeService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -35,9 +33,6 @@ import java.util.List; ...@@ -35,9 +33,6 @@ import java.util.List;
@RequestMapping("/bbs/points/exchange") @RequestMapping("/bbs/points/exchange")
public class BbsUserPointsExchangeController extends BaseController { public class BbsUserPointsExchangeController extends BaseController {
@Resource
private BbsUserPointsExchangeMapper userPointsExchangeMapper;
@Resource @Resource
private IBbsUserPointsExchangeService bbsUserPointsExchangeService; private IBbsUserPointsExchangeService bbsUserPointsExchangeService;
...@@ -45,18 +40,6 @@ public class BbsUserPointsExchangeController extends BaseController { ...@@ -45,18 +40,6 @@ public class BbsUserPointsExchangeController extends BaseController {
private IBbsPointsGoodsService pointsGoodsService; private IBbsPointsGoodsService pointsGoodsService;
/**
* 查询兑换人
*/
@ApiOperation("查询兑换人")
@PreAuthorize("@ss.hasPermi('points:points:list')")
@GetMapping("/select/users")
public AjaxResult selectUsers(String keyword) {
List<QwmhUserInfo> users = this.userPointsExchangeMapper.selectPointsUsers(keyword);
return AjaxResult.success(users);
}
/** /**
* 查询兑换商品 * 查询兑换商品
*/ */
......
...@@ -71,7 +71,7 @@ public class BbsUserPoints extends BaseEntity { ...@@ -71,7 +71,7 @@ public class BbsUserPoints extends BaseEntity {
*/ */
@Excel(name = "用户姓名") @Excel(name = "用户姓名")
@TableField(exist = false) @TableField(exist = false)
private String nikeName; private String nickName;
/** /**
* 用户部门 * 用户部门
......
...@@ -35,7 +35,7 @@ public class BbsUserPointsExchange extends BaseEntity { ...@@ -35,7 +35,7 @@ public class BbsUserPointsExchange extends BaseEntity {
/** 用户姓名 */ /** 用户姓名 */
@Excel(name = "用户姓名") @Excel(name = "用户姓名")
@ApiModelProperty("用户姓名") @ApiModelProperty("用户姓名")
private String nikeName; private String nickName;
/** 用户名 */ /** 用户名 */
@Excel(name = "用户名") @Excel(name = "用户名")
......
package com.tangguo.mapper; package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.common.domain.QwmhUserInfo;
import com.tangguo.domain.BbsUserPointsExchange; import com.tangguo.domain.BbsUserPointsExchange;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -17,7 +16,4 @@ public interface BbsUserPointsExchangeMapper extends BaseMapper<BbsUserPointsExc ...@@ -17,7 +16,4 @@ public interface BbsUserPointsExchangeMapper extends BaseMapper<BbsUserPointsExc
List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(@Param("exchange") BbsUserPointsExchange exchange); List<BbsUserPointsExchange> selectBbsUserPointsExchangeList(@Param("exchange") BbsUserPointsExchange exchange);
List<QwmhUserInfo> selectPointsUsers(@Param("keyword") String keyword);
} }
package com.tangguo.mapper; package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.common.domain.QwmhUserInfo;
import com.tangguo.domain.BbsUserPoints; import com.tangguo.domain.BbsUserPoints;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -18,13 +17,7 @@ public interface BbsUserPointsMapper extends BaseMapper<BbsUserPoints> { ...@@ -18,13 +17,7 @@ public interface BbsUserPointsMapper extends BaseMapper<BbsUserPoints> {
List<BbsUserPoints> selectBbsUserPointsList(@Param("points") BbsUserPoints points); List<BbsUserPoints> selectBbsUserPointsList(@Param("points") BbsUserPoints points);
QwmhUserInfo selectQwmhUser(@Param("userName") String userName); int selectUserCount(@Param("userName") String userName);
BbsUserPoints selectUserPoints(@Param("userName") String userName);
int initUserPointsGrade();
int refreshUserPointsGrade(); int refreshUserPointsGrade();
......
...@@ -23,6 +23,15 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> { ...@@ -23,6 +23,15 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> {
List<BbsUserPoints> selectBbsUserPointsList(BbsUserPoints bbsUserPoints); List<BbsUserPoints> selectBbsUserPointsList(BbsUserPoints bbsUserPoints);
/**
* 查询用户积分
*
* @param userName 用户名
* @return 积分
*/
BbsUserPoints getUserPoints(String userName);
/** /**
* 查询用户积分 * 查询用户积分
* *
......
...@@ -95,7 +95,7 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE ...@@ -95,7 +95,7 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE
// 添加兑换记录 // 添加兑换记录
BbsUserPointsExchange addExchange = new BbsUserPointsExchange(); BbsUserPointsExchange addExchange = new BbsUserPointsExchange();
addExchange.setNikeName(exchange.getNikeName()); addExchange.setNickName(exchange.getNickName());
addExchange.setUserName(dbUserPoints.getUserName()); addExchange.setUserName(dbUserPoints.getUserName());
addExchange.setUserGradeName(dbUserPoints.getGradeName()); addExchange.setUserGradeName(dbUserPoints.getGradeName());
addExchange.setGoodsName(dbGoods.getName()); addExchange.setGoodsName(dbGoods.getName());
......
package com.tangguo.service.impl; package com.tangguo.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.domain.PointsDetail; import com.tangguo.common.domain.PointsDetail;
import com.tangguo.common.domain.QwmhUserInfo;
import com.tangguo.common.exception.ServiceException; import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.SecurityUtils; import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.domain.BbsGrade; import com.tangguo.domain.BbsGrade;
...@@ -55,6 +55,20 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B ...@@ -55,6 +55,20 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
} }
/**
* 查询用户积分
*
* @param userName 用户名
* @return 积分
*/
@Override
public BbsUserPoints getUserPoints(String userName) {
return this.getOne(
Wrappers.lambdaQuery(BbsUserPoints.class).eq(BbsUserPoints::getUserName, userName)
);
}
/** /**
* 查询用户积分 * 查询用户积分
* *
...@@ -64,12 +78,10 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B ...@@ -64,12 +78,10 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
@Override @Override
public BbsUserPoints getAndInitUserPoints(String userName) { public BbsUserPoints getAndInitUserPoints(String userName) {
BbsUserPoints dbUserPoints = this.baseMapper.selectUserPoints(userName); BbsUserPoints dbUserPoints = this.getUserPoints(userName);
if (Objects.isNull(dbUserPoints)) { if (Objects.isNull(dbUserPoints)) {
QwmhUserInfo qwmhSysUser = this.baseMapper.selectQwmhUser(userName); int dbUserCount = this.baseMapper.selectUserCount(userName);
if (Objects.isNull(qwmhSysUser)) { if (dbUserCount > 0) {
throw new ServiceException("查询用户积分失败,未查询到当前用户数据。");
} else {
// 初始积分 // 初始积分
dbUserPoints = new BbsUserPoints(); dbUserPoints = new BbsUserPoints();
dbUserPoints.setUserName(userName); dbUserPoints.setUserName(userName);
...@@ -83,6 +95,8 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B ...@@ -83,6 +95,8 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
dbUserPoints.setLastUpgradeTime(new Date()); dbUserPoints.setLastUpgradeTime(new Date());
} }
this.save(dbUserPoints); this.save(dbUserPoints);
} else {
throw new ServiceException("查询用户积分失败,未查询到当前用户数据。");
} }
} }
return dbUserPoints; return dbUserPoints;
......
...@@ -4,6 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -4,6 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsGradeMapper"> <mapper namespace="com.tangguo.mapper.BbsGradeMapper">
</mapper> </mapper>
...@@ -4,5 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -4,5 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsPointsSettingMapper"> <mapper namespace="com.tangguo.mapper.BbsPointsSettingMapper">
</mapper> </mapper>
...@@ -10,8 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -10,8 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM FROM
bbs_user_points_exchange e bbs_user_points_exchange e
<where> <where>
<if test="exchange.nikeName != null and exchange.nikeName != ''"> <if test="exchange.nickName != null and exchange.nickName != ''">
e.nike_name LIKE CONCAT('%', #{exchange.nikeName}, '%') e.nick_name LIKE CONCAT('%', #{exchange.nickName}, '%')
</if> </if>
<if test="exchange.userName != null and exchange.userName != ''"> <if test="exchange.userName != null and exchange.userName != ''">
AND e.user_name LIKE CONCAT('%', #{exchange.userName}, '%') AND e.user_name LIKE CONCAT('%', #{exchange.userName}, '%')
...@@ -33,29 +33,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -33,29 +33,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
e.create_time DESC e.create_time DESC
</select> </select>
<select id="selectPointsUsers" resultType="com.tangguo.common.domain.QwmhUserInfo">
SELECT
uv.nike_name,
uv.user_name,
uv.dept_name,
IFNULL(p.current_points, 0) AS current_points,
IFNULL(p.accumulated_points, 0) AS accumulated_points,
IFNULL(p.grade_name, ug.name) AS grade_name
FROM
qwmh_sys_user_view uv
LEFT JOIN
bbs_user_points p ON p.user_name = uv.user_name
CROSS JOIN (
SELECT (SELECT name FROM bbs_grade WHERE is_initial = 1 ORDER BY create_time DESC LIMIT 1) AS name
) ug
<where>
<if test="keyword != null and keyword != ''">
nike_name LIKE CONCAT('%', #{keyword}, '%') OR user_name LIKE CONCAT('%', #{keyword}, '%')
</if>
</where>
ORDER BY
uv.create_time DESC
</select>
</mapper> </mapper>
...@@ -6,22 +6,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -6,22 +6,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBbsUserPointsList" resultType="com.tangguo.domain.BbsUserPoints"> <select id="selectBbsUserPointsList" resultType="com.tangguo.domain.BbsUserPoints">
SELECT SELECT
uv.nike_name, uv.nick_name AS nick_name,
uv.user_name, uv.user_name,
uv.dept_name, ud.dept_name,
IFNULL(p.current_points, 0) AS current_points, IFNULL(p.current_points, 0) AS current_points,
IFNULL(p.accumulated_points, 0) AS accumulated_points, IFNULL(p.accumulated_points, 0) AS accumulated_points,
IFNULL(p.grade_name, ug.name) AS grade_name IFNULL(p.grade_name, ug.name) AS grade_name
FROM FROM
qwmh_sys_user_view uv sys_user uv
LEFT JOIN
sys_dept ud ON ud.dept_id = uv.dept_id
LEFT JOIN LEFT JOIN
bbs_user_points p ON p.user_name = uv.user_name bbs_user_points p ON p.user_name = uv.user_name
CROSS JOIN ( CROSS JOIN (
SELECT (SELECT name FROM bbs_grade WHERE is_initial = 1 ORDER BY create_time DESC LIMIT 1) AS name SELECT (SELECT name FROM bbs_grade WHERE is_initial = 1 ORDER BY create_time DESC LIMIT 1) AS name
) ug ) ug
<where> <where>
<if test="points.nikeName != null and points.nikeName != ''"> <if test="points.keyword != null and points.keyword != ''">
uv.nike_name LIKE CONCAT('%', #{points.nikeName}, '%') uv.nick_name LIKE CONCAT('%', #{points.keyword}, '%') OR uv.user_name LIKE CONCAT('%', #{points.keyword}, '%')
</if>
<if test="points.nickName != null and points.nickName != ''">
AND uv.nick_name LIKE CONCAT('%', #{points.nickName}, '%')
</if> </if>
<if test="points.userName != null and points.userName != ''"> <if test="points.userName != null and points.userName != ''">
AND uv.user_name LIKE CONCAT('%', #{points.userName}, '%') AND uv.user_name LIKE CONCAT('%', #{points.userName}, '%')
...@@ -38,21 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -38,21 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectQwmhUser" resultType="com.tangguo.common.domain.QwmhUserInfo"> <select id="selectUserCount" resultType="java.lang.Integer">
SELECT * FROM qwmh_sys_user_view WHERE user_name = #{userName} SELECT COUNT(*) FROM sys_user WHERE user_name = #{userName}
</select>
<select id="selectUserPoints" resultType="com.tangguo.domain.BbsUserPoints">
SELECT * FROM bbs_user_points WHERE user_name = #{userName}
</select> </select>
<update id="initUserPointsGrade">
</update>
<update id="refreshUserPointsGrade"> <update id="refreshUserPointsGrade">
UPDATE UPDATE
bbs_user_points p bbs_user_points p
......
...@@ -28,10 +28,9 @@ ...@@ -28,10 +28,9 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- 通用工具-->
<dependency> <dependency>
<groupId>com.tangguo</groupId> <groupId>com.tangguo</groupId>
<artifactId>safe-campus-common</artifactId> <artifactId>safe-campus-system</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.tangguo.quartz.task;
import com.tangguo.system.mapper.SysDeptMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 增量同步企微门户部门到本地
*
* @author 谈笑
* @createTime 2025-09-08 14:54:30 星期一
*/
@Slf4j
@Component
public class SyncQwmhSysDeptToLocalTask {
@Autowired
private SysDeptMapper sysDeptMapper;
public void run() {
log.info("=> 开始增量同步企微门户部门到本地");
int records = this.sysDeptMapper.syncQwmhSysDeptToLocal();
log.info("=> 增量同步企微门户部门到本地完毕,同步记录条数:{}", records);
}
}
package com.tangguo.quartz.task;
import com.tangguo.system.mapper.SysUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 增量同步企微门户用户到本地
*
* @author 谈笑
* @createTime 2025-09-08 14:54:30 星期一
*/
@Slf4j
@Component
public class SyncQwmhSysUserToLocalTask {
@Autowired
private SysUserMapper sysDeptMapper;
public void run() {
log.info("=> 开始增量同步企微门户用户到本地");
int records = this.sysDeptMapper.syncQwmhSysUserToLocal();
log.info("=> 增量同步企微门户用户到本地完毕,同步记录条数:{}", records);
}
}
...@@ -115,4 +115,11 @@ public interface SysDeptMapper { ...@@ -115,4 +115,11 @@ public interface SysDeptMapper {
* @return 结果 * @return 结果
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
/**
* 增量同步企微门户部门到本地
*/
int syncQwmhSysDeptToLocal();
} }
...@@ -124,4 +124,11 @@ public interface SysUserMapper { ...@@ -124,4 +124,11 @@ public interface SysUserMapper {
* @return 结果 * @return 结果
*/ */
public SysUser checkEmailUnique(String email); public SysUser checkEmailUnique(String email);
/**
* 增量同步企微门户用户到本地
*/
int syncQwmhSysUserToLocal();
} }
...@@ -188,5 +188,20 @@ ...@@ -188,5 +188,20 @@
set del_flag = '2' set del_flag = '2'
where dept_id = #{deptId} where dept_id = #{deptId}
</delete> </delete>
<update id="syncQwmhSysDeptToLocal">
INSERT INTO sys_dept(dept_id, parent_id, ancestors, dept_name, order_num, create_time)
(
SELECT
q.id, q.parent_id, q.ancestors, q.dept_name, q.order_num, q.create_time
FROM
qwmh_sys_dept q
LEFT JOIN
sys_dept d ON d.dept_id = q.id
WHERE
d.dept_name IS NULL
)
</update>
</mapper> </mapper>
...@@ -264,5 +264,20 @@ ...@@ -264,5 +264,20 @@
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
<update id="syncQwmhSysUserToLocal">
INSERT INTO sys_user(dept_id, user_name, nick_name, phonenumber, email, avatar, create_time)
(
SELECT
q.dept_id, q.user_name, q.real_name, q.phonenumber, q.email, q.avatar, q.create_time
FROM
qwmh_sys_user q
LEFT JOIN
sys_user u ON u.user_name = q.user_name
WHERE
u.user_name IS NULL AND q.user_name != 'admin'
)
</update>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment