工单信息修正、小程序登录修正

This commit is contained in:
2025-12-28 14:58:09 +08:00
parent 7eddf00705
commit 8448a801ce
11 changed files with 62 additions and 27 deletions

View File

@@ -12,7 +12,7 @@ INSERT INTO sys.tb_sys_user (
) VALUES
('USER-0001', 'user_admin', 'admin',
'$2a$10$XAe0TE2p0ym94bKJ8LJ52el3M4oYyiExVH/kNCh.pWLLGDZWNM9Yu', -- admin123
'admin@urbanlifeline.com', '13800138000', '7503bbfc6171077b737cdc4f76e781893a9a474c9ead05b6b946ac936e5a0288',
'admin@urbanlifeline.com', 'DAWTIvnCQI/KmtwkBYI5WP2NpnSKTq4kStJpOJKahOeJLNhAQ0s1', '7503bbfc6171077b737cdc4f76e781893a9a474c9ead05b6b946ac936e5a0288',
now(), 0, false);
-- 超级管理员用户信息
@@ -43,7 +43,7 @@ INSERT INTO sys.tb_sys_user (
) VALUES
('USER-0002', 'user_demo', 'demo',
'$2a$10$XAe0TE2p0ym94bKJ8LJ52el3M4oYyiExVH/kNCh.pWLLGDZWNM9Yu', -- admin123
'demo@urbanlifeline.com', '13800138001', '4e98ffd0e02a7f746291bff77c6c497225e8884758d503bde2efad64e45ad44b',
'demo@urbanlifeline.com', 'Y9tsAZOppzsxmKvI7iqqRBMDHzvWym2DE5FX1KgEGVBC5Ii1UG68', '4e98ffd0e02a7f746291bff77c6c497225e8884758d503bde2efad64e45ad44b',
now(), 0, false);
-- 示例用户信息

View File

@@ -224,7 +224,7 @@ public class AesEncryptUtil {
public static void main(String[] args) {
AesEncryptUtil aesEncryptUtil = new AesEncryptUtil("MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=");
String phone = "17857100375";
String phone = "17857100376";
// 测试加密(每次都不同,不能用于查询)
String encryptedPhone1 = aesEncryptUtil.encryptPhone(phone);

View File

@@ -44,8 +44,15 @@ public class FileController {
public ResultDomain<TbSysFileDTO> uploadFile(
@RequestParam("file") MultipartFile file,
@RequestParam(value = "module", required = false) String module,
@RequestParam(value = "businessId", required = false) String businessId) {
return fileService.uploadFile(file, module, businessId);
@RequestParam(value = "businessId", required = false) String businessId,
@RequestParam(value = "fileName", required = false) String fileName) {
try {
// 如果前端传递了 fileName使用它否则使用 MultipartFile 的原始文件名
String actualFileName = (fileName != null && !fileName.isEmpty()) ? fileName : file.getOriginalFilename();
return fileService.uploadFileBytes(file.getBytes(), actualFileName, file.getContentType(), module, businessId);
} catch (Exception e) {
return ResultDomain.failure("文件上传失败: " + e.getMessage());
}
}
@Operation(summary = "批量上传文件")

View File

@@ -226,9 +226,15 @@ public class SysUserServiceImpl implements SysUserService {
public ResultDomain<SysUserVO> getLoginUser(SysUserVO filter) {
// 登录查询语义与 getUser 相同(可根据用户名/手机号/邮箱/wechatId查询
if(NonUtils.isNotNull(filter.getPhone())){
// 确保 phoneHash 被正确设置
filter.setPhone(filter.getPhone());
logger.info("登录查询 - phone: {}, phoneHash: {}", filter.getPhone(), filter.getPhoneHash());
}
if(NonUtils.isNotNull(filter.getWechatId())){
logger.info("登录查询 - wechatId: {}", filter.getWechatId());
}
List<SysUserVO> list = userMapper.getUserByFilter(filter);
logger.info("登录查询结果数量: {}", list != null ? list.size() : 0);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("用户不存在");
}

View File

@@ -63,7 +63,7 @@
password,
<!-- 可空/有默认值字段:按是否有入参动态拼接 -->
<if test="email != null and email != ''">email,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="phone != null and phone != ''">phone, phone_hash,</if>
<if test="wechatId != null and wechatId != ''">wechat_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
@@ -79,7 +79,7 @@
#{password},
<!-- 可空/有默认值字段对应的值 -->
<if test="email != null and email != ''">#{email},</if>
<if test="phone != null and phone != ''">#{phone, typeHandler=org.xyzh.common.jdbc.handler.EncryptedStringTypeHandler},</if>
<if test="phone != null and phone != ''">#{phone, typeHandler=org.xyzh.common.jdbc.handler.EncryptedStringTypeHandler}, #{phoneHash},</if>
<if test="wechatId != null and wechatId != ''">#{wechatId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
@@ -93,9 +93,6 @@
<update id="updateUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
UPDATE sys.tb_sys_user
<set>
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
@@ -104,6 +101,7 @@
</if>
<if test="phone != null and phone != ''">
phone = #{phone, typeHandler=org.xyzh.common.jdbc.handler.EncryptedStringTypeHandler},
phone_hash = #{phoneHash},
</if>
<if test="wechatId != null and wechatId != ''">
wechat_id = #{wechatId},

View File

@@ -29,6 +29,7 @@ import org.xyzh.api.workcase.vo.CustomerServiceVO;
import org.xyzh.api.workcase.vo.VideoMeetingVO;
import org.xyzh.common.auth.utils.JwtTokenUtil;
import org.xyzh.common.auth.utils.LoginUtil;
import org.xyzh.common.core.domain.LoginDomain;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.utils.validation.ValidationParam;
@@ -128,8 +129,11 @@ public class WorkcaseChatContorller {
return ResultDomain.failure(vr.getAllErrors());
}
String userId = LoginUtil.getCurrentUserId();
LoginDomain loginDomain = LoginUtil.getCurrentLogin();
String userId = loginDomain.getUser().getUserId();
if("guest".equals(loginDomain.getUser().getStatus())){
pageRequest.getFilter().setGuestId(userId);
}
return chatRoomService.getChatRoomPage(pageRequest, userId);
}

View File

@@ -14,6 +14,8 @@ import org.xyzh.api.workcase.dto.TbWorkcaseDTO;
import org.xyzh.api.workcase.dto.TbWorkcaseDeviceDTO;
import org.xyzh.api.workcase.dto.TbWorkcaseProcessDTO;
import org.xyzh.api.workcase.service.WorkcaseService;
import org.xyzh.common.auth.utils.LoginUtil;
import org.xyzh.common.core.domain.LoginDomain;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.utils.validation.ValidationResult;
@@ -91,6 +93,10 @@ public class WorkcaseController {
@PreAuthorize("hasAuthority('workcase:ticket:view')")
@PostMapping("/list")
public ResultDomain<TbWorkcaseDTO> getWorkcaseList(@RequestBody TbWorkcaseDTO filter) {
LoginDomain loginDomain = LoginUtil.getCurrentLogin();
if ("guest".equals(loginDomain.getUser().getStatus())) {
filter.setUserId(loginDomain.getUser().getUserId());
}
return workcaseService.getWorkcaseList(filter);
}

View File

@@ -21,6 +21,10 @@ export const fileAPI = {
if (param.uploader) {
formData.append('uploader', param.uploader);
}
// 显式传递原始文件名,确保后端保存正确的文件名
if (param.file.name) {
formData.append('fileName', param.file.name);
}
const response = await api.upload<TbSysFileDTO>(`${this.baseUrl}/upload`, formData);
return response.data;
},

View File

@@ -9,9 +9,10 @@ export const fileAPI = {
* 上传单个文件uni-app 版本)
* @param filePath 文件临时路径
* @param param 文件上传参数
* @param originalFileName 原始文件名(可选,用于保存正确的文件名)
* @returns Promise<ResultDomain<TbSysFileDTO>>
*/
uploadFile(filePath: string, param?: FileUploadParam): Promise<ResultDomain<TbSysFileDTO>> {
uploadFile(filePath: string, param?: FileUploadParam, originalFileName?: string): Promise<ResultDomain<TbSysFileDTO>> {
return uploadFile<TbSysFileDTO>({
url: `${this.baseUrl}/upload`,
filePath: filePath,
@@ -19,7 +20,8 @@ export const fileAPI = {
formData: {
module: param?.module || '',
optsn: param?.optsn || '',
uploader: param?.uploader || ''
uploader: param?.uploader || '',
fileName: originalFileName || ''
}
})
},

View File

@@ -164,9 +164,9 @@
// 开发环境使用mock数据
if (isMockMode.value) {
userInfo.value = {
wechatId: '17857100377',
wechatId: '17857100378',
username: '访客用户',
phone: '17857100377',
phone: '17857100378',
userId: ''
}
await doIdentify()
@@ -176,12 +176,12 @@
// 切换mock用户开发调试用
function switchMockUser() {
uni.showActionSheet({
itemList: ['员工 (17857100375)', '访客 (17857100377)'],
itemList: ['员工 (17857100375)', '访客 (17857100378)'],
success: (res) => {
if (res.tapIndex === 0) {
userInfo.value = { wechatId: '17857100375', username: '员工用户', phone: '17857100375', userId: '' }
} else {
userInfo.value = { wechatId: '17857100377', username: '访客用户', phone: '17857100377', userId: '' }
userInfo.value = { wechatId: '17857100378', username: '访客用户', phone: '17857100378', userId: '' }
}
doIdentify()
}
@@ -190,6 +190,12 @@
// 调用identify接口
async function doIdentify() {
// 先清空本地存储的登录信息,确保重新识别身份
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
uni.removeStorageSync('loginDomain')
uni.removeStorageSync('wechatId')
uni.showLoading({ title: '登录中...' })
try {
const res = await guestAPI.identify({

View File

@@ -816,7 +816,7 @@ function chooseAssignFile() {
const uploadRes = await fileAPI.uploadFile(file.path, {
module: 'workcase',
optsn: workcase.workcaseId || 'temp'
})
}, file.name)
if (uploadRes.success && uploadRes.data?.fileId) {
assignForm.files.push({
name: file.name,
@@ -842,12 +842,12 @@ function chooseAssignFile() {
uni.showLoading({ title: '上传中...' })
try {
for (const filePath of imgRes.tempFilePaths) {
const fileName = filePath.split('/').pop() || '图片.jpg'
const uploadRes = await fileAPI.uploadFile(filePath, {
module: 'workcase',
optsn: workcase.workcaseId || 'temp'
})
}, fileName)
if (uploadRes.success && uploadRes.data?.fileId) {
const fileName = filePath.split('/').pop() || '图片'
assignForm.files.push({
name: fileName,
fileId: uploadRes.data.fileId
@@ -974,12 +974,13 @@ async function chooseFaultImages() {
// 上传图片到服务器
uni.showLoading({ title: '上传中...' })
try {
const uploadPromises = res.tempFilePaths.map(filePath =>
fileAPI.uploadFile(filePath, {
const uploadPromises = res.tempFilePaths.map((filePath, index) => {
const fileName = `故障图片_${Date.now()}_${index}.jpg`
return fileAPI.uploadFile(filePath, {
module: 'workcase',
optsn: workcase.workcaseId || 'temp'
})
)
}, fileName)
})
const results = await Promise.all(uploadPromises)
@@ -1022,10 +1023,11 @@ async function chooseNameplateImage() {
// 上传铭牌照片到服务器
uni.showLoading({ title: '上传中...' })
try {
const fileName = `设备铭牌_${Date.now()}.jpg`
const result = await fileAPI.uploadFile(res.tempFilePaths[0], {
module: 'workcase',
optsn: workcase.workcaseId || 'temp'
})
}, fileName)
if (result.success && result.data?.fileId) {
workcase.deviceNamePlateImg = result.data.fileId
@@ -1187,7 +1189,7 @@ async function chooseProcessFile() {
const result = await fileAPI.uploadFile(file.path, {
module: 'workcase',
optsn: workcase.workcaseId || 'temp'
})
}, file.name)
if (result.success && result.data?.fileId) {
return {
name: file.name,