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

将小程序后端以微服务形式引入(可能还有bug)

This commit is contained in:
程序员小墨 2022-11-05 17:11:54 +08:00
parent 48ba451ec0
commit 26e24eacd7
46 changed files with 1547 additions and 1 deletions

View File

@ -3,6 +3,8 @@
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/microservice-api/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/microservice-api/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/microservice-provider-miniprogram-8080/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/microservice-provider-miniprogram-8080/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/microservice-provider-user-8001/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/microservice-provider-user-8001/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />

View File

@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MiniProgram" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" />
<module name="microservice-provider-miniprogram-8080" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.school.Application" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@ -4,7 +4,7 @@
<envs>
<env name="--spring.profiles.active" value="remote" />
</envs>
<module name="microservice-provider-user" />
<module name="microservice-provider-user-8001" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.cxyxiaomo.epp.UserProvider" />
<option name="WORKING_DIRECTORY" value="file://$MODULE_WORKING_DIR$" />
<extension name="coverage">

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>epp</artifactId>
<groupId>com.cxyxiaomo</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>microservice-provider-miniprogram</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package com.school;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,55 @@
package com.school.index.controller;
import com.school.index.pojo.Apply;
import com.school.index.pojo.Res;
import com.school.index.service.ApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
@Controller
@RequestMapping("apply")
public class ApplyController {
@Autowired
private ApplyService applyService;
@RequestMapping("/applySub")
@ResponseBody
public String applySub(Apply apply) {
apply.setCreate_time(new Date().toString());
return applyService.applySub(apply);
}
@RequestMapping("/applyListNoReplay")
@ResponseBody
public Res applyListNoReplay() {
return Res.success(applyService.applyListNoReplay());
}
@RequestMapping("/myApply")
@ResponseBody
public Res myApply(Integer id) {
return Res.success(applyService.myApply(id));
}
@RequestMapping("/applyReplay")
@ResponseBody
public Res applyReplay(Integer id,String replay,Integer reasonId) {
String reason = null;
if (reasonId == 0){
reason = "格式错误";
}else if(reasonId == 1){
reason = "出行地点不允许";
}else if(reasonId == 2){
reason = "时间填写错误";
}else if(reasonId == 99){
reason = "";
}
return Res.success(applyService.applyReplay(id, replay,reason));
}
}

View File

@ -0,0 +1,41 @@
package com.school.index.controller;
import com.school.index.pojo.Apply;
import com.school.index.pojo.Notice;
import com.school.index.pojo.Report;
import com.school.index.pojo.Res;
import com.school.index.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
@Controller
@RequestMapping("notice")
public class NoticeController {
@Autowired
private NoticeService noticeService;
@RequestMapping("/noticeList")
@ResponseBody
public Res noticeList(Integer limit){
return Res.success(noticeService.noticeList(limit));
}
@RequestMapping("/addNotice")
@ResponseBody
public String addNotice(Notice notice){
noticeService.addNotice(notice);
return "发布成功";
}
@RequestMapping("/delNotice")
@ResponseBody
public String delNotice(Integer id){
noticeService.delNotice(id);
return "删除成功";
}
}

View File

@ -0,0 +1,45 @@
package com.school.index.controller;
import com.school.index.pojo.Res;
import com.school.index.service.OtherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("other")
public class OtherController {
@Autowired
private OtherService otherService;
@RequestMapping("/subFeedback")
@ResponseBody
public String subFeedback(String title, String content,String time, Integer id){
if (otherService.subFeedback(title, content,time,id) != 0){
return "提交成功";
}else{
return "提交失败";
}
}
@RequestMapping("/feedbackList")
@ResponseBody
public Res feedbackList(Integer id){
return Res.success(otherService.feedbackList(id));
}
@RequestMapping("/feedbackListNoReplay")
@ResponseBody
public Res feedbackListNoReplay(){
return Res.success(otherService.feedbackListNoReplay());
}
@RequestMapping("/feedbackReplay")
@ResponseBody
public Res feedbackReplay(Integer id,String replay){
return Res.success(otherService.feedbackReplay(id,replay));
}
}

View File

@ -0,0 +1,34 @@
package com.school.index.controller;
import com.school.index.pojo.Report;
import com.school.index.pojo.Res;
import com.school.index.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("report")
public class ReportController {
@Autowired
private ReportService reportService;
@RequestMapping("/doReport")
@ResponseBody
public String doReport(Report report){
if (reportService.doReport(report)!=0){
return "填报成功";
}else {
return "填报失败";
}
}
@RequestMapping("/myReport")
@ResponseBody
public Res myReport(Integer id){
return Res.success(reportService.myReport(id));
}
}

View File

@ -0,0 +1,87 @@
package com.school.index.controller;
import com.school.index.pojo.Res;
import com.school.index.pojo.User;
import com.school.index.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/login")
@ResponseBody
public Res login(String username, String password){
User user = userService.getUserByUsername(username);
if (user!=null){
if (user.getPassword().equals(password)){
return Res.success(user);
}else {
return Res.error("密码错误");
}
}else{
return Res.error("该用户名不存在");
}
}
@RequestMapping("/person")
@ResponseBody
public User person(String username){
return userService.getUserByUsername(username);
}
@RequestMapping("/updateImg")
@ResponseBody
public String updateImg(Integer id,String img){
if (userService.updateImg(id,img) != 0){
return "修改成功";
}else{
return "修改失败";
}
}
@RequestMapping("/updPwd")
@ResponseBody
public String updPwd(String username,String pwd1,String pwd2){
User user = userService.getUserByUsername(username);
if (user.getPassword().equals(pwd1)){
userService.updPwd(username, pwd2);
return "请重新登录";
}else {
return "原密码错误";
}
}
@RequestMapping("/redCodeList")
@ResponseBody
public Res redCodeList(){
return Res.success(userService.redCodeList());
}
@RequestMapping("/redCodeList2")
@ResponseBody
public Res redCodeList2(){
return Res.success(userService.redCodeList2());
}
@RequestMapping("/addUser")
@ResponseBody
public Res addUser(String username,String name,Integer role){
User user = new User();
user.setUsername(username);
user.setPassword(username);
user.setName(name);
if (role == 2){
user.setStu_id(username);
}
user.setRole(role);
return Res.success(userService.addUser(user));
}
}

View File

@ -0,0 +1,94 @@
package com.school.index.controller;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import java.util.Hashtable;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.school.index.pojo.Res;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 二维码的生成需要借助MatrixToImageWriter类该类是由Google提供的可以将该类直接拷贝到源码中使用
*/
@Controller
@RequestMapping("code")
public class toCodeController {
private static final int WHITE = 0xFFFFFFFF;
private static final int RED = 0xDC143C;
private static final int GREEN = 0x008001;
private toCodeController() {
}
public static BufferedImage toBufferedImage(BitMatrix matrix,Integer isHealth) {
int width = matrix.getWidth();
int height = matrix.getHeight();
int color;
if (isHealth == 0){
color = RED;
}else{
color = GREEN;
}
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, matrix.get(x, y) ? color : WHITE);
}
}
return image;
}
public static void writeToFile(BitMatrix matrix, String format, File file,Integer isHealth)
throws IOException {
BufferedImage image = toBufferedImage(matrix,isHealth);
if (!ImageIO.write(image, format, file)) {
throw new IOException("Could not write an image of format "
+ format + " to " + file);
}
}
public static void writeToStream(BitMatrix matrix, String format,
OutputStream stream,Integer isHealth) throws IOException {
BufferedImage image = toBufferedImage(matrix,isHealth);
if (!ImageIO.write(image, format, stream)) {
throw new IOException("Could not write an image of format " + format);
}
}
@RequestMapping("/showCode")
@ResponseBody
public void showCode(String stuId,String name, Integer isHealth) throws Exception {
String health;
if (isHealth == 1) {
health = "健康";
}else{
health = "不健康";
}
String text = stuId+" "+name+" "+health; // 二维码内容
int width = 400; // 二维码图片宽度
int height = 400; // 二维码图片高度
String format = "jpg";// 二维码的图片格式
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); // 内容所使用字符集编码
BitMatrix bitMatrix = new MultiFormatWriter().encode(text,
BarcodeFormat.QR_CODE, width, height, hints);
// 生成二维码
File outputFile = new File("D:/毕设/school/wx/img" + File.separator + "code.jpg");
toCodeController.writeToFile(bitMatrix, format, outputFile,isHealth);
}
}

View File

@ -0,0 +1,19 @@
package com.school.index.dao;
import com.school.index.pojo.Apply;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ApplyDao {
int applySub(Apply apply);
int lastApply(Integer id);
List<Apply> applyListNoReplay();
List<Apply> myApply(Integer id);
int applyReplay(Integer id, String replay, String reason);
}

View File

@ -0,0 +1,16 @@
package com.school.index.dao;
import com.school.index.pojo.Notice;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface NoticeDao {
void addNotice(Notice notice);
void delNotice(Integer id);
List<Notice> noticeList(Integer limit);
}

View File

@ -0,0 +1,19 @@
package com.school.index.dao;
import com.school.index.pojo.Feedback;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface OtherDao {
int subFeedback(String title, String content,String time, Integer id);
List<Feedback> feedbackList(Integer id);
List<Feedback> feedbackListNoReplay();
int feedbackReplay(Integer id,String replay);
}

View File

@ -0,0 +1,15 @@
package com.school.index.dao;
import com.school.index.pojo.Report;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ReportDao {
int doReport(Report report);
List<Report> myReport(Integer id);
}

View File

@ -0,0 +1,28 @@
package com.school.index.dao;
import com.school.index.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserDao {
List<User> selectAll();
User getUser(String username,String role);
User getUserByUsername(String username);
int updateImg(Integer id,String img);
int updPwd(String username, String pwd2);
int updState(Integer id, String date);
List<User> redCodeList();
List<User> redCodeList2();
int addUser(User user);
}

View File

@ -0,0 +1,29 @@
package com.school.index.pojo;
import lombok.Data;
@Data
public class Apply {
private Integer id;
private String name;
private String stuId;
private Integer stu_id;
private String issue;
private String transport;
private String place;
private String start_time;
private String end_time;
private Integer state;
private String create_time;
}

View File

@ -0,0 +1,17 @@
package com.school.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

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

View File

@ -0,0 +1,28 @@
package com.school.index.pojo;
import lombok.Data;
@Data
public class Report {
private Integer id;
private Integer user_id;
private String name;
private String address;
private String time;
private String normal;
private String yes_noon_temp;
private String yes_night_temp;
private String today_morning_temp;
private String isolation;
}

View File

@ -0,0 +1,34 @@
package com.school.index.pojo;
import lombok.Data;
@Data
public class Res<T> {
private String msg;
private T data;
public Res() {
}
public Res(T data) {
this.data = data;
}
public static Res success(){
Res res = new Res<>();
res.setMsg("成功");
return res;
}
public static <T> Res<T> success(T data){
Res<T> res = new Res<>(data);
res.setMsg("成功");
return res;
}
public static Res error(String msg){
Res res = new Res<>();
res.setMsg(msg);
return res;
}
}

View File

@ -0,0 +1,15 @@
package com.school.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

@ -0,0 +1,15 @@
package com.school.index.service;
import com.school.index.pojo.Apply;
import java.util.List;
public interface ApplyService {
String applySub(Apply apply);
List<Apply> applyListNoReplay();
List<Apply> myApply(Integer id);
String applyReplay(Integer id, String replay,String reason);
}

View File

@ -0,0 +1,43 @@
package com.school.index.service;
import com.school.index.dao.ApplyDao;
import com.school.index.pojo.Apply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ApplyServiceImpl implements ApplyService {
@Autowired
private ApplyDao applyDao;
@Override
public String applySub(Apply apply) {
try {
applyDao.lastApply(apply.getStu_id());
return "您已提交该日的申请,请等待审批";
}catch (Exception e){
applyDao.applySub(apply);
return "申请成功";
}
}
@Override
public List<Apply> applyListNoReplay() {
return applyDao.applyListNoReplay();
}
@Override
public List<Apply> myApply(Integer id) {
return applyDao.myApply(id);
}
@Override
public String applyReplay(Integer id, String replay,String reason) {
applyDao.applyReplay(id,replay,reason);
return null;
}
}

View File

@ -0,0 +1,17 @@
package com.school.index.service;
import com.school.index.pojo.Apply;
import com.school.index.pojo.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
public interface NoticeService {
void addNotice(Notice notice);
void delNotice(Integer id);
List<Notice> noticeList(Integer limit);
}

View File

@ -0,0 +1,31 @@
package com.school.index.service;
import com.school.index.dao.NoticeDao;
import com.school.index.pojo.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class NoticeServiceImpl implements NoticeService {
@Autowired
private NoticeDao noticeDao;
@Override
public void addNotice(Notice notice) {
noticeDao.addNotice(notice);
}
@Override
public void delNotice(Integer id) {
noticeDao.delNotice(id);
}
@Override
public List<Notice> noticeList(Integer limit) {
return noticeDao.noticeList(limit);
}
}

View File

@ -0,0 +1,16 @@
package com.school.index.service;
import com.school.index.pojo.Feedback;
import java.util.List;
public interface OtherService {
int subFeedback(String title, String content,String time, Integer id);
List<Feedback> feedbackList(Integer id);
List<Feedback> feedbackListNoReplay();
int feedbackReplay(Integer id,String replay);
}

View File

@ -0,0 +1,35 @@
package com.school.index.service;
import com.school.index.dao.OtherDao;
import com.school.index.pojo.Feedback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class OtherServiceImpl implements OtherService {
@Autowired
private OtherDao otherDao;
@Override
public int subFeedback(String title, String content,String time, Integer id) {
return otherDao.subFeedback(title, content,time,id);
}
@Override
public List<Feedback> feedbackList(Integer id) {
return otherDao.feedbackList(id);
}
@Override
public List<Feedback> feedbackListNoReplay() {
return otherDao.feedbackListNoReplay();
}
@Override
public int feedbackReplay(Integer id, String replay) {
return otherDao.feedbackReplay(id,replay);
}
}

View File

@ -0,0 +1,12 @@
package com.school.index.service;
import com.school.index.pojo.Report;
import java.util.List;
public interface ReportService {
int doReport(Report report);
List<Report> myReport(Integer id);
}

View File

@ -0,0 +1,39 @@
package com.school.index.service;
import com.school.index.dao.ReportDao;
import com.school.index.dao.UserDao;
import com.school.index.pojo.Report;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service
public class ReportServiceImpl implements ReportService {
@Autowired
private ReportDao reportDao;
@Autowired
private UserDao userDao;
@Override
public int doReport(Report report) {
if(!report.getNormal().equals("发热") || !report.getIsolation().equals("无需隔离")){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String date = formatter.format(new Date()) ;
// 修改用户状态
userDao.updState(report.getUser_id(),date);
}else{
userDao.updState(report.getUser_id(),"1999-01-01");
}
return reportDao.doReport(report);
}
@Override
public List<Report> myReport(Integer id) {
return reportDao.myReport(id);
}
}

View File

@ -0,0 +1,23 @@
package com.school.index.service;
import com.school.index.pojo.User;
import java.util.List;
public interface UserService {
User getUser(String username,String role);
User getUserByUsername(String username);
int updateImg(Integer id,String img);
int updPwd(String username,String pwd2);
List<User> redCodeList();
List<User> redCodeList2();
String addUser(User user);
}

View File

@ -0,0 +1,55 @@
package com.school.index.service;
import com.school.index.dao.UserDao;
import com.school.index.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public User getUser(String username,String role) {
return userDao.getUser(username, role);
}
@Override
public User getUserByUsername(String username) {
return userDao.getUserByUsername(username);
}
@Override
public int updateImg(Integer id, String img) {
return userDao.updateImg(id,img);
}
@Override
public int updPwd(String username, String pwd2) {
return userDao.updPwd(username, pwd2);
}
@Override
public List<User> redCodeList() {
return userDao.redCodeList();
}
@Override
public List<User> redCodeList2() {
return userDao.redCodeList2();
}
@Override
public String addUser(User user) {
if (userDao.getUserByUsername(user.getUsername()) == null){
userDao.addUser(user);
return "添加成功";
}else{
return "该用户已存在";
}
}
}

View File

@ -0,0 +1,45 @@
package com.school.visitor.controller;
import com.school.index.pojo.Apply;
import com.school.index.pojo.Res;
import com.school.visitor.pojo.Visitor;
import com.school.visitor.service.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
@Controller
@RequestMapping("visitor")
public class VisitorController {
@Autowired
private VisitorService visitorService;
@ResponseBody
@RequestMapping("/visitorApply")
public String visitorApply(Visitor visitor) {
// visitor.setCreate_time(new Date().toString());
return visitorService.visitorApply(visitor);
}
@ResponseBody
@RequestMapping("/visitorChangeState")
public String visitorChangeState(Integer id, Integer state) {
return visitorService.visitorChangeState(id, state);
}
@ResponseBody
@RequestMapping("/showMyVisitor")
public String showMyVisitor(String phone) {
return visitorService.showMyVisitor(phone);
}
@ResponseBody
@RequestMapping("/showVisitorList")
public Res showVisitorList() {
return Res.success(visitorService.showVisitorList());
}
}

View File

@ -0,0 +1,20 @@
package com.school.visitor.dao;
import com.school.visitor.pojo.Visitor;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface VisitorDao {
int getApplyByPhone(String phone);
int visitorApply(Visitor visitor);
int visitorChangeState(Integer id, Integer state);
int showMyVisitor(String phone);
List<Visitor> showVisitorList();
}

View File

@ -0,0 +1,22 @@
package com.school.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

@ -0,0 +1,16 @@
package com.school.visitor.service;
import com.school.visitor.pojo.Visitor;
import java.util.List;
public interface VisitorService {
String visitorApply(Visitor visitor);
String visitorChangeState(Integer id, Integer state);
String showMyVisitor(String phone);
List<Visitor> showVisitorList();
}

View File

@ -0,0 +1,53 @@
package com.school.visitor.service.impl;
import com.school.visitor.dao.VisitorDao;
import com.school.visitor.pojo.Visitor;
import com.school.visitor.service.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class VisitorServiceImpl implements VisitorService {
@Autowired
private VisitorDao visitorDao;
@Override
public String visitorApply(Visitor visitor) {
if (visitorDao.getApplyByPhone(visitor.getPhone())==0){
visitorDao.visitorApply(visitor);
return "申请成功";
}else {
return "不能重复申请";
}
}
@Override
public String visitorChangeState(Integer id, Integer state) {
visitorDao.visitorChangeState(id, state);
if (state == 1)
{ return "审批成功";
}else{
return "已驳回";
}
}
@Override
public String showMyVisitor(String phone) {
int i = visitorDao.showMyVisitor(phone);
if (i == 0){
return "您的审批正在申请";
}else if(i==1){
return "审批通过";
}else{
return "申请已被驳回,请重新申请";
}
}
@Override
public List<Visitor> showVisitorList() {
return visitorDao.showVisitorList();
}
}

View File

@ -0,0 +1,14 @@
server:
port: 8080
max-http-header-size: 102400
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/school?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&serverTimezone=UTC
username: root
password: root
mybatis:
mapper-locations: classpath:mapper/*.xml

View File

@ -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.school.index.dao.ApplyDao">
<insert id="applySub">
insert into apply
(stu_id,issue,transport,place,start_time,end_time,state) values
(#{stu_id},#{issue},#{transport},#{place},#{start_time},#{end_time},0)
</insert>
<update id="applyReplay">
update apply set state = #{replay}, reason =#{reason}
where id = #{id}
</update>
<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.school.index.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.school.index.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}
</select>
</mapper>

View File

@ -0,0 +1,19 @@
<?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.school.index.dao.NoticeDao">
<insert id="addNotice">
insert into notice (title, content , time) values
(#{title},#{content},#{time})
</insert>
<delete id="delNotice">
delete from notice where id = #{id}
</delete>
<select id="noticeList" resultType="com.school.index.pojo.Notice">
select * from notice order by time desc
<if test="limit!= ''">
limit ${limit}
</if>
</select>
</mapper>

View File

@ -0,0 +1,25 @@
<?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.school.index.dao.OtherDao">
<insert id="subFeedback">
insert into feedback (title, content, time, user_id) values
(#{title},#{content},#{time},#{id})
</insert>
<update id="feedbackReplay">
update feedback set reply = #{replay}
where id = #{id}
</update>
<select id="feedbackList" resultType="com.school.index.pojo.Feedback">
select * from feedback
<where>
<if test="id != null">
and user_id = #{id}
</if>
</where>
</select>
<select id="feedbackListNoReplay" resultType="com.school.index.pojo.Feedback">
select * from feedback where reply is null
</select>
</mapper>

View File

@ -0,0 +1,18 @@
<?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.school.index.dao.ReportDao">
<insert id="doReport">
insert into report
(user_id,name,address,time,normal,yes_noon_temp,yes_night_temp,
today_morning_temp,isolation)
values
(#{user_id},#{name},#{address},#{time},#{normal},#{yes_noon_temp},
#{yes_night_temp},#{today_morning_temp},#{isolation})
</insert>
<select id="myReport" resultType="com.school.index.pojo.Report">
select name,time,normal,address from report where user_id = #{id}
order by time desc
</select>
</mapper>

View File

@ -0,0 +1,38 @@
<?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.school.index.dao.UserDao">
<insert id="addUser">
insert into user
(username, name, password, role, stu_id) values
(#{username},#{name},#{password},#{role},#{stu_id})
</insert>
<update id="updateImg">
update user set img = #{img}
where id = #{id}
</update>
<update id="updPwd">
update user set password = #{pwd2}
where username = #{username}
</update>
<update id="updState">
update user set state = #{date}
where id = #{id}
</update>
<select id="selectAll" resultType="com.school.index.pojo.User">
select * from `user`
</select>
<select id="getUserByUsername" resultType="com.school.index.pojo.User">
select * from user where username = #{username}
</select>
<select id="getUser" resultType="com.school.index.pojo.User">
select * from user where username = #{username} and role_id = #{role}
</select>
<select id="redCodeList" resultType="com.school.index.pojo.User">
select name,stu_id from user where TO_DAYS(NOW( )) != TO_DAYS(state) and role = 2
</select>
<select id="redCodeList2" resultType="com.school.index.pojo.User">
select name,stu_id from user where state = "1999-01-01"
</select>
</mapper>

View File

@ -0,0 +1,25 @@
<?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.school.visitor.dao.VisitorDao">
<insert id="visitorApply">
insert into visitor
(time,phone,issue,meet_name,create_time) values
(#{time},#{phone},#{issue},#{meet_name},#{create_time})
</insert>
<update id="visitorChangeState">
update visitor set state = #{state}
where id = #{id} and state = 0
</update>
<select id="getApplyByPhone" resultType="java.lang.Integer">
select count(*) from visitor where phone=#{phone} and TO_DAYS(NOW( )) - TO_DAYS(time) = 0
</select>
<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.school.visitor.pojo.Visitor">
select * from visitor where state = 0
</select>
</mapper>

View File

@ -15,6 +15,7 @@
<modules>
<module>microservice-api</module>
<module>microservice-provider-user-8001</module>
<module>microservice-provider-miniprogram-8080</module>
</modules>
<!-- 统一管理jar包版本 -->

251
database/school.sql Normal file

File diff suppressed because one or more lines are too long