From a92ec8c18c9720e54d4b1e0ccd34df4b99aa479b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=82=B3=E8=BC=B8=E5=8A=A9=E6=89=8B?= <1766219146@qq.com> Date: Tue, 16 Aug 2022 13:54:13 +0800 Subject: [PATCH 1/2] aaa --- src/main/java/com/sixteam/irs/IrsApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sixteam/irs/IrsApplication.java b/src/main/java/com/sixteam/irs/IrsApplication.java index 1195710..cd5037c 100644 --- a/src/main/java/com/sixteam/irs/IrsApplication.java +++ b/src/main/java/com/sixteam/irs/IrsApplication.java @@ -8,7 +8,7 @@ public class IrsApplication { public static void main(String[] args) { SpringApplication.run(IrsApplication.class, args); - System.out.println("12311111321"); + System.out.println(""); } } -- Gitee From e17ff94a66ab82c04c9d4ffcedc38f2a3aa34300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=82=B3=E8=BC=B8=E5=8A=A9=E6=89=8B?= <1766219146@qq.com> Date: Tue, 16 Aug 2022 19:18:04 +0800 Subject: [PATCH 2/2] bbb --- .../irs/controller/EnterpriseController.java | 36 +++++ .../irs/controller/UserController.java | 90 +++++++++++ .../sixteam/irs/mapper/EnterpriseMapper.java | 22 +++ .../com/sixteam/irs/mapper/UserMapper.java | 22 +++ .../com/sixteam/irs/model/Enterprise.java | 124 ++++++++++++++++ src/main/java/com/sixteam/irs/model/User.java | 140 ++++++++++++++++++ .../irs/service/EnterpriseService.java | 19 +++ .../com/sixteam/irs/service/UserService.java | 19 +++ .../service/impl/EnterpriceServiceImpl.java | 46 ++++++ .../irs/service/impl/UserServiceImpl.java | 50 +++++++ .../java/com/sixteam/irs/utils/UuidUtils.java | 9 ++ src/main/resources/application.yml | 8 +- .../resources/mapper/EnterpriseMapper.xml | 46 ++++++ src/main/resources/mapper/UserMapper.xml | 46 ++++++ src/main/resources/templates/index.html | 10 ++ 15 files changed, 683 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/sixteam/irs/controller/EnterpriseController.java create mode 100644 src/main/java/com/sixteam/irs/controller/UserController.java create mode 100644 src/main/java/com/sixteam/irs/mapper/EnterpriseMapper.java create mode 100644 src/main/java/com/sixteam/irs/mapper/UserMapper.java create mode 100644 src/main/java/com/sixteam/irs/model/Enterprise.java create mode 100644 src/main/java/com/sixteam/irs/model/User.java create mode 100644 src/main/java/com/sixteam/irs/service/EnterpriseService.java create mode 100644 src/main/java/com/sixteam/irs/service/UserService.java create mode 100644 src/main/java/com/sixteam/irs/service/impl/EnterpriceServiceImpl.java create mode 100644 src/main/java/com/sixteam/irs/service/impl/UserServiceImpl.java create mode 100644 src/main/java/com/sixteam/irs/utils/UuidUtils.java create mode 100644 src/main/resources/mapper/EnterpriseMapper.xml create mode 100644 src/main/resources/mapper/UserMapper.xml create mode 100644 src/main/resources/templates/index.html diff --git a/src/main/java/com/sixteam/irs/controller/EnterpriseController.java b/src/main/java/com/sixteam/irs/controller/EnterpriseController.java new file mode 100644 index 0000000..50b3528 --- /dev/null +++ b/src/main/java/com/sixteam/irs/controller/EnterpriseController.java @@ -0,0 +1,36 @@ +package com.sixteam.irs.controller; + +import com.sixteam.irs.model.Enterprise; +import com.sixteam.irs.model.User; +import com.sixteam.irs.service.EnterpriseService; +import com.sixteam.irs.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; + +@Controller +@RequestMapping("/ee") +public class EnterpriseController { + + @Autowired + private EnterpriseService enterpriseService; + + @RequestMapping("findAllEnterprise") + public String findAllEnterprise(Model model){ + List enterpriseList = enterpriseService.findAllEnterprise(); + model.addAttribute("enterpriseList",enterpriseList); + return "enterpriseList.html"; + } + + + @RequestMapping("findEnterpriseByName") + public String findEnterpriseByName(Model model,Enterprise enterprise){ + List enterpriseList = enterpriseService.findEnterpriseByName(enterprise); + model.addAttribute("enterpriseList",enterpriseList); + return "redirect:/ee/findAllEnterprise"; + } + +} diff --git a/src/main/java/com/sixteam/irs/controller/UserController.java b/src/main/java/com/sixteam/irs/controller/UserController.java new file mode 100644 index 0000000..3d50640 --- /dev/null +++ b/src/main/java/com/sixteam/irs/controller/UserController.java @@ -0,0 +1,90 @@ +package com.sixteam.irs.controller; + +import com.sixteam.irs.model.User; +import com.sixteam.irs.service.UserService; +import com.sun.org.apache.xpath.internal.operations.Mod; +import org.apache.ibatis.annotations.Insert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.List; + +@Controller +@RequestMapping("/user") +public class UserController { + + @Autowired + private UserService userService; + + @RequestMapping("findAllUser") + public String findAllUser(Model model){ + List userList = userService.findAllUser(); + System.out.println(userList); + model.addAttribute("userList",userList); + return "userList.html"; + } + + + @RequestMapping("findUserByName") + public String findUserByName(Model model,User user){ + List userList = userService.findUserByName(user); + model.addAttribute("userList",userList); + return "redirect:/user/findAllUser"; + } + + + + @RequestMapping(value = "/addUser") + public String addUser(User user, Model model) { + if (userService.addUser(user)>0) { + + return "redirect:/user/findAllUser"; + } else { + + model.addAttribute("errorMessage", "注册错误"); + return "error"; + } + } + + + @RequestMapping(value = "/delUser") + public String delUser(User user, Model model) { + + if (userService.delUser(user)>0) { + + return "redirect:/user/findAllUser"; + } else { + + model.addAttribute("errorMessage", "删除错误"); + return "error"; + } + } + + + @RequestMapping("toUpdateUser") + public String toUpdateUser(User user, Model model, Integer id) { + + User user1 = userService.findById(user); + model.addAttribute("user1", user1); + + return "updateUser"; + } + + @RequestMapping(value = "/updateUser") + public String updateUser(User user, Model model) { + if (userService.updateUser(user)>0) { + + return "redirect:/user/findAllUser"; + } else { + + model.addAttribute("errorMessage", "修改错误"); + return "error"; + } + } + +} diff --git a/src/main/java/com/sixteam/irs/mapper/EnterpriseMapper.java b/src/main/java/com/sixteam/irs/mapper/EnterpriseMapper.java new file mode 100644 index 0000000..e3a841b --- /dev/null +++ b/src/main/java/com/sixteam/irs/mapper/EnterpriseMapper.java @@ -0,0 +1,22 @@ +package com.sixteam.irs.mapper; + +import com.sixteam.irs.model.Enterprise; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface EnterpriseMapper { + + List findAllEnterprise(); + + List findEnterpriseByName(Enterprise enterprise); + + Exception findById(Enterprise enterprise); + + int addEnterprise(Enterprise enterprise); + + int delEnterprise(Enterprise enterprise); + + int updateEnterprise(Enterprise enterprise); +} diff --git a/src/main/java/com/sixteam/irs/mapper/UserMapper.java b/src/main/java/com/sixteam/irs/mapper/UserMapper.java new file mode 100644 index 0000000..366f8bf --- /dev/null +++ b/src/main/java/com/sixteam/irs/mapper/UserMapper.java @@ -0,0 +1,22 @@ +package com.sixteam.irs.mapper; + +import com.sixteam.irs.model.User; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface UserMapper { + + List findAllUser(); + + List findUserByName(User user); + + User findById(User user); + + int addUser(User user); + + int delUser(User user); + + int updateUser(User user); +} diff --git a/src/main/java/com/sixteam/irs/model/Enterprise.java b/src/main/java/com/sixteam/irs/model/Enterprise.java new file mode 100644 index 0000000..9fe7275 --- /dev/null +++ b/src/main/java/com/sixteam/irs/model/Enterprise.java @@ -0,0 +1,124 @@ +package com.sixteam.irs.model; + +public class Enterprise { + + private String eId; + private String eName; + private String eIntroduce; + private String eStart; + private String eType; + private String eFounder; + + + public Enterprise() { + } + + public Enterprise(String eId, String eName, String eIntroduce, String eStart, String eType, String eFounder) { + this.eId = eId; + this.eName = eName; + this.eIntroduce = eIntroduce; + this.eStart = eStart; + this.eType = eType; + this.eFounder = eFounder; + } + + /** + * 获取 + * @return eId + */ + public String getEId() { + return eId; + } + + /** + * 设置 + * @param eId + */ + public void setEId(String eId) { + this.eId = eId; + } + + /** + * 获取 + * @return eName + */ + public String getEName() { + return eName; + } + + /** + * 设置 + * @param eName + */ + public void setEName(String eName) { + this.eName = eName; + } + + /** + * 获取 + * @return eIntroduce + */ + public String getEIntroduce() { + return eIntroduce; + } + + /** + * 设置 + * @param eIntroduce + */ + public void setEIntroduce(String eIntroduce) { + this.eIntroduce = eIntroduce; + } + + /** + * 获取 + * @return eStart + */ + public String getEStart() { + return eStart; + } + + /** + * 设置 + * @param eStart + */ + public void setEStart(String eStart) { + this.eStart = eStart; + } + + /** + * 获取 + * @return eType + */ + public String getEType() { + return eType; + } + + /** + * 设置 + * @param eType + */ + public void setEType(String eType) { + this.eType = eType; + } + + /** + * 获取 + * @return eFounder + */ + public String getEFounder() { + return eFounder; + } + + /** + * 设置 + * @param eFounder + */ + public void setEFounder(String eFounder) { + this.eFounder = eFounder; + } + + public String toString() { + return "Enterprise{eId = " + eId + ", eName = " + eName + ", eIntroduce = " + eIntroduce + ", eStart = " + eStart + ", eType = " + eType + ", eFounder = " + eFounder + "}"; + } +} diff --git a/src/main/java/com/sixteam/irs/model/User.java b/src/main/java/com/sixteam/irs/model/User.java new file mode 100644 index 0000000..771bd1a --- /dev/null +++ b/src/main/java/com/sixteam/irs/model/User.java @@ -0,0 +1,140 @@ +package com.sixteam.irs.model; + +public class User { + private String uId; + private String uName; + private String uPassword; + private String uPhone; + private String uEmail; + private String uSex; + private String uBirthDate; + + public User() { + } + + public User(String uId, String uName, String uPassword, String uPhone, String uEmail, String uSex, String uBirthDate) { + this.uId = uId; + this.uName = uName; + this.uPassword = uPassword; + this.uPhone = uPhone; + this.uEmail = uEmail; + this.uSex = uSex; + this.uBirthDate = uBirthDate; + } + + /** + * 获取 + * @return uId + */ + public String getUId() { + return uId; + } + + /** + * 设置 + * @param uId + */ + public void setUId(String uId) { + this.uId = uId; + } + + /** + * 获取 + * @return uName + */ + public String getUName() { + return uName; + } + + /** + * 设置 + * @param uName + */ + public void setUName(String uName) { + this.uName = uName; + } + + /** + * 获取 + * @return uPassword + */ + public String getUPassword() { + return uPassword; + } + + /** + * 设置 + * @param uPassword + */ + public void setUPassword(String uPassword) { + this.uPassword = uPassword; + } + + /** + * 获取 + * @return uPhone + */ + public String getUPhone() { + return uPhone; + } + + /** + * 设置 + * @param uPhone + */ + public void setUPhone(String uPhone) { + this.uPhone = uPhone; + } + + /** + * 获取 + * @return uEmail + */ + public String getUEmail() { + return uEmail; + } + + /** + * 设置 + * @param uEmail + */ + public void setUEmail(String uEmail) { + this.uEmail = uEmail; + } + + /** + * 获取 + * @return uSex + */ + public String getUSex() { + return uSex; + } + + /** + * 设置 + * @param uSex + */ + public void setUSex(String uSex) { + this.uSex = uSex; + } + + /** + * 获取 + * @return uBirthDate + */ + public String getUBirthDate() { + return uBirthDate; + } + + /** + * 设置 + * @param uBirthDate + */ + public void setUBirthDate(String uBirthDate) { + this.uBirthDate = uBirthDate; + } + + public String toString() { + return "User{uId = " + uId + ", uName = " + uName + ", uPassword = " + uPassword + ", uPhone = " + uPhone + ", uEmail = " + uEmail + ", uSex = " + uSex + ", uBirthDate = " + uBirthDate + "}"; + } +} diff --git a/src/main/java/com/sixteam/irs/service/EnterpriseService.java b/src/main/java/com/sixteam/irs/service/EnterpriseService.java new file mode 100644 index 0000000..f9c6d51 --- /dev/null +++ b/src/main/java/com/sixteam/irs/service/EnterpriseService.java @@ -0,0 +1,19 @@ +package com.sixteam.irs.service; + +import com.sixteam.irs.model.Enterprise; + +import java.util.List; + +public interface EnterpriseService { + List findAllEnterprise(); + + List findEnterpriseByName(Enterprise enterprise); + + Exception findById(Enterprise enterprise); + + int addEnterprise(Enterprise enterprise); + + int delEnterprise(Enterprise enterprise); + + int updateEnterprise(Enterprise enterprise); +} diff --git a/src/main/java/com/sixteam/irs/service/UserService.java b/src/main/java/com/sixteam/irs/service/UserService.java new file mode 100644 index 0000000..1153de9 --- /dev/null +++ b/src/main/java/com/sixteam/irs/service/UserService.java @@ -0,0 +1,19 @@ +package com.sixteam.irs.service; + +import com.sixteam.irs.model.User; + +import java.util.List; + +public interface UserService { + List findAllUser(); + + List findUserByName(User user); + + User findById(User user); + + int addUser(User user); + + int delUser(User user); + + int updateUser(User user); +} diff --git a/src/main/java/com/sixteam/irs/service/impl/EnterpriceServiceImpl.java b/src/main/java/com/sixteam/irs/service/impl/EnterpriceServiceImpl.java new file mode 100644 index 0000000..93ccb8e --- /dev/null +++ b/src/main/java/com/sixteam/irs/service/impl/EnterpriceServiceImpl.java @@ -0,0 +1,46 @@ +package com.sixteam.irs.service.impl; + +import com.sixteam.irs.mapper.EnterpriseMapper; +import com.sixteam.irs.model.Enterprise; +import com.sixteam.irs.service.EnterpriseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class EnterpriceServiceImpl implements EnterpriseService { + + @Autowired + private EnterpriseMapper enterpriseMapper; + + @Override + public List findAllEnterprise() { + return enterpriseMapper.findAllEnterprise(); + } + + @Override + public List findEnterpriseByName(Enterprise enterprise) { + return enterpriseMapper.findEnterpriseByName(enterprise); + } + + @Override + public Exception findById(Enterprise enterprise) { + return enterpriseMapper.findById(enterprise); + } + + @Override + public int addEnterprise(Enterprise enterprise) { + return enterpriseMapper.addEnterprise(enterprise); + } + + @Override + public int delEnterprise(Enterprise enterprise) { + return enterpriseMapper.delEnterprise(enterprise); + } + + @Override + public int updateEnterprise(Enterprise enterprise) { + return enterpriseMapper.updateEnterprise(enterprise); + } +} diff --git a/src/main/java/com/sixteam/irs/service/impl/UserServiceImpl.java b/src/main/java/com/sixteam/irs/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..c9b8907 --- /dev/null +++ b/src/main/java/com/sixteam/irs/service/impl/UserServiceImpl.java @@ -0,0 +1,50 @@ +package com.sixteam.irs.service.impl; + +import com.sixteam.irs.mapper.UserMapper; +import com.sixteam.irs.model.User; +import com.sixteam.irs.service.UserService; +import com.sixteam.irs.utils.UuidUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class UserServiceImpl implements UserService { + + @Autowired + private UserMapper userMapper; + + @Override + public List findAllUser() { + return userMapper.findAllUser(); + } + + @Override + public List findUserByName(User user) { + return userMapper.findUserByName(user); + } + + @Override + public User findById(User user) { + return userMapper.findById(user); + } + + @Override + public int addUser(User user) { + user.setUId(UuidUtils.uuid()); + return userMapper.addUser(user); + } + + @Override + public int delUser(User user) { + return userMapper.delUser(user); + } + + @Override + public int updateUser(User user) { + return userMapper.updateUser(user); + } + + +} diff --git a/src/main/java/com/sixteam/irs/utils/UuidUtils.java b/src/main/java/com/sixteam/irs/utils/UuidUtils.java new file mode 100644 index 0000000..6c3ecc9 --- /dev/null +++ b/src/main/java/com/sixteam/irs/utils/UuidUtils.java @@ -0,0 +1,9 @@ +package com.sixteam.irs.utils; + +import java.util.UUID; + +public class UuidUtils { + public static String uuid() { + return UUID.randomUUID().toString().replace("-", "").toUpperCase(); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d6e6325..1987399 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,9 +2,9 @@ server: port: 80 spring: datasource: - driver-class-name: com.mysql.jdbc.Driver - url: jdbc:mysql:/49.232.158.16;3306/irs?serverTimezone=UTC - username: irsadmin + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://49.232.158.16:3306/irs?serverTimezone=UTC + username: irsSHL password: 666 thymeleaf: @@ -16,6 +16,6 @@ spring: mybatis: configuration: map-underscore-to-camel-case: true - #շʽ + mapper-locations: classpath:mapper/*.xml type-aliases-package: com.sixteam.irs.entity diff --git a/src/main/resources/mapper/EnterpriseMapper.xml b/src/main/resources/mapper/EnterpriseMapper.xml new file mode 100644 index 0000000..3022fde --- /dev/null +++ b/src/main/resources/mapper/EnterpriseMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + insert into irs_enterprise (e_id,e_name,e_introduce,e_start,e_type,e_founder) + values (#{eId},#{eName},#{eIntroduce},#{eStart},#{eType},#{eFounder}) + + + + delete from irs_enterprise where e_id = #{eId} + + + + update irs_enterprise + + e_name = #{eName}, + e_introduce = #{eIntroduce}, + e_start = #{eStart}, + e_type = #{eType}, + e_founder = #{eFounder}, + + where eId = #{eId} + + + \ No newline at end of file diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..2355f5b --- /dev/null +++ b/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + insert into irs_user (u_id,u_name,u_eamil,u_phone,u_password,u_sex,u_birth_date) + values (#{uId},#{uName},#{uEmail},#{uPhone},#{uPassword},#{uSex},#{uBirthDate}); + + + + delete from irs_user where u_id = #{uId} + + + + update irs_user + + u_name = #{uName}, + u_eamil = #{uEmail}, + u_phone = #{uPhone}, + u_password = #{uPassword}, + u_sex = #{uSex}, + u_birth_date = #{uBirthDate}, + + where u_id = #{uId} + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..0587296 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,10 @@ + + + + + Title + + + 查询所有 + + \ No newline at end of file -- Gitee