短信服务集成
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.njcn.cssystem.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.cssystem.pojo.param.AppMsgSetParam;
|
||||
import com.njcn.cssystem.service.IAppMsgSetService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备发送短信配置表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/appMsgSet")
|
||||
@Slf4j
|
||||
@Api(tags = "短信配置")
|
||||
@AllArgsConstructor
|
||||
public class AppMsgSetController extends BaseController {
|
||||
|
||||
private final IAppMsgSetService appMsgSetService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/addUserDevices")
|
||||
@ApiOperation("新增用户设备关联")
|
||||
@ApiImplicitParam(name = "param", value = "参数{userId:用户ID, deviceIds:设备ID列表}", required = true)
|
||||
public HttpResult<Void> addUserDevices(@RequestBody @Validated AppMsgSetParam param) {
|
||||
String methodDescribe = getMethodDescribe("addUserDevices");
|
||||
LogUtil.njcnDebug(log, "{},参数:{}", methodDescribe, param);
|
||||
appMsgSetService.addUserDevices(param.getUserId(), param.getDeviceIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/deleteByUserId")
|
||||
@ApiOperation("根据用户ID删除设备关联")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true)
|
||||
public HttpResult<Void> deleteByUserId(@RequestParam @Validated String userId) {
|
||||
String methodDescribe = getMethodDescribe("deleteByUserId");
|
||||
LogUtil.njcnDebug(log, "{},用户ID:{}", methodDescribe, userId);
|
||||
appMsgSetService.deleteByUserId(userId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
|
||||
@PostMapping("/queryDeviceIdsByUserId")
|
||||
@ApiOperation("根据用户ID查询设备列表")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true)
|
||||
public HttpResult<List<String>> queryDeviceIdsByUserId(@RequestParam @Validated String userId) {
|
||||
String methodDescribe = getMethodDescribe("queryDeviceIdsByUserId");
|
||||
LogUtil.njcnDebug(log, "{},用户ID:{}", methodDescribe, userId);
|
||||
List<String> deviceIds = appMsgSetService.queryDeviceIdsByUserId(userId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deviceIds, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
|
||||
@PostMapping("/queryUserIdsByDeviceId")
|
||||
@ApiOperation("根据设备ID查询用户列表")
|
||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true)
|
||||
public HttpResult<List<String>> queryUserIdsByDeviceId(@RequestParam @Validated String deviceId) {
|
||||
String methodDescribe = getMethodDescribe("queryUserIdsByDeviceId");
|
||||
LogUtil.njcnDebug(log, "{},设备ID:{}", methodDescribe, deviceId);
|
||||
List<String> userIds = appMsgSetService.queryUserIdsByDeviceId(deviceId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userIds, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,5 +72,34 @@ public class AppVersionController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改版本信息")
|
||||
@ApiImplicitParam(name = "param", value = "app版本信息", required = true)
|
||||
public HttpResult<String> update(@RequestBody @Validated AppVersionParam param){
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
boolean result = appVersionService.update(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "修改成功", methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "修改失败", methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除版本信息")
|
||||
@ApiImplicitParam(name = "id", value = "版本ID", required = true)
|
||||
public HttpResult<String> delete(@RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
boolean result = appVersionService.delete(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "删除成功", methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "删除失败", methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.cssystem.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.cssystem.pojo.po.AppMsgSet;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备发送短信配置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-21
|
||||
*/
|
||||
public interface AppMsgSetMapper extends BaseMapper<AppMsgSet> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.cssystem.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.cssystem.pojo.po.AppMsgSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备发送短信配置表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-21
|
||||
*/
|
||||
public interface IAppMsgSetService extends IService<AppMsgSet> {
|
||||
|
||||
/**
|
||||
* 新增用户设备关联(先清空该用户的旧数据,再批量插入新数据)
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param deviceIds 设备ID列表
|
||||
*/
|
||||
void addUserDevices(String userId, List<String> deviceIds);
|
||||
|
||||
/**
|
||||
* 根据用户ID删除设备关联
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询设备列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 设备ID列表
|
||||
*/
|
||||
List<String> queryDeviceIdsByUserId(String userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备ID查询用户列表
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @return 用户ID列表
|
||||
*/
|
||||
List<String> queryUserIdsByDeviceId(String deviceId);
|
||||
|
||||
}
|
||||
@@ -22,4 +22,8 @@ public interface IAppVersionService extends IService<AppVersion> {
|
||||
AppVersionVo getLastData(String versionType);
|
||||
|
||||
List<AppVersion> getAllData(String versionType);
|
||||
|
||||
boolean update(AppVersionParam param);
|
||||
|
||||
boolean delete(String id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.njcn.cssystem.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.cssystem.mapper.AppMsgSetMapper;
|
||||
import com.njcn.cssystem.pojo.po.AppMsgSet;
|
||||
import com.njcn.cssystem.service.IAppMsgSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备发送短信配置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-21
|
||||
*/
|
||||
@Service
|
||||
public class AppMsgSetServiceImpl extends ServiceImpl<AppMsgSetMapper, AppMsgSet> implements IAppMsgSetService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addUserDevices(String userId, List<String> deviceIds) {
|
||||
// 先删除该用户的所有设备关联
|
||||
deleteByUserId(userId);
|
||||
// 如果设备列表为空,直接返回
|
||||
if (CollectionUtils.isEmpty(deviceIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 批量插入新的设备关联
|
||||
List<AppMsgSet> relationList = new ArrayList<>();
|
||||
for (String deviceId : deviceIds) {
|
||||
AppMsgSet relation = new AppMsgSet();
|
||||
relation.setId(IdUtil.fastSimpleUUID());
|
||||
relation.setUserId(userId);
|
||||
relation.setDeviceId(deviceId);
|
||||
relationList.add(relation);
|
||||
}
|
||||
this.saveBatch(relationList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserId(String userId) {
|
||||
LambdaQueryWrapper<AppMsgSet> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AppMsgSet::getUserId, userId);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryDeviceIdsByUserId(String userId) {
|
||||
LambdaQueryWrapper<AppMsgSet> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AppMsgSet::getUserId, userId);
|
||||
wrapper.select(AppMsgSet::getDeviceId);
|
||||
|
||||
List<AppMsgSet> relationList = this.list(wrapper);
|
||||
List<String> deviceIds = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(relationList)) {
|
||||
for (AppMsgSet relation : relationList) {
|
||||
deviceIds.add(relation.getDeviceId());
|
||||
}
|
||||
}
|
||||
return deviceIds;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> queryUserIdsByDeviceId(String deviceId) {
|
||||
LambdaQueryWrapper<AppMsgSet> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AppMsgSet::getDeviceId, deviceId);
|
||||
wrapper.select(AppMsgSet::getUserId);
|
||||
|
||||
List<AppMsgSet> relationList = this.list(wrapper);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(relationList)) {
|
||||
for (AppMsgSet relation : relationList) {
|
||||
userIds.add(relation.getUserId());
|
||||
}
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -34,6 +34,8 @@ public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVers
|
||||
appVersion.setSev(param.getSev());
|
||||
appVersion.setVersionType(param.getVersionType());
|
||||
appVersion.setContent(param.getContent());
|
||||
appVersion.setAndroidPath(param.getAndroidPath());
|
||||
appVersion.setIosPath(param.getIosPath());
|
||||
return this.save(appVersion);
|
||||
}
|
||||
|
||||
@@ -59,4 +61,22 @@ public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVers
|
||||
queryWrapper.orderByDesc(AppVersion::getPublishTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(AppVersionParam param) {
|
||||
AppVersion appVersion = new AppVersion();
|
||||
appVersion.setId(param.getId());
|
||||
appVersion.setVersionName(param.getAppVersion());
|
||||
appVersion.setSev(param.getSev());
|
||||
appVersion.setVersionType(param.getVersionType());
|
||||
appVersion.setContent(param.getContent());
|
||||
appVersion.setAndroidPath(param.getAndroidPath());
|
||||
appVersion.setIosPath(param.getIosPath());
|
||||
return this.updateById(appVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,18 @@ public class WlUserServiceImpl implements IWlUserService {
|
||||
} else {
|
||||
WlUserVo.EngineeringVo engineeringVo = new WlUserVo.EngineeringVo();
|
||||
engineeringVo.setId(item.getEngineeringid());
|
||||
engineeringVo.setName(item.getEngineeringName());
|
||||
engineeringVo.setName(item.getEngineeringName() + "("+item.getEquipmentName()+")");
|
||||
|
||||
List<WlUserVo.portableDevVo> devList2 = new ArrayList<>();
|
||||
String[] arr1 = item.getEquipmentId().split(",");
|
||||
String[] arr2 = item.getEquipmentName().split(",");
|
||||
for (int i = 0; i < arr1.length; i++) {
|
||||
WlUserVo.portableDevVo portableDevVo = new WlUserVo.portableDevVo();
|
||||
portableDevVo.setId(arr1[i]);
|
||||
portableDevVo.setName(arr2[i]);
|
||||
devList2.add(portableDevVo);
|
||||
}
|
||||
engineeringVo.setDevList(devList2);
|
||||
list1.add(engineeringVo);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user