diff --git a/.idea/misc.xml b/.idea/misc.xml index 8bb4a3e..67e1e61 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,9 +8,5 @@ - - \ No newline at end of file diff --git a/src/main/java/com/bbyb/operating/examination/controller/RoleUserMapper.java b/src/main/java/com/bbyb/operating/examination/controller/RoleUserMapper.java new file mode 100644 index 0000000..9a7c6ab --- /dev/null +++ b/src/main/java/com/bbyb/operating/examination/controller/RoleUserMapper.java @@ -0,0 +1,41 @@ +package com.bbyb.operating.examination.controller; + +import com.bbyb.operating.examination.model.po.Role; +import com.bbyb.operating.examination.service.RoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController() +public class RoleUserMapper { + @Autowired + RoleService roleService; + + @PostMapping("/selectAll") + public List selectAll() { + return roleService.selectAll(); + } + + @PostMapping("/selectByPrimaryKey") + public Role selectByPrimaryKey(@RequestParam("id") Integer id) { + return roleService.selectByPrimaryKey(id); + } + + @PostMapping("/insert") + public Integer insert(@RequestParam("row") Role row) { + return roleService.insert(row); + } + + @PostMapping("/deleteByPrimaryKey") + public Integer deleteByPrimaryKey(@RequestParam("id") Integer id) { + return roleService.deleteByPrimaryKey(id); + } + + @PostMapping("/updateByPrimaryKey") + public Integer updateByPrimaryKey(@RequestParam("row") Role row) { + return roleService.updateByPrimaryKey(row); + } +} diff --git a/src/main/java/com/bbyb/operating/examination/controller/UserController.java b/src/main/java/com/bbyb/operating/examination/controller/UserController.java index 701042d..5bcad52 100644 --- a/src/main/java/com/bbyb/operating/examination/controller/UserController.java +++ b/src/main/java/com/bbyb/operating/examination/controller/UserController.java @@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.xml.transform.Result; import java.util.List; /** @@ -58,6 +59,29 @@ public class UserController { return userService.getAllUser(); } + @PostMapping("/selectByPrimaryKey") + public User selectByPrimaryKey(@RequestParam("id") Integer id){ + return userService.selectByPrimaryKey(id); + } + + @PostMapping("/insert") + public Integer insert(@RequestBody User row){ + return userService.insert(row); + } + + @PostMapping("/deleteByPrimaryKey") + public Integer deleteByPrimaryKey(@RequestParam("id") Integer id){ + return userService.deleteByPrimaryKey(id); + } + + @PostMapping("/selectAll") + public List selectAll(){ + return userService.selectAll(); + } + @PostMapping("/updateByPrimaryKey") + public Integer updateByPrimaryKey(@RequestBody User row){ + return userService.updateByPrimaryKey(row); + } diff --git a/src/main/java/com/bbyb/operating/examination/mapper/RoleMapper.java b/src/main/java/com/bbyb/operating/examination/mapper/RoleMapper.java index fc558b2..d5c531f 100644 --- a/src/main/java/com/bbyb/operating/examination/mapper/RoleMapper.java +++ b/src/main/java/com/bbyb/operating/examination/mapper/RoleMapper.java @@ -1,8 +1,10 @@ package com.bbyb.operating.examination.mapper; import com.bbyb.operating.examination.model.po.Role; -import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import java.util.List; +@Mapper public interface RoleMapper { int deleteByPrimaryKey(Integer id); @@ -13,4 +15,4 @@ public interface RoleMapper { List selectAll(); int updateByPrimaryKey(Role row); -} \ No newline at end of file +} diff --git a/src/main/java/com/bbyb/operating/examination/service/RoleService.java b/src/main/java/com/bbyb/operating/examination/service/RoleService.java new file mode 100644 index 0000000..4c20659 --- /dev/null +++ b/src/main/java/com/bbyb/operating/examination/service/RoleService.java @@ -0,0 +1,18 @@ +package com.bbyb.operating.examination.service; + +import com.bbyb.operating.examination.model.po.Role; + +import java.util.List; + +public interface RoleService { + List selectAll(); + + + Role selectByPrimaryKey(Integer id); + + Integer insert(Role row); + + Integer deleteByPrimaryKey(Integer id); + + Integer updateByPrimaryKey(Role row); +} diff --git a/src/main/java/com/bbyb/operating/examination/service/UserService.java b/src/main/java/com/bbyb/operating/examination/service/UserService.java index aa87ded..b44e5a7 100644 --- a/src/main/java/com/bbyb/operating/examination/service/UserService.java +++ b/src/main/java/com/bbyb/operating/examination/service/UserService.java @@ -10,5 +10,14 @@ public interface UserService { List getAllUser(); + User selectByPrimaryKey(Integer id); + Integer insert(User row); + + Integer deleteByPrimaryKey(Integer id); + + List selectAll(); + + + Integer updateByPrimaryKey(User row); } diff --git a/src/main/java/com/bbyb/operating/examination/service/impl/RoleServiceImpl.java b/src/main/java/com/bbyb/operating/examination/service/impl/RoleServiceImpl.java new file mode 100644 index 0000000..963dcd5 --- /dev/null +++ b/src/main/java/com/bbyb/operating/examination/service/impl/RoleServiceImpl.java @@ -0,0 +1,42 @@ +package com.bbyb.operating.examination.service.impl; + +import com.bbyb.operating.examination.mapper.RoleMapper; +import com.bbyb.operating.examination.model.po.Role; +import com.bbyb.operating.examination.service.RoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class RoleServiceImpl implements RoleService { + @Autowired + RoleMapper roleMapper; + + + @Override + public List selectAll() { + return roleMapper.selectAll(); + } + + @Override + public Role selectByPrimaryKey(Integer id) { + + return roleMapper.selectByPrimaryKey(id); + } + + @Override + public Integer insert(Role row) { + return roleMapper.insert(row); + } + + @Override + public Integer deleteByPrimaryKey(Integer id) { + return roleMapper.deleteByPrimaryKey(id); + } + + @Override + public Integer updateByPrimaryKey(Role row) { + return roleMapper.updateByPrimaryKey(row); + } +} diff --git a/src/main/java/com/bbyb/operating/examination/service/impl/UserServiceImpl.java b/src/main/java/com/bbyb/operating/examination/service/impl/UserServiceImpl.java index 7278c60..9e265fe 100644 --- a/src/main/java/com/bbyb/operating/examination/service/impl/UserServiceImpl.java +++ b/src/main/java/com/bbyb/operating/examination/service/impl/UserServiceImpl.java @@ -30,11 +30,39 @@ public class UserServiceImpl implements UserService { @Override public List getAllUser() { + return userMapper.selectAll(); } + @Override + public User selectByPrimaryKey(Integer id) { + return userMapper.selectByPrimaryKey(id); + } + @Override + public Integer insert(User row) { + + return userMapper.insert(row); + } + + @Override + public Integer deleteByPrimaryKey(Integer id) { + + return userMapper.deleteByPrimaryKey(id); + } + + @Override + public List selectAll() { + + return userMapper.selectAll(); + } + + @Override + public Integer updateByPrimaryKey(User row) { + + return userMapper.updateByPrimaryKey(row); + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ef89a16..911cd5d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,7 +4,7 @@ spring.datasource.url=jdbc:mysql://127.0.0.1:3306/bbyb_examination spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username =root spring.datasource.password =123456A -logging.level.root=debug +logging.level.root=info logging.level.org.springframework.boot.autoconfigure=error mybatis.mapper-locations=classpath*:/mapper/**/*.xml diff --git a/src/main/resources/mapper/RoleMapper.xml b/src/main/resources/mapper/RoleMapper.xml new file mode 100644 index 0000000..30a82b8 --- /dev/null +++ b/src/main/resources/mapper/RoleMapper.xml @@ -0,0 +1,32 @@ + + + + + INSERT INTO roles (roleCode, roleName, createBy, createTime, updateBy, updateTime, invalid) + VALUES (#{roleCode}, #{roleName}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{invalid}); + + + UPDATE roles + SET roleCode = #{roleCode}, + roleName = #{roleName}, + createBy = #{createBy}, + createTime = #{createTime}, + updateBy = #{updateBy}, + updateTime = #{updateTime}, + invalid = #{invalid} + WHERE id = #{id}; + + + DELETE FROM user WHERE id = #{id}; + + + + + diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..1f0e33c --- /dev/null +++ b/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,26 @@ + + + + + INSERT INTO user_table (userCode, userName, phone, password, email, idCard, gender, isAdmin, isEnable, createBy, createTime, updateBy, updateTime, invalid) + VALUES (#{userCode}, #{userName}, #{phone}, #{password}, #{email}, #{idCard}, #{gender}, #{isAdmin}, #{isEnable}, #{createBy}, CURRENT_TIMESTAMP, #{updateTime}, CURRENT_TIMESTAMP, #{invalid}); + + + UPDATE user + SET userName = #{userName} + WHERE id = #{id} + + + + DELETE FROM user WHERE id = #{id}; + + + + diff --git a/target/bbyb-examination-0.0.1-SNAPSHOT.jar b/target/bbyb-examination-0.0.1-SNAPSHOT.jar index 535488a..152a97d 100644 Binary files a/target/bbyb-examination-0.0.1-SNAPSHOT.jar and b/target/bbyb-examination-0.0.1-SNAPSHOT.jar differ diff --git a/target/classes/application.properties b/target/classes/application.properties index ef89a16..911cd5d 100644 --- a/target/classes/application.properties +++ b/target/classes/application.properties @@ -4,7 +4,7 @@ spring.datasource.url=jdbc:mysql://127.0.0.1:3306/bbyb_examination spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username =root spring.datasource.password =123456A -logging.level.root=debug +logging.level.root=info logging.level.org.springframework.boot.autoconfigure=error mybatis.mapper-locations=classpath*:/mapper/**/*.xml