添加接口

This commit is contained in:
lu7213 committed 2026-08-12 05:20:52 -04:00
1 parent 9b78c4a8a5
commit f25ff6eb3b
5 files changed
+60 -1

No files matched your search

@@ -2,6 +2,9 @@ package com.ruoyi.system.controller;
import com.ruoyi.common.select.Ids;
import com.ruoyi.common.select.SelectItem;
import java.util.List;
import com.ruoyi.system.domain.DmGroupOperateVo;
import com.ruoyi.system.domain.DmOperateVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -115,4 +118,12 @@ public class DmPlayerTaskGroupController extends BaseController
{
return toAjax(dmPlayerTaskGroupService.deleteDmPlayerTaskGroupByIds(ids));
}
@PreAuthorize("@ss.hasPermi('system:dmtaskgroup:operate')")
@Log(title = "操作", businessType = BusinessType.INSERT)
@PostMapping("/operate")
public AjaxResult operate(@RequestBody DmGroupOperateVo vo)
{
return toAjax(dmPlayerTaskGroupService.operate(vo));
}
}
@@ -0,0 +1,12 @@
package com.ruoyi.system.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class DmGroupOperateVo implements Serializable {
private static final long serialVersionUID = 1L;
private String groupId;
private Integer operateType;
}
@@ -11,6 +11,7 @@ public class DmOperateVo implements Serializable {
private String playerId;
private String winId;
private Integer operateType;
// 控制方向
private Integer type;
private Integer x;
private Integer y;
@@ -1,6 +1,8 @@
package com.ruoyi.system.service;
import java.util.Map;
import java.util.List;
import com.ruoyi.system.domain.DmGroupOperateVo;
import com.ruoyi.system.domain.DmPlayerTaskGroup;
import com.ruoyi.system.domain.DmPlayerTaskGroupPlus;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -86,4 +88,6 @@ public interface IDmPlayerTaskGroupService extends IService<DmPlayerTaskGroupPlu
Long count(String where);
<T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass);
boolean operate(DmGroupOperateVo vo);
}
@@ -1,18 +1,24 @@
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 com.ruoyi.system.domain.DmGroupOperateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DmPlayerTaskGroupMapper;
import com.ruoyi.system.domain.DmPlayerTaskGroup;
@@ -30,11 +36,15 @@ import com.ruoyi.common.select.SelectItem;
@Service
public class DmPlayerTaskGroupServiceImpl extends ServiceImpl<DmPlayerTaskGroupMapper, DmPlayerTaskGroupPlus> implements IDmPlayerTaskGroupService
{
private HttpHelper httpHelper = new HttpHelper();
@Autowired
private DmPlayerTaskGroupMapper dmPlayerTaskGroupMapper;
@Autowired
private JdbcTemplate jdbcTemplate;
@Value("${dm.server.ip:192.168.3.103}")
private String serverIp;
@Value("${dm.server.port:8080}")
private Integer serverPort;
@Override
public List<DmPlayerTaskGroupPlus> getByIds(List<Long> ids, SFunction<DmPlayerTaskGroupPlus, ?>... columns) {
LambdaQueryWrapper<DmPlayerTaskGroupPlus> lambdaQueryWrapper = new LambdaQueryWrapper<DmPlayerTaskGroupPlus>()
@@ -132,6 +142,27 @@ public class DmPlayerTaskGroupServiceImpl extends ServiceImpl<DmPlayerTaskGroupM
List<T> tList = JSONArray.parseArray(JSONArray.toJSONString(result), tClass);
return tList;
}
@Override
public boolean operate(DmGroupOperateVo vo) {
JSONObject params = new JSONObject();
params.put("params", "{}");
try {
params.put("groupId", vo.getGroupId());
params.put("operateType", vo.getOperateType());
String result = httpHelper.getlHttpResult("http://" + this.serverIp + ":" + serverPort + "?cmd=11&params=" + URLEncoder.encode(JSONObject.toJSONString(params), "utf-8")
, "get", new HashMap<>(), new HashMap<>());
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.getString("code").equals("1")) {
return true;
}
log.debug(result);
} catch (Exception e) {
throw new RuntimeException(e);
}
return false;
}
/**
* 查询大漠任务组
*