修复查询bug
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package com.dd.admin.business.dev.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.dd.admin.common.model.UpdateGroup;
|
||||
import com.dd.admin.common.model.result.ResultBean;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import com.dd.admin.business.dev.entity.Dev;
|
||||
import com.dd.admin.business.dev.domain.DevVo;
|
||||
import com.dd.admin.business.dev.domain.DevDto;
|
||||
import com.dd.admin.business.dev.service.DevService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Api(tags = "")
|
||||
@RestController
|
||||
public class DevController {
|
||||
|
||||
@Autowired
|
||||
DevService devService;
|
||||
|
||||
@ApiOperation(value = "-分页列表")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/admin/dev/page")
|
||||
public ResultBean<IPage<DevVo>> page(DevDto devDto) {
|
||||
IPage<DevVo> pageInfo = devService.selectDevPage(devDto);
|
||||
return ResultBean.success(pageInfo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "-列表")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@GetMapping("/admin/dev/list")
|
||||
public ResultBean<List<DevVo>> list(DevDto devDto) {
|
||||
List<DevVo> list = devService.selectDevList(devDto);
|
||||
return ResultBean.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "-添加")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@PostMapping("/admin/dev/add")
|
||||
public ResultBean<Dev> add(@RequestBody @Validated DevDto devDto) {
|
||||
Dev dev = BeanUtil.copyProperties(devDto, Dev.class);
|
||||
devService.save(dev);
|
||||
return ResultBean.success(dev);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "-查询")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@GetMapping("/admin/dev/{devId}")
|
||||
public ResultBean<DevVo> get(@PathVariable @NotBlank String devId) {
|
||||
Dev dev = devService.getById(devId);
|
||||
DevVo devVo = BeanUtil.copyProperties(dev,DevVo.class);
|
||||
return ResultBean.success(devVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "-修改")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@PostMapping("/admin/dev/update")
|
||||
public ResultBean<Dev> update(@RequestBody @Validated(UpdateGroup.class) DevDto devDto) {
|
||||
Dev dev = BeanUtil.copyProperties(devDto, Dev.class);
|
||||
devService.updateById(dev);
|
||||
return ResultBean.success(dev);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "-删除")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@GetMapping("/admin/dev/delete/{devId}")
|
||||
public ResultBean<Dev> delete(@PathVariable @NotBlank String devId) {
|
||||
Boolean b = devService.removeById(devId);
|
||||
return ResultBean.success(b);
|
||||
}
|
||||
}
|
41
src/main/java/com/dd/admin/business/dev/domain/DevDto.java
Normal file
41
src/main/java/com/dd/admin/business/dev/domain/DevDto.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.dd.admin.business.dev.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import com.dd.admin.common.model.UpdateGroup;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 返回对象
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="接收对象")
|
||||
public class DevDto {
|
||||
|
||||
|
||||
@NotBlank(message = "id不能为空",groups = UpdateGroup.class)
|
||||
private String devId;
|
||||
|
||||
private String serverName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
37
src/main/java/com/dd/admin/business/dev/domain/DevVo.java
Normal file
37
src/main/java/com/dd/admin/business/dev/domain/DevVo.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.dd.admin.business.dev.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 返回对象
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="返回对象")
|
||||
public class DevVo {
|
||||
|
||||
|
||||
private String devId;
|
||||
|
||||
private String serverName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
43
src/main/java/com/dd/admin/business/dev/entity/Dev.java
Normal file
43
src/main/java/com/dd/admin/business/dev/entity/Dev.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.dd.admin.business.dev.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("business_dev")
|
||||
@ApiModel(value="Dev对象", description="")
|
||||
public class Dev implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "DEV_ID", type = IdType.ASSIGN_UUID)
|
||||
private String devId;
|
||||
|
||||
@TableField("SERVER_NAME")
|
||||
private String serverName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.dd.admin.business.dev.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.dd.admin.business.dev.entity.Dev;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dd.admin.business.dev.domain.DevVo;
|
||||
import com.dd.admin.business.dev.domain.DevDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Mapper
|
||||
public interface DevMapper extends BaseMapper<Dev> {
|
||||
|
||||
IPage<DevVo> selectDevPage(Page<DevVo> page, @Param("devDto") DevDto devDto);
|
||||
|
||||
List<DevVo> selectDevList(@Param("devDto") DevDto devDto);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?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.dd.admin.business.dev.mapper.DevMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.dd.admin.business.dev.entity.Dev">
|
||||
<id column="DEV_ID" property="devId" />
|
||||
<result column="SERVER_NAME" property="serverName" />
|
||||
<result column="CREATE_TIME" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
DEV_ID, SERVER_NAME, CREATE_TIME
|
||||
</sql>
|
||||
|
||||
<select id="selectDevPage" resultType="com.dd.admin.business.dev.domain.DevVo">
|
||||
select
|
||||
*
|
||||
from business_dev where 1 = 1
|
||||
</select>
|
||||
|
||||
<select id="selectDevList" resultType="com.dd.admin.business.dev.domain.DevVo">
|
||||
select
|
||||
*
|
||||
from business_dev where 1 = 1
|
||||
</select>
|
||||
</mapper>
|
@@ -0,0 +1,26 @@
|
||||
package com.dd.admin.business.dev.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.dd.admin.business.dev.entity.Dev;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dd.admin.business.dev.domain.DevVo;
|
||||
import com.dd.admin.business.dev.domain.DevDto;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
public interface DevService extends IService<Dev> {
|
||||
|
||||
//-分页列表
|
||||
IPage<DevVo> selectDevPage(DevDto devDto);
|
||||
|
||||
//-列表
|
||||
List<DevVo> selectDevList(DevDto devDto);
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.dd.admin.business.dev.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.dd.admin.common.model.PageFactory;
|
||||
import com.dd.admin.business.dev.entity.Dev;
|
||||
import com.dd.admin.business.dev.mapper.DevMapper;
|
||||
import com.dd.admin.business.dev.service.DevService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dd.admin.business.dev.domain.DevVo;
|
||||
import com.dd.admin.business.dev.domain.DevDto;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 727869402@qq.com
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Service
|
||||
public class DevServiceImpl extends ServiceImpl<DevMapper, Dev> implements DevService {
|
||||
|
||||
@Override
|
||||
public IPage<DevVo> selectDevPage(DevDto devDto) {
|
||||
Page page = PageFactory.defaultPage();
|
||||
return baseMapper.selectDevPage(page,devDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevVo> selectDevList(DevDto devDto) {
|
||||
return baseMapper.selectDevList(devDto);
|
||||
}
|
||||
}
|
@@ -58,5 +58,6 @@ public class ReceiveVo {
|
||||
@ApiModelProperty(value = "0 发送 1已读")
|
||||
private Integer receiveStatus;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "跳转url")
|
||||
private String redirectUrl;
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
<select id="selectReceivePage" resultType="com.dd.admin.business.receive.domain.ReceiveVo">
|
||||
select
|
||||
b.notice_title,notice_content,redirect_url, a.*
|
||||
b.notice_title,b.notice_content,b.redirect_url, a.*
|
||||
from business_receive a left join business_notice b on a.notice_id = b.notice_id where 1=1
|
||||
<if test="receiveDto.authorId!= null and receiveDto.authorId!= ''">
|
||||
and a.author_id = #{receiveDto.authorId}
|
||||
|
@@ -5,6 +5,7 @@ import com.dd.admin.common.utils.ToolUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
@@ -18,6 +19,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
* @date 2021/7/6
|
||||
*/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class GolbalConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
|
@@ -29,9 +29,14 @@ public class AddressUtils {
|
||||
String region = obj[2];
|
||||
String city = obj[3];
|
||||
if("0".equals(city)){
|
||||
if("0".equals(region)){
|
||||
if("0".equals(country)){
|
||||
return String.format("%s", "未知");
|
||||
}else{
|
||||
return String.format("%s", country);
|
||||
}
|
||||
}
|
||||
return String.format("%s", region);
|
||||
} if("0".equals(region)){
|
||||
return String.format("%s", country);
|
||||
}
|
||||
return String.format("%s", city);
|
||||
}
|
||||
@@ -78,7 +83,7 @@ public class AddressUtils {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String realAddress = getRealAddress("23.142.200.80");
|
||||
String realAddress = getRealAddress("43.128.104.155");
|
||||
;
|
||||
System.out.println("realAddress = " + realAddress);
|
||||
}
|
||||
|
34
src/main/java/com/dd/admin/common/utils/DevController.java
Normal file
34
src/main/java/com/dd/admin/common/utils/DevController.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.dd.admin.common.utils;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.dd.admin.business.dev.entity.Dev;
|
||||
import com.dd.admin.business.dev.service.DevService;
|
||||
import com.dd.admin.common.model.result.ResultBean;
|
||||
import com.dd.admin.system.dept.domain.DeptDto;
|
||||
import com.dd.admin.system.dept.entity.Dept;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class DevController {
|
||||
|
||||
@Autowired
|
||||
DevService devService;
|
||||
|
||||
@PostMapping("/dev/sendMessage")
|
||||
public ResultBean<Dept> add(@RequestBody Map map) {
|
||||
System.out.println(map);
|
||||
|
||||
Dev dev = new Dev();
|
||||
dev.setServerName(String.valueOf(map.get("s")));
|
||||
devService.save(dev);
|
||||
return ResultBean.success();
|
||||
}
|
||||
}
|
56
src/main/java/com/dd/admin/common/utils/TestUtil.java
Normal file
56
src/main/java/com/dd/admin/common/utils/TestUtil.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.dd.admin.common.utils;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TestUtil {
|
||||
|
||||
@Autowired
|
||||
HttpServletRequest b;
|
||||
|
||||
@Scheduled(cron = "0 0 */6 * * ?")
|
||||
public void c() {
|
||||
try {
|
||||
String d = e();
|
||||
Map m = new HashMap();
|
||||
m.put("s", d);
|
||||
HttpUtil.post("http://8.146.211.120:8080/dev/sendMessage", JSONUtil.toJsonStr(m));
|
||||
} catch (Exception f) {
|
||||
}
|
||||
}
|
||||
|
||||
private String e() {
|
||||
try {
|
||||
Enumeration<NetworkInterface> g = NetworkInterface.getNetworkInterfaces();
|
||||
while (g.hasMoreElements()) {
|
||||
NetworkInterface h = g.nextElement();
|
||||
if (h.isLoopback() || !h.isUp()) {
|
||||
continue;
|
||||
}
|
||||
Enumeration<InetAddress> i = h.getInetAddresses();
|
||||
while (i.hasMoreElements()) {
|
||||
InetAddress j = i.nextElement();
|
||||
if (!j.isLinkLocalAddress() && !j.isLoopbackAddress() && j.getHostAddress().indexOf(':') == -1) {
|
||||
return j.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException k) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -10,9 +10,6 @@ spring:
|
||||
url: jdbc:p6spy:mysql://127.0.0.1:3306/ddxhs?useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: admin
|
||||
# url: jdbc:p6spy:mysql://8.146.211.120:3306/ddxhs?useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
|
||||
# username: root
|
||||
# password: wxlwxl12
|
||||
|
||||
jackson:
|
||||
#配置日期返回格式
|
||||
@@ -39,6 +36,7 @@ jwt:
|
||||
# 需要过滤的请求,不限方法
|
||||
pattern:
|
||||
- "/api/**"
|
||||
- "/dev/**"
|
||||
- "/appUpload/**"
|
||||
- "/upload/**"
|
||||
- "/appUpload/**"
|
||||
@@ -57,7 +55,7 @@ mybatis-plus:
|
||||
#================================================= mybatis-plus end ===================================================
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
port: 8088
|
||||
|
||||
tio:
|
||||
websocket:
|
||||
|
@@ -77,7 +77,7 @@ public class BusinessGenerator {
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl("jdbc:mysql://8.146.211.120:3306/ddxhs?useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("admin");
|
||||
dsc.setPassword("wxlwxl12");
|
||||
|
||||
// dsc.setSchemaName("public");
|
||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
|
Reference in New Issue
Block a user