diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/DmPlayerConfigController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/DmPlayerConfigController.java new file mode 100644 index 0000000..dd12723 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/DmPlayerConfigController.java @@ -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 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 list = dmPlayerConfigService.select(keyword); + return AjaxResult.success(list); + } + /** + * 查询玩家配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:dmplayerconfig:list')") + @GetMapping("/list") + public TableDataInfo list(DmPlayerConfig dmPlayerConfig) + { + startPage(); + List 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 list = dmPlayerConfigService.selectDmPlayerConfigList(dmPlayerConfig); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/DmPlayerConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/DmPlayerConfig.java new file mode 100644 index 0000000..465402d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/DmPlayerConfig.java @@ -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(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/DmPlayerConfigPlus.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/DmPlayerConfigPlus.java new file mode 100644 index 0000000..511e943 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/DmPlayerConfigPlus.java @@ -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; + /** 固定方位 + * + * + * + * + * + * + * + * + * + * + * + * */ + @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(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DmPlayerConfigMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DmPlayerConfigMapper.java new file mode 100644 index 0000000..1c7a49e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DmPlayerConfigMapper.java @@ -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 +{ + /** + * 查询玩家配置 + * + * @param id 玩家配置ID + * @return 玩家配置 + */ + public DmPlayerConfig selectDmPlayerConfigById(Long id); + + /** + * 查询玩家配置列表 + * + * @param dmPlayerConfig 玩家配置 + * @return 玩家配置集合 + */ + public List 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IDmPlayerConfigService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDmPlayerConfigService.java new file mode 100644 index 0000000..9f66abb --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDmPlayerConfigService.java @@ -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 +{ + + List select(String keyword); + /** + * 查询玩家配置 + * + * @param id 玩家配置ID + * @return 玩家配置 + */ + public DmPlayerConfig selectDmPlayerConfigById(Long id); + + /** + * 查询玩家配置列表 + * + * @param dmPlayerConfig 玩家配置 + * @return 玩家配置集合 + */ + public List 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 getByIds(List ids, SFunction... columns); + + DmPlayerConfigPlus getById(Long id, SFunction... columns); + + Map getMapByIds(List ids, SFunction... columns); + + List getByIds(List ids); + + Map getMapByIds(List ids); + + + Map getMapByPlayerIds(List ids); + /** + * @param field sum 字段 + * @param where 条件 + * @param tClass 返回类型 + * @param + * @return + */ + T sum(String field, String where, Class tClass); + + Long count(String where); + + List countByGroupBy(String select, String where, String groupby, Class tClass); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerConfigServiceImpl.java new file mode 100644 index 0000000..811bf18 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerConfigServiceImpl.java @@ -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 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 getByIds(List ids, SFunction... columns) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper() + .select(columns).in(DmPlayerConfigPlus::getId, ids); + return this.list(lambdaQueryWrapper); + } + @Override + public List select(String keyword) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper() + .select(DmPlayerConfigPlus::getId, DmPlayerConfigPlus::getPlayerId) + .like(DmPlayerConfigPlus::getPlayerId, keyword); + List list = this.list(lambdaQueryWrapper); + List 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... columns) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper() + .select(columns).eq(DmPlayerConfigPlus::getId, id); + return baseMapper.selectOne(lambdaQueryWrapper); + } + + @Override + public Map getMapByIds(List ids, SFunction... columns) { + List list = this.getByIds(ids, columns); + Map map = new HashMap<>(); + for (DmPlayerConfigPlus item : list) { + map.put(item.getId(), item); + } + return map; + } + + @Override + public Map getMapByIds(List ids) { + List list = this.getByIds(ids); + Map map = new HashMap<>(); + for (DmPlayerConfigPlus item : list) { + map.put(item.getId(), item); + } + return map; + } + + @Override + public Map getMapByPlayerIds(List ids) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper() + .in(DmPlayerConfigPlus::getPlayerId, ids); + List list = this.list(lambdaQueryWrapper); + Map map = new HashMap<>(); + for (DmPlayerConfigPlus item : list) { + map.put(item.getId(), item); + } + return map; + } + @Override + public List getByIds(List ids) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper().in(DmPlayerConfigPlus::getId, ids); + return this.list(lambdaQueryWrapper); + } + + public T sum(String field, String where, Class 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 List countByGroupBy(String select, String where, String groupby, Class 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 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 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¶ms=" + 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); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerentServiceImpl.java index edc8f64..c2d9a3c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerentServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DmPlayerentServiceImpl.java @@ -10,20 +10,20 @@ import com.ruoyi.common.select.SelectItem; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.DmOperateVo; +import com.ruoyi.system.domain.DmPlayerConfigPlus; import com.ruoyi.system.domain.DmPlayerent; import com.ruoyi.system.domain.DmPlayerentPlus; import com.ruoyi.system.mapper.DmPlayerentMapper; +import com.ruoyi.system.service.IDmPlayerConfigService; import com.ruoyi.system.service.IDmPlayerentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 大漠代理Service业务层处理 @@ -36,6 +36,9 @@ public class DmPlayerentServiceImpl extends ServiceImpl selectDmPlayerentList(DmPlayerent dmPlayerent) { - return dmPlayerentMapper.selectDmPlayerentList(dmPlayerent); + List list = dmPlayerentMapper.selectDmPlayerentList(dmPlayerent); + List ids = new ArrayList<>(); + for (DmPlayerent playerent : list) { + ids.add(playerent.getId()); + } + if (!ids.isEmpty()) { + Map map = playerConfigService.getMapByPlayerIds(ids); + List 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; } /** @@ -180,10 +213,10 @@ public class DmPlayerentServiceImpl extends ServiceImpl + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into dm_player_config + + player_id, + create_time, + update_time, + shout_interval, + shout_mana, + auto_add_mana, + add_mana_threshold, + yolo_height, + yolo_width, + custom_params, + fixed_direction, + + + #{playerId}, + #{createTime}, + #{updateTime}, + #{shoutInterval}, + #{shoutMana}, + #{autoAddMana}, + #{addManaThreshold}, + #{yoloHeight}, + #{yoloWidth}, + #{customParams}, + #{fixedDirection}, + + + + + update dm_player_config + + player_id = #{playerId}, + create_time = #{createTime}, + update_time = #{updateTime}, + shout_interval = #{shoutInterval}, + shout_mana = #{shoutMana}, + auto_add_mana = #{autoAddMana}, + add_mana_threshold = #{addManaThreshold}, + yolo_height = #{yoloHeight}, + yolo_width = #{yoloWidth}, + custom_params = #{customParams}, + fixed_direction = #{fixedDirection}, + + where id = #{id} + + + + delete from dm_player_config where id = #{id} + + + + delete from dm_player_config where id in + + #{id} + + + \ No newline at end of file