1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

所有服务接入Nacos服务发现

This commit is contained in:
程序员小墨 2022-11-05 22:33:44 +08:00
parent feeb171cff
commit 529ef7528e
49 changed files with 174 additions and 127 deletions

View File

@ -1,9 +1,15 @@
package com.cxyxiaomo.epp.index.pojo;
package com.cxyxiaomo.epp.pojo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
public class Apply {
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
public class Apply implements Serializable {
private Integer id;

View File

@ -0,0 +1,23 @@
package com.cxyxiaomo.epp.pojo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
public class Feedback implements Serializable {
private Integer id;
private String title;
private String content;
private String time;
private String reply;
}

View File

@ -0,0 +1,26 @@
package com.cxyxiaomo.epp.pojo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
// import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@Data
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
public class Notice implements Serializable {
private Integer id;
private String title;
private String content;
// @DateTimeFormat(pattern = "yyyy-MM-dd")
// TODO
private String time;
}

View File

@ -1,9 +1,15 @@
package com.cxyxiaomo.epp.index.pojo;
package com.cxyxiaomo.epp.pojo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
public class Report {
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
public class Report implements Serializable {
private Integer id;

View File

@ -1,4 +1,4 @@
package com.cxyxiaomo.epp.index.pojo;
package com.cxyxiaomo.epp.pojo;
import lombok.Data;

View File

@ -1,9 +1,7 @@
package com.cxyxiaomo.epp.pojo;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.io.Serializable;
@ -11,12 +9,16 @@ import java.io.Serializable;
// 数据库关系映射
@Data
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
public class User implements Serializable { // 微服务必须要实现Serializable
private Long id;
// 微服务必须要实现Serializable
public class User implements Serializable {
private Integer id;
private String username;
private String name;
private String password;
private String img;
private String stu_id;
private Integer role;
private String state;
}

View File

@ -0,0 +1,28 @@
package com.cxyxiaomo.epp.pojo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@NoArgsConstructor
@Accessors(chain = true) // 链式写法
public class Visitor implements Serializable {
private Integer id;
private String time;
private String phone;
private String issue;
private String meet_name;
private String create_time;
private Integer state;
}

View File

@ -18,6 +18,12 @@
</properties>
<dependencies>
<!-- 实体类 -->
<dependency>
<groupId>com.cxyxiaomo</groupId>
<artifactId>microservice-pojo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
@ -59,5 +65,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<!-- Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -2,8 +2,10 @@ package com.cxyxiaomo.epp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
public static void main(String[] args) {

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.controller;
import com.cxyxiaomo.epp.index.pojo.Apply;
import com.cxyxiaomo.epp.index.pojo.Res;
import com.cxyxiaomo.epp.pojo.Apply;
import com.cxyxiaomo.epp.pojo.Res;
import com.cxyxiaomo.epp.index.service.ApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.controller;
import com.cxyxiaomo.epp.index.pojo.Notice;
import com.cxyxiaomo.epp.index.pojo.Res;
import com.cxyxiaomo.epp.pojo.Notice;
import com.cxyxiaomo.epp.pojo.Res;
import com.cxyxiaomo.epp.index.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.controller;
import com.cxyxiaomo.epp.index.pojo.Res;
import com.cxyxiaomo.epp.pojo.Res;
import com.cxyxiaomo.epp.index.service.OtherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.controller;
import com.cxyxiaomo.epp.index.pojo.Report;
import com.cxyxiaomo.epp.index.pojo.Res;
import com.cxyxiaomo.epp.pojo.Report;
import com.cxyxiaomo.epp.pojo.Res;
import com.cxyxiaomo.epp.index.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.controller;
import com.cxyxiaomo.epp.index.pojo.Res;
import com.cxyxiaomo.epp.index.pojo.User;
import com.cxyxiaomo.epp.pojo.Res;
import com.cxyxiaomo.epp.pojo.User;
import com.cxyxiaomo.epp.index.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.dao;
import com.cxyxiaomo.epp.index.pojo.Apply;
import com.cxyxiaomo.epp.pojo.Apply;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.dao;
import com.cxyxiaomo.epp.index.pojo.Notice;
import com.cxyxiaomo.epp.pojo.Notice;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.dao;
import com.cxyxiaomo.epp.index.pojo.Feedback;
import com.cxyxiaomo.epp.pojo.Feedback;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.dao;
import com.cxyxiaomo.epp.index.pojo.Report;
import com.cxyxiaomo.epp.pojo.Report;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.dao;
import com.cxyxiaomo.epp.index.pojo.User;
import com.cxyxiaomo.epp.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -1,17 +0,0 @@
package com.cxyxiaomo.epp.index.pojo;
import lombok.Data;
@Data
public class Feedback {
private Integer id;
private String title;
private String content;
private String time;
private String reply;
}

View File

@ -1,19 +0,0 @@
package com.cxyxiaomo.epp.index.pojo;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@Data
public class Notice {
private Integer id;
private String title;
private String content;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private String time;
}

View File

@ -1,15 +0,0 @@
package com.cxyxiaomo.epp.index.pojo;
import lombok.Data;
@Data
public class User {
private Integer id;
private String username;
private String name;
private String password;
private String img;
private String stu_id;
private Integer role;
private String state;
}

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.pojo.Apply;
import com.cxyxiaomo.epp.pojo.Apply;
import java.util.List;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.dao.ApplyDao;
import com.cxyxiaomo.epp.index.pojo.Apply;
import com.cxyxiaomo.epp.pojo.Apply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.pojo.Notice;
import com.cxyxiaomo.epp.pojo.Notice;
import java.util.List;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.dao.NoticeDao;
import com.cxyxiaomo.epp.index.pojo.Notice;
import com.cxyxiaomo.epp.pojo.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.pojo.Feedback;
import com.cxyxiaomo.epp.pojo.Feedback;
import java.util.List;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.dao.OtherDao;
import com.cxyxiaomo.epp.index.pojo.Feedback;
import com.cxyxiaomo.epp.pojo.Feedback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.pojo.Report;
import com.cxyxiaomo.epp.pojo.Report;
import java.util.List;

View File

@ -2,7 +2,7 @@ package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.dao.ReportDao;
import com.cxyxiaomo.epp.index.dao.UserDao;
import com.cxyxiaomo.epp.index.pojo.Report;
import com.cxyxiaomo.epp.pojo.Report;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.pojo.User;
import com.cxyxiaomo.epp.pojo.User;
import java.util.List;

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.index.service;
import com.cxyxiaomo.epp.index.dao.UserDao;
import com.cxyxiaomo.epp.index.pojo.User;
import com.cxyxiaomo.epp.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,8 +1,8 @@
package com.cxyxiaomo.epp.visitor.controller;
import com.cxyxiaomo.epp.index.pojo.Res;
import com.cxyxiaomo.epp.pojo.Res;
import com.cxyxiaomo.epp.visitor.service.VisitorService;
import com.cxyxiaomo.epp.visitor.pojo.Visitor;
import com.cxyxiaomo.epp.pojo.Visitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.visitor.dao;
import com.cxyxiaomo.epp.visitor.pojo.Visitor;
import com.cxyxiaomo.epp.pojo.Visitor;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -1,22 +0,0 @@
package com.cxyxiaomo.epp.visitor.pojo;
import lombok.Data;
@Data
public class Visitor {
private Integer id;
private String time;
private String phone;
private String issue;
private String meet_name;
private String create_time;
private Integer state;
}

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.visitor.service;
import com.cxyxiaomo.epp.visitor.pojo.Visitor;
import com.cxyxiaomo.epp.pojo.Visitor;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.cxyxiaomo.epp.visitor.service.impl;
import com.cxyxiaomo.epp.visitor.pojo.Visitor;
import com.cxyxiaomo.epp.pojo.Visitor;
import com.cxyxiaomo.epp.visitor.service.VisitorService;
import com.cxyxiaomo.epp.visitor.dao.VisitorDao;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -5,6 +5,10 @@ server:
spring:
application:
name: microservice-provider-miniprogram
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&serverTimezone=UTC

View File

@ -15,12 +15,12 @@
<select id="lastApply" resultType="java.lang.Integer">
select * from apply where stu_id = #{id} and state = 0 limit 1
</select>
<select id="applyListNoReplay" resultType="com.cxyxiaomo.epp.index.pojo.Apply">
<select id="applyListNoReplay" resultType="com.cxyxiaomo.epp.pojo.Apply">
select a.*,u.name,u.stu_id as stuId from apply a
left join user u on a.stu_id = u.id
where a.state = 0
</select>
<select id="myApply" resultType="com.cxyxiaomo.epp.index.pojo.Apply">
<select id="myApply" resultType="com.cxyxiaomo.epp.pojo.Apply">
select a.*,u.name,u.stu_id as stuId from apply a
left join user u on a.stu_id = u.id
where a.stu_id = #{id}

View File

@ -10,7 +10,7 @@
<delete id="delNotice">
delete from notice where id = #{id}
</delete>
<select id="noticeList" resultType="com.cxyxiaomo.epp.index.pojo.Notice">
<select id="noticeList" resultType="com.cxyxiaomo.epp.pojo.Notice">
select * from notice order by time desc
<if test="limit!= ''">
limit ${limit}

View File

@ -11,7 +11,7 @@
update feedback set reply = #{replay}
where id = #{id}
</update>
<select id="feedbackList" resultType="com.cxyxiaomo.epp.index.pojo.Feedback">
<select id="feedbackList" resultType="com.cxyxiaomo.epp.pojo.Feedback">
select * from feedback
<where>
<if test="id != null">
@ -19,7 +19,7 @@
</if>
</where>
</select>
<select id="feedbackListNoReplay" resultType="com.cxyxiaomo.epp.index.pojo.Feedback">
<select id="feedbackListNoReplay" resultType="com.cxyxiaomo.epp.pojo.Feedback">
select * from feedback where reply is null
</select>
</mapper>

View File

@ -11,7 +11,7 @@
(#{user_id},#{name},#{address},#{time},#{normal},#{yes_noon_temp},
#{yes_night_temp},#{today_morning_temp},#{isolation})
</insert>
<select id="myReport" resultType="com.cxyxiaomo.epp.index.pojo.Report">
<select id="myReport" resultType="com.cxyxiaomo.epp.pojo.Report">
select name,time,normal,address from report where user_id = #{id}
order by time desc
</select>

View File

@ -19,20 +19,20 @@
update user set state = #{date}
where id = #{id}
</update>
<select id="selectAll" resultType="com.cxyxiaomo.epp.index.pojo.User">
<select id="selectAll" resultType="com.cxyxiaomo.epp.pojo.User">
select * from `user`
</select>
<select id="getUserByUsername" resultType="com.cxyxiaomo.epp.index.pojo.User">
<select id="getUserByUsername" resultType="com.cxyxiaomo.epp.pojo.User">
select * from user where username = #{username}
</select>
<select id="getUser" resultType="com.cxyxiaomo.epp.index.pojo.User">
<select id="getUser" resultType="com.cxyxiaomo.epp.pojo.User">
select * from user where username = #{username} and role_id = #{role}
</select>
<select id="redCodeList" resultType="com.cxyxiaomo.epp.index.pojo.User">
<select id="redCodeList" resultType="com.cxyxiaomo.epp.pojo.User">
select name,stu_id from user where TO_DAYS(NOW( )) != TO_DAYS(state) and role = 2
</select>
<select id="redCodeList2" resultType="com.cxyxiaomo.epp.index.pojo.User">
<select id="redCodeList2" resultType="com.cxyxiaomo.epp.pojo.User">
select name,stu_id from user where state = "1999-01-01"
</select>
</mapper>

View File

@ -19,7 +19,7 @@
<select id="showMyVisitor" resultType="java.lang.Integer">
select state from visitor where phone = #{phone} and TO_DAYS(NOW( )) - TO_DAYS(time) = 0
</select>
<select id="showVisitorList" resultType="com.cxyxiaomo.epp.visitor.pojo.Visitor">
<select id="showVisitorList" resultType="com.cxyxiaomo.epp.pojo.Visitor">
select * from visitor where state = 0
</select>
</mapper>

View File

@ -76,6 +76,12 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- 热部署 -->
<!--<dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->

View File

@ -2,10 +2,12 @@ package com.cxyxiaomo.epp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
// 启动类
@SpringBootApplication
@EnableDiscoveryClient
public class UserProvider {
public static void main(String[] args) {
SpringApplication.run(UserProvider.class, args);

View File

@ -1,7 +1,7 @@
package com.cxyxiaomo.epp.controller;
import com.cxyxiaomo.epp.service.UserServiceImpl;
import com.cxyxiaomo.epp.pojo.User;
import com.cxyxiaomo.epp.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

View File

@ -11,6 +11,10 @@ mybatis:
spring:
application:
name: microservice-provider-user
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -75,7 +75,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.6.4</version>
<version>2.6.3</version>
</dependency>
<!-- Nacos -->