123
This commit is contained in:
1 parent
b77f5b0701
commit
a19f0e8e46
1 file changed
+48
-50
+48
-50
@@ -1,39 +1,36 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.luqj.util.HttpHelper;
|
||||
import com.ruoyi.common.select.SelectItem;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.DmPlayerConfig;
|
||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||
import com.ruoyi.system.mapper.DmPlayerConfigMapper;
|
||||
import com.ruoyi.system.service.IDmPlayerConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
import com.luqj.util.HttpHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.DmPlayerConfigMapper;
|
||||
import com.ruoyi.system.domain.DmPlayerConfig;
|
||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||
import com.ruoyi.system.service.IDmPlayerConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import com.ruoyi.common.select.SelectItem;
|
||||
/**
|
||||
* 玩家配置Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2026-05-10
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper, DmPlayerConfigPlus> implements IDmPlayerConfigService
|
||||
{
|
||||
public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper, DmPlayerConfigPlus> implements IDmPlayerConfigService {
|
||||
@Autowired
|
||||
private DmPlayerConfigMapper dmPlayerConfigMapper;
|
||||
@Autowired
|
||||
@@ -43,27 +40,30 @@ public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper,
|
||||
private String serverIp;
|
||||
@Value("${dm.server.port:8080}")
|
||||
private Integer serverPort;
|
||||
|
||||
@Override
|
||||
public List<DmPlayerConfigPlus> getByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
.select(columns).in(DmPlayerConfigPlus::getId, ids);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectItem> select(String keyword) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
.select(DmPlayerConfigPlus::getId, DmPlayerConfigPlus::getPlayerId)
|
||||
.like(DmPlayerConfigPlus::getPlayerId, keyword);
|
||||
List<DmPlayerConfigPlus> list = this.list(lambdaQueryWrapper);
|
||||
List<SelectItem> result =new ArrayList<>();
|
||||
for (DmPlayerConfigPlus item : list){
|
||||
List<SelectItem> result = new ArrayList<>();
|
||||
for (DmPlayerConfigPlus item : list) {
|
||||
SelectItem selectItem = new SelectItem();
|
||||
selectItem.setName(item.getPlayerId()+"");
|
||||
selectItem.setName(item.getPlayerId() + "");
|
||||
selectItem.setId(item.getId());
|
||||
result.add(selectItem);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DmPlayerConfigPlus getById(Long id, SFunction<DmPlayerConfigPlus, ?>... columns) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
|
||||
@@ -102,6 +102,7 @@ public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper,
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DmPlayerConfigPlus> getByIds(List<Long> ids) {
|
||||
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>().in(DmPlayerConfigPlus::getId, ids);
|
||||
@@ -151,22 +152,22 @@ public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper,
|
||||
List<T> tList = JSONArray.parseArray(JSONArray.toJSONString(result), tClass);
|
||||
return tList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询玩家配置
|
||||
*
|
||||
*
|
||||
* @param id 玩家配置ID
|
||||
* @return 玩家配置
|
||||
*/
|
||||
@Override
|
||||
public DmPlayerConfig selectDmPlayerConfigById(Long id)
|
||||
{
|
||||
public DmPlayerConfig selectDmPlayerConfigById(Long id) {
|
||||
return dmPlayerConfigMapper.selectDmPlayerConfigById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DmPlayerConfig selectDmPlayerConfigByPlayerId(Long playerId)
|
||||
{
|
||||
DmPlayerConfig dmPlayerConfig= dmPlayerConfigMapper.selectDmPlayerConfigByPlayerId(playerId);
|
||||
if(dmPlayerConfig == null){
|
||||
public DmPlayerConfig selectDmPlayerConfigByPlayerId(Long playerId) {
|
||||
DmPlayerConfig dmPlayerConfig = dmPlayerConfigMapper.selectDmPlayerConfigByPlayerId(playerId);
|
||||
if (dmPlayerConfig == null) {
|
||||
DmPlayerConfig playerConfigPlus = new DmPlayerConfig();
|
||||
playerConfigPlus.setPlayerId(playerId);
|
||||
playerConfigPlus.setAutoAddMana(0);
|
||||
@@ -188,48 +189,47 @@ public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper,
|
||||
|
||||
/**
|
||||
* 查询玩家配置列表
|
||||
*
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 玩家配置
|
||||
*/
|
||||
@Override
|
||||
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig)
|
||||
{
|
||||
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig) {
|
||||
return dmPlayerConfigMapper.selectDmPlayerConfigList(dmPlayerConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增玩家配置
|
||||
*
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig)
|
||||
{
|
||||
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig) {
|
||||
dmPlayerConfig.setCreateTime(DateUtils.getNowDate());
|
||||
return dmPlayerConfigMapper.insertDmPlayerConfig(dmPlayerConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改玩家配置
|
||||
*
|
||||
*
|
||||
* @param dmPlayerConfig 玩家配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig)
|
||||
{
|
||||
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig) {
|
||||
dmPlayerConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
int resutl= dmPlayerConfigMapper.updateDmPlayerConfig(dmPlayerConfig);
|
||||
if(resutl > 0){
|
||||
int resutl = dmPlayerConfigMapper.updateDmPlayerConfig(dmPlayerConfig);
|
||||
if (resutl > 0) {
|
||||
try {
|
||||
String result = httpHelper.getlHttpResult("http://" + this.serverIp + ":" + serverPort + "?cmd=8¶ms=" + URLEncoder.encode(JSONObject.toJSONString(dmPlayerConfig), "utf-8")
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("dates", Base64.getEncoder().encodeToString(JSONObject.toJSONString(dmPlayerConfig).getBytes()));
|
||||
String result = httpHelper.getlHttpResult("http://" + this.serverIp + ":" + serverPort + "?cmd=8¶ms=" + URLEncoder.encode(JSONObject.toJSONString(params), "utf-8")
|
||||
, "get", new HashMap<>(), new HashMap<>());
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (jsonObject.getString("code").equals("1")) {
|
||||
log.info("配置同步成功");
|
||||
}else{
|
||||
} else {
|
||||
log.error("配置同步失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -241,25 +241,23 @@ public class DmPlayerConfigServiceImpl extends ServiceImpl<DmPlayerConfigMapper,
|
||||
|
||||
/**
|
||||
* 批量删除玩家配置
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的玩家配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDmPlayerConfigByIds(Long[] ids)
|
||||
{
|
||||
public int deleteDmPlayerConfigByIds(Long[] ids) {
|
||||
return dmPlayerConfigMapper.deleteDmPlayerConfigByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除玩家配置信息
|
||||
*
|
||||
*
|
||||
* @param id 玩家配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDmPlayerConfigById(Long id)
|
||||
{
|
||||
public int deleteDmPlayerConfigById(Long id) {
|
||||
return dmPlayerConfigMapper.deleteDmPlayerConfigById(id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user