This commit is contained in:
lu7213 committed 2026-05-10 04:52:50 -04:00
1 parent d4b1bc60b1
commit 36e5ab3308
8 files changed
+1022 -5

No files matched your search

@@ -0,0 +1,118 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.select.Ids;
import com.ruoyi.common.select.SelectItem;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DmPlayerConfig;
import com.ruoyi.system.domain.DmPlayerConfigPlus;
import com.ruoyi.system.service.IDmPlayerConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 玩家配置Controller
*
* @author luqj
* @date 2026-05-10
*/
@RestController
@RequestMapping("/system/dmplayerconfig")
public class DmPlayerConfigController extends BaseController
{
@Autowired
private IDmPlayerConfigService dmPlayerConfigService;
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:getByIds')")
@PostMapping("/getByIds")
public AjaxResult getByIds(@RequestBody Ids ids)
{
List<DmPlayerConfigPlus> list = dmPlayerConfigService.getByIds(ids.getLongIds(),DmPlayerConfigPlus::getPlayerId,DmPlayerConfigPlus::getId);
return AjaxResult.success(list);
}
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:select')")
@GetMapping("/select")
public AjaxResult select(String keyword)
{
List<SelectItem> list = dmPlayerConfigService.select(keyword);
return AjaxResult.success(list);
}
/**
* 查询玩家配置列表
*/
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:list')")
@GetMapping("/list")
public TableDataInfo list(DmPlayerConfig dmPlayerConfig)
{
startPage();
List<DmPlayerConfig> list = dmPlayerConfigService.selectDmPlayerConfigList(dmPlayerConfig);
return getDataTable(list);
}
/**
* 导出玩家配置列表
*/
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:export')")
@Log(title = "玩家配置", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(DmPlayerConfig dmPlayerConfig)
{
List<DmPlayerConfig> list = dmPlayerConfigService.selectDmPlayerConfigList(dmPlayerConfig);
ExcelUtil<DmPlayerConfig> util = new ExcelUtil<DmPlayerConfig>(DmPlayerConfig.class);
return util.exportExcel(list, "dmplayerconfig");
}
/**
* 获取玩家配置详细信息
*/
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(dmPlayerConfigService.selectDmPlayerConfigById(id));
}
/**
* 新增玩家配置
*/
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:add')")
@Log(title = "玩家配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DmPlayerConfig dmPlayerConfig)
{
return toAjax(dmPlayerConfigService.insertDmPlayerConfig(dmPlayerConfig));
}
/**
* 修改玩家配置
*/
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:edit')")
@Log(title = "玩家配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DmPlayerConfig dmPlayerConfig)
{
return toAjax(dmPlayerConfigService.updateDmPlayerConfig(dmPlayerConfig));
}
/**
* 删除玩家配置
*/
@PreAuthorize("@ss.hasPermi('system:dmplayerconfig:remove')")
@Log(title = "玩家配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(dmPlayerConfigService.deleteDmPlayerConfigByIds(ids));
}
}
@@ -0,0 +1,165 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.io.Serializable;
/**
* 玩家配置对象 dm_player_config
*
* @author luqj
* @date 2026-05-10
*/
public class DmPlayerConfig extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 玩家ID */
@Excel(name = "玩家ID")
private Long playerId;
/** 喊话间隔 */
@Excel(name = "喊话间隔")
private Integer shoutInterval;
/** 喊话蓝量 */
@Excel(name = "喊话蓝量")
private Integer shoutMana;
/** 是否自动加蓝 */
@Excel(name = "是否自动加蓝")
private Integer autoAddMana;
/** 加蓝阈值 */
@Excel(name = "加蓝阈值")
private Integer addManaThreshold;
/** 识别高度 */
@Excel(name = "识别高度")
private Integer yoloHeight;
/** 识别宽度 */
@Excel(name = "识别宽度")
private Integer yoloWidth;
/** 自定义参数 */
@Excel(name = "自定义参数")
private String customParams;
/** 固定方位 */
@Excel(name = "固定方位")
private Integer fixedDirection;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setPlayerId(Long playerId)
{
this.playerId = playerId;
}
public Long getPlayerId()
{
return playerId;
}
public void setShoutInterval(Integer shoutInterval)
{
this.shoutInterval = shoutInterval;
}
public Integer getShoutInterval()
{
return shoutInterval;
}
public void setShoutMana(Integer shoutMana)
{
this.shoutMana = shoutMana;
}
public Integer getShoutMana()
{
return shoutMana;
}
public void setAutoAddMana(Integer autoAddMana)
{
this.autoAddMana = autoAddMana;
}
public Integer getAutoAddMana()
{
return autoAddMana;
}
public void setAddManaThreshold(Integer addManaThreshold)
{
this.addManaThreshold = addManaThreshold;
}
public Integer getAddManaThreshold()
{
return addManaThreshold;
}
public void setYoloHeight(Integer yoloHeight)
{
this.yoloHeight = yoloHeight;
}
public Integer getYoloHeight()
{
return yoloHeight;
}
public void setYoloWidth(Integer yoloWidth)
{
this.yoloWidth = yoloWidth;
}
public Integer getYoloWidth()
{
return yoloWidth;
}
public void setCustomParams(String customParams)
{
this.customParams = customParams;
}
public String getCustomParams()
{
return customParams;
}
public void setFixedDirection(Integer fixedDirection)
{
this.fixedDirection = fixedDirection;
}
public Integer getFixedDirection()
{
return fixedDirection;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("playerId", getPlayerId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("shoutInterval", getShoutInterval())
.append("shoutMana", getShoutMana())
.append("autoAddMana", getAutoAddMana())
.append("addManaThreshold", getAddManaThreshold())
.append("yoloHeight", getYoloHeight())
.append("yoloWidth", getYoloWidth())
.append("customParams", getCustomParams())
.append("fixedDirection", getFixedDirection())
.toString();
}
}
@@ -0,0 +1,203 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* 玩家配置对象 dm_player_config
*
* @author luqj
* @date 2026-05-10
*/
@TableName(value = "dm_player_config")
public class DmPlayerConfigPlus implements Serializable
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 玩家ID */
@Excel(name = "玩家ID")
private Long playerId;
/** 创建时间 */
private Date createTime;
/** 更新时间 */
private Date updateTime;
/** 喊话间隔 */
@Excel(name = "喊话间隔")
private Integer shoutInterval;
/** 喊话蓝量 */
@Excel(name = "喊话蓝量")
private Integer shoutMana;
/** 是否自动加蓝 */
@Excel(name = "是否自动加蓝")
private Integer autoAddMana;
/** 加蓝阈值 */
@Excel(name = "加蓝阈值")
private Integer addManaThreshold;
/** 识别高度 */
@Excel(name = "识别高度")
private Integer yoloHeight;
/** 识别宽度 */
@Excel(name = "识别宽度")
private Integer yoloWidth;
/** 自定义参数 */
@Excel(name = "自定义参数")
private String customParams;
/** 固定方位
* <el-option label="所有" :value="0" />
* <el-option label="斜四个方位" :value="9" />
* <el-option label="除了上" :value="10" />
* <el-option label="上" :value="1" />
* <el-option label="下" :value="2" />
* <el-option label="左" :value="3" />
* <el-option label="右" :value="4" />
* <el-option label="左上" :value="5" />
* <el-option label="右上" :value="6" />
* <el-option label="左下" :value="7" />
* <el-option label="右下" :value="8" />
* */
@Excel(name = "固定方位")
private Integer fixedDirection;
@Excel(name = "喊话编码 对应按键值表")
private Integer shoutKey;
public Integer getShoutKey() {
return shoutKey;
}
public void setShoutKey(Integer shoutKey) {
this.shoutKey = shoutKey;
}
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setPlayerId(Long playerId)
{
this.playerId = playerId;
}
public Long getPlayerId()
{
return playerId;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
public Date getCreateTime()
{
return createTime;
}
public void setUpdateTime(Date updateTime)
{
this.updateTime = updateTime;
}
public Date getUpdateTime()
{
return updateTime;
}
public void setShoutInterval(Integer shoutInterval)
{
this.shoutInterval = shoutInterval;
}
public Integer getShoutInterval()
{
return shoutInterval;
}
public void setShoutMana(Integer shoutMana)
{
this.shoutMana = shoutMana;
}
public Integer getShoutMana()
{
return shoutMana;
}
public void setAutoAddMana(Integer autoAddMana)
{
this.autoAddMana = autoAddMana;
}
public Integer getAutoAddMana()
{
return autoAddMana;
}
public void setAddManaThreshold(Integer addManaThreshold)
{
this.addManaThreshold = addManaThreshold;
}
public Integer getAddManaThreshold()
{
return addManaThreshold;
}
public void setYoloHeight(Integer yoloHeight)
{
this.yoloHeight = yoloHeight;
}
public Integer getYoloHeight()
{
return yoloHeight;
}
public void setYoloWidth(Integer yoloWidth)
{
this.yoloWidth = yoloWidth;
}
public Integer getYoloWidth()
{
return yoloWidth;
}
public void setCustomParams(String customParams)
{
this.customParams = customParams;
}
public String getCustomParams()
{
return customParams;
}
public void setFixedDirection(Integer fixedDirection)
{
this.fixedDirection = fixedDirection;
}
public Integer getFixedDirection()
{
return fixedDirection;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("playerId", getPlayerId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("shoutInterval", getShoutInterval())
.append("shoutMana", getShoutMana())
.append("autoAddMana", getAutoAddMana())
.append("addManaThreshold", getAddManaThreshold())
.append("yoloHeight", getYoloHeight())
.append("yoloWidth", getYoloWidth())
.append("customParams", getCustomParams())
.append("fixedDirection", getFixedDirection())
.toString();
}
}
@@ -0,0 +1,65 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.system.domain.DmPlayerConfig;
import com.ruoyi.system.domain.DmPlayerConfigPlus;
/**
* 玩家配置Mapper接口
*
* @author luqj
* @date 2026-05-10
*/
public interface DmPlayerConfigMapper extends BaseMapper<DmPlayerConfigPlus>
{
/**
* 查询玩家配置
*
* @param id 玩家配置ID
* @return 玩家配置
*/
public DmPlayerConfig selectDmPlayerConfigById(Long id);
/**
* 查询玩家配置列表
*
* @param dmPlayerConfig 玩家配置
* @return 玩家配置集合
*/
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig);
/**
* 新增玩家配置
*
* @param dmPlayerConfig 玩家配置
* @return 结果
*/
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig);
/**
* 修改玩家配置
*
* @param dmPlayerConfig 玩家配置
* @return 结果
*/
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig);
/**
* 删除玩家配置
*
* @param id 玩家配置ID
* @return 结果
*/
public int deleteDmPlayerConfigById(Long id);
/**
* 批量删除玩家配置
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteDmPlayerConfigByIds(Long[] ids);
}
@@ -0,0 +1,91 @@
package com.ruoyi.system.service;
import java.util.Map;
import java.util.List;
import com.ruoyi.system.domain.DmPlayerConfig;
import com.ruoyi.system.domain.DmPlayerConfigPlus;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.ruoyi.common.select.SelectItem;
/**
* 玩家配置Service接口
*
* @author luqj
* @date 2026-05-10
*/
public interface IDmPlayerConfigService extends IService<DmPlayerConfigPlus>
{
List<SelectItem> select(String keyword);
/**
* 查询玩家配置
*
* @param id 玩家配置ID
* @return 玩家配置
*/
public DmPlayerConfig selectDmPlayerConfigById(Long id);
/**
* 查询玩家配置列表
*
* @param dmPlayerConfig 玩家配置
* @return 玩家配置集合
*/
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig);
/**
* 新增玩家配置
*
* @param dmPlayerConfig 玩家配置
* @return 结果
*/
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig);
/**
* 修改玩家配置
*
* @param dmPlayerConfig 玩家配置
* @return 结果
*/
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig);
/**
* 批量删除玩家配置
*
* @param ids 需要删除的玩家配置ID
* @return 结果
*/
public int deleteDmPlayerConfigByIds(Long[] ids);
/**
* 删除玩家配置信息
*
* @param id 玩家配置ID
* @return 结果
*/
public int deleteDmPlayerConfigById(Long id);
List<DmPlayerConfigPlus> getByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns);
DmPlayerConfigPlus getById(Long id, SFunction<DmPlayerConfigPlus, ?>... columns);
Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns);
List<DmPlayerConfigPlus> getByIds(List<Long> ids);
Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids);
Map<Long, DmPlayerConfigPlus> getMapByPlayerIds(List<Long> ids);
/**
* @param field sum 字段
* @param where 条件
* @param tClass 返回类型
* @param <T>
* @return
*/
<T> T sum(String field, String where, Class<T> tClass);
Long count(String where);
<T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass);
}
@@ -0,0 +1,245 @@
package com.ruoyi.system.service.impl;
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 java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import com.luqj.util.HttpHelper;
import com.ruoyi.common.utils.StringUtils;
import com.alibaba.fastjson.JSONArray;
import java.util.List;
import java.util.Map;
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
{
@Autowired
private DmPlayerConfigMapper dmPlayerConfigMapper;
@Autowired
private JdbcTemplate jdbcTemplate;
private HttpHelper httpHelper = new HttpHelper();
@Value("${dm.server.ip:192.168.3.103}")
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){
SelectItem selectItem = new SelectItem();
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>()
.select(columns).eq(DmPlayerConfigPlus::getId, id);
return baseMapper.selectOne(lambdaQueryWrapper);
}
@Override
public Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids, SFunction<DmPlayerConfigPlus, ?>... columns) {
List<DmPlayerConfigPlus> list = this.getByIds(ids, columns);
Map<Long, DmPlayerConfigPlus> map = new HashMap<>();
for (DmPlayerConfigPlus item : list) {
map.put(item.getId(), item);
}
return map;
}
@Override
public Map<Long, DmPlayerConfigPlus> getMapByIds(List<Long> ids) {
List<DmPlayerConfigPlus> list = this.getByIds(ids);
Map<Long, DmPlayerConfigPlus> map = new HashMap<>();
for (DmPlayerConfigPlus item : list) {
map.put(item.getId(), item);
}
return map;
}
@Override
public Map<Long, DmPlayerConfigPlus> getMapByPlayerIds(List<Long> ids) {
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>()
.in(DmPlayerConfigPlus::getPlayerId, ids);
List<DmPlayerConfigPlus> list = this.list(lambdaQueryWrapper);
Map<Long, DmPlayerConfigPlus> map = new HashMap<>();
for (DmPlayerConfigPlus item : list) {
map.put(item.getId(), item);
}
return map;
}
@Override
public List<DmPlayerConfigPlus> getByIds(List<Long> ids) {
LambdaQueryWrapper<DmPlayerConfigPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerConfigPlus>().in(DmPlayerConfigPlus::getId, ids);
return this.list(lambdaQueryWrapper);
}
public <T> T sum(String field, String where, Class<T> tClass) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select ");
stringBuffer.append(" sum(" + field + ") as total ");
stringBuffer.append(" from dm_player_config ");
if (StringUtils.isNotBlank(where)) {
stringBuffer.append(" where ");
stringBuffer.append(where);
}
T result = jdbcTemplate.queryForObject(stringBuffer.toString(), tClass);
return result;
}
public Long count(String where) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select ");
stringBuffer.append(" count(1)");
stringBuffer.append(" from ");
stringBuffer.append(" dm_player_config ");
if (StringUtils.isNotBlank(where)) {
stringBuffer.append(" where ");
stringBuffer.append(where);
}
Long result = jdbcTemplate.queryForObject(stringBuffer.toString(), Long.class);
return result;
}
public <T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select ");
stringBuffer.append(select);
stringBuffer.append(" from ");
stringBuffer.append(" dm_player_config ");
if (StringUtils.isNotBlank(where)) {
stringBuffer.append(" where ");
stringBuffer.append(where);
}
stringBuffer.append(" group by ");
stringBuffer.append(groupby);
List result = jdbcTemplate.queryForList(stringBuffer.toString());
List<T> tList = JSONArray.parseArray(JSONArray.toJSONString(result), tClass);
return tList;
}
/**
* 查询玩家配置
*
* @param id 玩家配置ID
* @return 玩家配置
*/
@Override
public DmPlayerConfig selectDmPlayerConfigById(Long id)
{
return dmPlayerConfigMapper.selectDmPlayerConfigById(id);
}
/**
* 查询玩家配置列表
*
* @param dmPlayerConfig 玩家配置
* @return 玩家配置
*/
@Override
public List<DmPlayerConfig> selectDmPlayerConfigList(DmPlayerConfig dmPlayerConfig)
{
return dmPlayerConfigMapper.selectDmPlayerConfigList(dmPlayerConfig);
}
/**
* 新增玩家配置
*
* @param dmPlayerConfig 玩家配置
* @return 结果
*/
@Override
public int insertDmPlayerConfig(DmPlayerConfig dmPlayerConfig)
{
dmPlayerConfig.setCreateTime(DateUtils.getNowDate());
return dmPlayerConfigMapper.insertDmPlayerConfig(dmPlayerConfig);
}
/**
* 修改玩家配置
*
* @param dmPlayerConfig 玩家配置
* @return 结果
*/
@Override
public int updateDmPlayerConfig(DmPlayerConfig dmPlayerConfig)
{
dmPlayerConfig.setUpdateTime(DateUtils.getNowDate());
int resutl= dmPlayerConfigMapper.updateDmPlayerConfig(dmPlayerConfig);
if(resutl > 0){
try {
String result = httpHelper.getlHttpResult("http://" + this.serverIp + ":" + serverPort + "?cmd=8&params=" + URLEncoder.encode(JSONObject.toJSONString(dmPlayerConfig), "utf-8")
, "get", new HashMap<>(), new HashMap<>());
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.getString("code").equals("1")) {
log.info("配置同步成功");
}else{
log.error("配置同步失败");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return resutl;
}
/**
* 批量删除玩家配置
*
* @param ids 需要删除的玩家配置ID
* @return 结果
*/
@Override
public int deleteDmPlayerConfigByIds(Long[] ids)
{
return dmPlayerConfigMapper.deleteDmPlayerConfigByIds(ids);
}
/**
* 删除玩家配置信息
*
* @param id 玩家配置ID
* @return 结果
*/
@Override
public int deleteDmPlayerConfigById(Long id)
{
return dmPlayerConfigMapper.deleteDmPlayerConfigById(id);
}
}
@@ -10,20 +10,20 @@ import com.ruoyi.common.select.SelectItem;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.DmOperateVo; import com.ruoyi.system.domain.DmOperateVo;
import com.ruoyi.system.domain.DmPlayerConfigPlus;
import com.ruoyi.system.domain.DmPlayerent; import com.ruoyi.system.domain.DmPlayerent;
import com.ruoyi.system.domain.DmPlayerentPlus; import com.ruoyi.system.domain.DmPlayerentPlus;
import com.ruoyi.system.mapper.DmPlayerentMapper; import com.ruoyi.system.mapper.DmPlayerentMapper;
import com.ruoyi.system.service.IDmPlayerConfigService;
import com.ruoyi.system.service.IDmPlayerentService; import com.ruoyi.system.service.IDmPlayerentService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 大漠代理Service业务层处理 * 大漠代理Service业务层处理
@@ -36,6 +36,9 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
private HttpHelper httpHelper = new HttpHelper(); private HttpHelper httpHelper = new HttpHelper();
@Autowired @Autowired
private DmPlayerentMapper dmPlayerentMapper; private DmPlayerentMapper dmPlayerentMapper;
@Lazy
@Autowired
private IDmPlayerConfigService playerConfigService;
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Value("${dm.server.ip:192.168.3.103}") @Value("${dm.server.ip:192.168.3.103}")
@@ -162,7 +165,37 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
*/ */
@Override @Override
public List<DmPlayerent> selectDmPlayerentList(DmPlayerent dmPlayerent) { public List<DmPlayerent> selectDmPlayerentList(DmPlayerent dmPlayerent) {
return dmPlayerentMapper.selectDmPlayerentList(dmPlayerent); List<DmPlayerent> list = dmPlayerentMapper.selectDmPlayerentList(dmPlayerent);
List<Long> ids = new ArrayList<>();
for (DmPlayerent playerent : list) {
ids.add(playerent.getId());
}
if (!ids.isEmpty()) {
Map<Long, DmPlayerConfigPlus> map = playerConfigService.getMapByPlayerIds(ids);
List<DmPlayerConfigPlus> saveList = new ArrayList<>();
for (DmPlayerent playerent : list) {
if (!map.containsKey(playerent.getId())) {
DmPlayerConfigPlus playerConfigPlus = new DmPlayerConfigPlus();
playerConfigPlus.setPlayerId(playerent.getId());
playerConfigPlus.setAutoAddMana(0);
playerConfigPlus.setAddManaThreshold(10);
playerConfigPlus.setCreateTime(new Date());
playerConfigPlus.setYoloHeight(160);
playerConfigPlus.setYoloWidth(100);
playerConfigPlus.setCustomParams("");
playerConfigPlus.setUpdateTime(new Date());
playerConfigPlus.setFixedDirection(0);
playerConfigPlus.setShoutInterval(12000);
playerConfigPlus.setShoutMana(55);
playerConfigPlus.setShoutKey(69);
saveList.add(playerConfigPlus);
}
}
if (!saveList.isEmpty()) {
this.playerConfigService.saveBatch(saveList);
}
}
return list;
} }
/** /**
@@ -0,0 +1,97 @@
<?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.ruoyi.system.mapper.DmPlayerConfigMapper">
<resultMap type="DmPlayerConfig" id="DmPlayerConfigResult">
<result property="id" column="id" />
<result property="playerId" column="player_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="shoutInterval" column="shout_interval" />
<result property="shoutMana" column="shout_mana" />
<result property="autoAddMana" column="auto_add_mana" />
<result property="addManaThreshold" column="add_mana_threshold" />
<result property="yoloHeight" column="yolo_height" />
<result property="yoloWidth" column="yolo_width" />
<result property="customParams" column="custom_params" />
<result property="fixedDirection" column="fixed_direction" />
</resultMap>
<sql id="selectDmPlayerConfigVo">
select id, player_id, create_time, update_time, shout_interval, shout_mana, auto_add_mana, add_mana_threshold, yolo_height, yolo_width, custom_params, fixed_direction from dm_player_config
</sql>
<select id="selectDmPlayerConfigList" parameterType="DmPlayerConfig" resultMap="DmPlayerConfigResult">
<include refid="selectDmPlayerConfigVo"/>
<where>
<if test="playerId != null "> and player_id = #{playerId}</if>
<if test="fixedDirection != null "> and fixed_direction = #{fixedDirection}</if>
</where>
</select>
<select id="selectDmPlayerConfigById" parameterType="Long" resultMap="DmPlayerConfigResult">
<include refid="selectDmPlayerConfigVo"/>
where id = #{id}
</select>
<insert id="insertDmPlayerConfig" parameterType="DmPlayerConfig" useGeneratedKeys="true" keyProperty="id">
insert into dm_player_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="playerId != null">player_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="shoutInterval != null">shout_interval,</if>
<if test="shoutMana != null">shout_mana,</if>
<if test="autoAddMana != null">auto_add_mana,</if>
<if test="addManaThreshold != null">add_mana_threshold,</if>
<if test="yoloHeight != null">yolo_height,</if>
<if test="yoloWidth != null">yolo_width,</if>
<if test="customParams != null">custom_params,</if>
<if test="fixedDirection != null">fixed_direction,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="playerId != null">#{playerId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="shoutInterval != null">#{shoutInterval},</if>
<if test="shoutMana != null">#{shoutMana},</if>
<if test="autoAddMana != null">#{autoAddMana},</if>
<if test="addManaThreshold != null">#{addManaThreshold},</if>
<if test="yoloHeight != null">#{yoloHeight},</if>
<if test="yoloWidth != null">#{yoloWidth},</if>
<if test="customParams != null">#{customParams},</if>
<if test="fixedDirection != null">#{fixedDirection},</if>
</trim>
</insert>
<update id="updateDmPlayerConfig" parameterType="DmPlayerConfig">
update dm_player_config
<trim prefix="SET" suffixOverrides=",">
<if test="playerId != null">player_id = #{playerId},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="shoutInterval != null">shout_interval = #{shoutInterval},</if>
<if test="shoutMana != null">shout_mana = #{shoutMana},</if>
<if test="autoAddMana != null">auto_add_mana = #{autoAddMana},</if>
<if test="addManaThreshold != null">add_mana_threshold = #{addManaThreshold},</if>
<if test="yoloHeight != null">yolo_height = #{yoloHeight},</if>
<if test="yoloWidth != null">yolo_width = #{yoloWidth},</if>
<if test="customParams != null">custom_params = #{customParams},</if>
<if test="fixedDirection != null">fixed_direction = #{fixedDirection},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDmPlayerConfigById" parameterType="Long">
delete from dm_player_config where id = #{id}
</delete>
<delete id="deleteDmPlayerConfigByIds" parameterType="String">
delete from dm_player_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>