This commit is contained in:
clay 2022-01-25 17:29:47 +08:00
parent 025468942b
commit e5482278e2
25 changed files with 499 additions and 0 deletions

33
.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
catalina.base_IS_UNDEFINED/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
.mvn
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpringJavaInjectionPointsAutowiringInspection" enabled="false" level="ERROR" enabled_by_default="false" />
</profile>
</component>

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -21,6 +21,11 @@
<artifactId>foodie-service</artifactId> <artifactId>foodie-service</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<properties> <properties>

View File

@ -2,6 +2,8 @@ package cn.odliken;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;
/** /**
* @author: Clay * @author: Clay
@ -12,6 +14,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* 启动类 * 启动类
*/ */
@SpringBootApplication @SpringBootApplication
// 扫描mybatis 通用mapper 所在的包
@MapperScan(basePackages = "cn.odliken.mapper")
//开启事务管理 可加可不加
//@EnableTransactionManagement
public class Application { public class Application {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -0,0 +1,53 @@
package cn.odliken.controller;
import cn.odliken.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author: Clay
* @date: 2022/1/25 17:05
* @descriptionPassprotController
* @email: clay@hchyun.com
*/
@RestController
@RequestMapping("/passport")
public class PassportController {
@Autowired
private UserService userService;
// RequestParam 请求类型参数
@GetMapping("/usernameIsExist")
public HttpStatus usernameIsExist(@RequestParam String username){
// 1. 判断入参是否为空
if (StringUtils.isBlank(username)){
return HttpStatus.INTERNAL_SERVER_ERROR;
}
//2. 查找注册的用户名是否存在
boolean isExist = userService.queryUSerNameIsExist(username);
if (isExist){
return HttpStatus.INTERNAL_SERVER_ERROR;
}
// 3. 请求成功,用户名可用
return HttpStatus.OK;
}
}

View File

@ -0,0 +1,46 @@
package cn.odliken.controller;
import cn.odliken.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.security.sasl.SaslServer;
/**
* @author: Clay
* @date: 2022/1/25 14:09
* @descriptionSruFooController
* @email: clay@hchyun.com
*/
@RestController
public class StuFooController {
@Autowired
private StuService stuService;
@GetMapping("/getStu")
public Object getStu(int id) {
return stuService.getStuInfo(id);
}
//无幂等性 再同一时间高并发下可能会新增多条数据
@PostMapping("/saveStu")
public Object saveStu() {
stuService.saveStu();
return 200;
}
// 通过id更新和删除是有幂等性的
@PostMapping("/updateStu")
public Object updateStu(int id) {
stuService.updateStu(id);
return 200;
}
@PostMapping("/deleteStu")
public Object deleteStu(int id) {
stuService.deleteStu(id);
return 200;
}
}

View File

@ -0,0 +1,19 @@
import cn.odliken.Application;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author: Clay
* @date: 2022/1/25 14:59
* @descriptionTransTest
* @email: clay@hchyun.com
*/
//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = Application.class)
public class TransTest {
}

View File

@ -1,2 +1,3 @@
cn\odliken\controller\PassportController.class
cn\odliken\Application.class cn\odliken\Application.class
cn\odliken\controller\HelloController.class cn\odliken\controller\HelloController.class

View File

@ -1,2 +1,4 @@
F:\架构师之路\project\foodie-dev\foodie-api\src\main\java\cn\odliken\controller\HelloController.java F:\架构师之路\project\foodie-dev\foodie-api\src\main\java\cn\odliken\controller\HelloController.java
F:\架构师之路\project\foodie-dev\foodie-api\src\main\java\cn\odliken\controller\StuFooController.java
F:\架构师之路\project\foodie-dev\foodie-api\src\main\java\cn\odliken\Application.java F:\架构师之路\project\foodie-dev\foodie-api\src\main\java\cn\odliken\Application.java
F:\架构师之路\project\foodie-dev\foodie-api\src\main\java\cn\odliken\controller\PassportController.java

View File

@ -0,0 +1,14 @@
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\ItemsSpecMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\OrderItemsMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\CarouselMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\OrderStatusMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\ItemsCommentsMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\ItemsImgMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\StuMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\UserAddressMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\OrdersMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\my\mapper\MyMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\ItemsParamMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\ItemsMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\UsersMapper.java
F:\架构师之路\project\foodie-dev\foodie-mapper\src\main\java\cn\odliken\mapper\CategoryMapper.java

View File

@ -0,0 +1,13 @@
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\OrderItems.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\Carousel.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\Category.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\Users.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\ItemsComments.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\ItemsSpec.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\UserAddress.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\Orders.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\Stu.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\ItemsImg.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\ItemsParam.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\OrderStatus.java
F:\架构师之路\project\foodie-dev\foodie-pojo\src\main\java\cn\odliken\pojo\Items.java

View File

@ -0,0 +1,25 @@
package cn.odliken.service;
import cn.odliken.pojo.Stu;
/**
* @author: Clay
* @date: 2022/1/25 14:05
* @descriptionStuService
* @email: clay@hchyun.com
*/
public interface StuService {
public Stu getStuInfo(int id);
public void saveStu();
public void updateStu(int id);
public void deleteStu(int id);
}

View File

@ -0,0 +1,20 @@
package cn.odliken.service;
import cn.odliken.pojo.Stu;
/**
* @author: Clay
* @date: 2022/1/25 14:05
* @descriptionStuService
* @email: clay@hchyun.com
*/
public interface UserService {
/**
* 判断用户名是否存在
* @param username
* @return
*/
public boolean queryUSerNameIsExist(String username);
}

View File

@ -0,0 +1,68 @@
package cn.odliken.service.impl;
import cn.odliken.mapper.StuMapper;
import cn.odliken.pojo.Stu;
import cn.odliken.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @author: Clay
* @date: 2022/1/25 14:07
* @descriptionStuServiceImpl
* @email: clay@hchyun.com
*/
@Service
public class StuServiceImpl implements StuService {
@Autowired
private StuMapper stuMapper;
/**
* 查询stu
*
* 只需要事务支持即可
* @param id
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public Stu getStuInfo(int id) {
return stuMapper.selectByPrimaryKey(id);
}
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void saveStu() {
Stu stu = new Stu();
stu.setName("cao");
stu.setAge(2000);
stuMapper.insert(stu);
}
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void updateStu(int id) {
Stu stu = new Stu();
stu.setName("cao");
stu.setAge(2000);
stu.setId(id);
stuMapper.selectByPrimaryKey(stu);
}
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void deleteStu(int id) {
Stu stu = new Stu();
stu.setName("cao");
stu.setAge(2000);
stu.setId(id);
stuMapper.deleteByPrimaryKey(stu);
}
}

View File

@ -0,0 +1,36 @@
package cn.odliken.service.impl;
import cn.odliken.mapper.StuMapper;
import cn.odliken.mapper.UsersMapper;
import cn.odliken.pojo.Stu;
import cn.odliken.pojo.Users;
import cn.odliken.service.StuService;
import cn.odliken.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
/**
* @author: Clay
* @date: 2022/1/25 14:07
* @descriptionStuServiceImpl
* @email: clay@hchyun.com
*/
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UsersMapper usersMapper;
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public boolean queryUSerNameIsExist(String username) {
Example userExample = new Example(Users.class);
Example.Criteria userCriteria = userExample.createCriteria();
userCriteria.andEqualTo("username",username);
Users result = usersMapper.selectOneByExample(userExample);
return result==null ? false : true;
}
}

View File

@ -0,0 +1,4 @@
F:\架构师之路\project\foodie-dev\foodie-service\src\main\java\cn\odliken\service\impl\UserServiceImpl.java
F:\架构师之路\project\foodie-dev\foodie-service\src\main\java\cn\odliken\service\impl\StuServiceImpl.java
F:\架构师之路\project\foodie-dev\foodie-service\src\main\java\cn\odliken\service\UserService.java
F:\架构师之路\project\foodie-dev\foodie-service\src\main\java\cn\odliken\service\StuService.java

17
pom.xml
View File

@ -65,6 +65,23 @@
<version>2.1.5</version> <version>2.1.5</version>
</dependency> </dependency>
<!--apache工具类 -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies> </dependencies>