parent
619a142941
commit
9f1ac0a5dc
|
@ -52,6 +52,11 @@
|
|||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.common.core.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 多数据源对象 entinfo
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-06-06
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("entinfo")
|
||||
public class Entinfo extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 数据源key */
|
||||
@Excel(name = "数据源key")
|
||||
private String entCode;
|
||||
|
||||
/** 数据源ip */
|
||||
@Excel(name = "数据源ip")
|
||||
private String ip;
|
||||
|
||||
/** 数据源端口 */
|
||||
@Excel(name = "数据源端口")
|
||||
private Integer port;
|
||||
|
||||
/** 数据源ID */
|
||||
private Long id;
|
||||
|
||||
|
||||
}
|
|
@ -1,15 +1,19 @@
|
|||
package com.muyu.common.system.remote;
|
||||
|
||||
import com.muyu.common.core.domain.Entinfo;
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.SysFile;
|
||||
import com.muyu.common.system.remote.factory.RemoteFileFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务
|
||||
*
|
||||
|
@ -26,4 +30,11 @@ public interface RemoteFileService {
|
|||
*/
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file);
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id);
|
||||
@GetMapping("ListAll")
|
||||
public List<Entinfo> listAll();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Entinfo;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.remote.RemoteFileService;
|
||||
import com.muyu.common.system.domain.SysFile;
|
||||
|
@ -9,6 +9,8 @@ import org.springframework.cloud.openfeign.FallbackFactory;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务降级处理
|
||||
*
|
||||
|
@ -26,6 +28,16 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||
public Result<SysFile> upload (MultipartFile file) {
|
||||
return Result.error("上传文件失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getInfo(Long id) {
|
||||
return Result.error("获取失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entinfo> listAll() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,19 @@
|
|||
</properties>
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join</artifactId>
|
||||
<version>1.2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--rabbitMQ-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.muyu.business;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* qidong XiaoHuangBusinessApplication
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.muyu.business.config;
|
||||
|
||||
|
||||
import ch.qos.logback.classic.pattern.MessageConverter;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
@ -10,8 +11,6 @@ public class RabbitmqConfig {
|
|||
// 消息转换配置
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter() {
|
||||
|
||||
// return new Jackson2JsonMessageConverter();
|
||||
return null;
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* Cart
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/10
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("cart")
|
||||
public class Cart {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
|
||||
@TableField(value = "type_id")
|
||||
private Long typeId;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* CartVo
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/10
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class CartVo {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private String typeName;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/10
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("type")
|
||||
public class Type {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "type_name")
|
||||
private String typeName;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.business.feign;
|
||||
|
||||
import com.muyu.business.domain.Entinfo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* EntInfoFeign
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/10
|
||||
*/
|
||||
|
||||
@FeignClient(value = "muyu-business-service" )
|
||||
public interface EntInfoFeign {
|
||||
|
||||
@GetMapping("ListAll")
|
||||
public List<Entinfo> listAll();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.muyu.business.domain.Cart;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName PlusMapper
|
||||
* @Date 2024/06/09 15:33
|
||||
*/
|
||||
@Mapper
|
||||
public interface PlusMapper extends MPJBaseMapper<Cart> {
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.Type;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName PlusMapper
|
||||
* @Date 2024/06/09 15:33
|
||||
*/
|
||||
@Mapper
|
||||
public interface TypeMapper extends BaseMapper<Type> {
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Cart;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
/**
|
||||
* @ClassName PlusService
|
||||
* @Description 描述
|
||||
* @Author BingRui.Hou
|
||||
* @Date 2024/06/09 15:36
|
||||
*/
|
||||
public interface PlusService extends IService<Cart> {
|
||||
Result cartList();
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.business.domain.Cart;
|
||||
import com.muyu.business.domain.CartVo;
|
||||
import com.muyu.business.domain.Type;
|
||||
import com.muyu.business.mapper.PlusMapper;
|
||||
import com.muyu.business.mapper.TypeMapper;
|
||||
import com.muyu.business.service.PlusService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PlusServiceImpl
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/10
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class PlusServiceImpl extends MPJBaseServiceImpl<PlusMapper, Cart> implements PlusService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PlusMapper plusMapper;
|
||||
|
||||
@Autowired
|
||||
private TypeMapper typeMapper;
|
||||
|
||||
@Override
|
||||
public Result cartList(){
|
||||
MPJLambdaWrapper<Cart> mpjLambdaWrapper = new MPJLambdaWrapper<Cart>()
|
||||
.selectAll( Cart.class) //查询主表所有的字段
|
||||
.select(Type::getTypeName) //查询类型名称
|
||||
.leftJoin(Type.class, Type::getId, Cart::getTypeId);//左连接查询,相当于 left join type on dept.id=user.dept_id
|
||||
List<CartVo> cartList = plusMapper.selectJoinList(CartVo.class, mpjLambdaWrapper);
|
||||
|
||||
|
||||
List<Cart> list = this.list();
|
||||
list.stream().forEach(cart -> {
|
||||
|
||||
LambdaQueryWrapper<Type> typeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
Type type = typeMapper.selectOne(typeLambdaQueryWrapper.eq(Type::getId, cart.getTypeId()));
|
||||
cart.setName(type.getTypeName());
|
||||
|
||||
});
|
||||
System.out.println(list);
|
||||
return Result.success(list,cartList.toString());
|
||||
}
|
||||
}
|
|
@ -4,6 +4,17 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
rabbitmq:
|
||||
username: guest
|
||||
password: guest
|
||||
virtualHost: /
|
||||
port: 5672
|
||||
host: 122.51.111.225
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
||||
publisher-returns: true #确认消息已发送到队列(Queue)
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-business
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
<?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.muyu.business.mapper.EntinfoMapper">
|
||||
|
||||
<resultMap type="com.muyu.business.domain.Entinfo" id="EntinfoResult">
|
||||
<result property="entCode" column="ent_code" />
|
||||
<result property="ip" column="ip" />
|
||||
<result property="port" column="port" />
|
||||
<result property="id" column="id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEntinfoVo">
|
||||
select ent_code, ip, port, id from entinfo
|
||||
</sql>
|
||||
|
||||
<select id="selectEntinfoList" parameterType="com.muyu.business.domain.Entinfo" resultMap="EntinfoResult">
|
||||
<include refid="selectEntinfoVo"/>
|
||||
<where>
|
||||
<if test="entCode != null and entCode != ''"> and ent_code = #{entCode}</if>
|
||||
<if test="ip != null and ip != ''"> and ip = #{ip}</if>
|
||||
<if test="port != null "> and port = #{port}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEntinfoById" parameterType="Long" resultMap="EntinfoResult">
|
||||
<include refid="selectEntinfoVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEntinfo" parameterType="com.muyu.business.domain.Entinfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into entinfo
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="entCode != null">ent_code,</if>
|
||||
<if test="ip != null">ip,</if>
|
||||
<if test="port != null">port,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="entCode != null">#{entCode},</if>
|
||||
<if test="ip != null">#{ip},</if>
|
||||
<if test="port != null">#{port},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEntinfo" parameterType="com.muyu.business.domain.Entinfo">
|
||||
update entinfo
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="entCode != null">ent_code = #{entCode},</if>
|
||||
<if test="ip != null">ip = #{ip},</if>
|
||||
<if test="port != null">port = #{port},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEntinfoById" parameterType="Long">
|
||||
delete from entinfo where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEntinfoByIds" parameterType="String">
|
||||
delete from entinfo where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -44,6 +44,12 @@
|
|||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
|
@ -80,6 +86,14 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.muyu.cloud;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 多数据源启动类 CloudManyDataSourceApplication
|
||||
|
@ -16,7 +18,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {DynamicDataSourceAutoConfiguration.class, DataSourceAutoConfiguration.class})
|
||||
public class CloudManyDataSourceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -4,6 +4,17 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
rabbitmq:
|
||||
username: guest
|
||||
password: guest
|
||||
virtualHost: /
|
||||
port: 5672
|
||||
host: 122.51.111.225
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
||||
publisher-returns: true #确认消息已发送到队列(Queue)
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-vehicle
|
||||
|
|
|
@ -23,5 +23,11 @@
|
|||
<description>
|
||||
muyu-modules业务模块
|
||||
</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue