增删改查
parent
7280a8c5f3
commit
a921f6e5f5
|
@ -8,9 +8,5 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="MavenRunner">
|
||||
<option name="delegateBuildToMaven" value="true" />
|
||||
<option name="jreName" value="1.8" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -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<Role> 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);
|
||||
}
|
||||
}
|
|
@ -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<User> selectAll(){
|
||||
return userService.selectAll();
|
||||
}
|
||||
@PostMapping("/updateByPrimaryKey")
|
||||
public Integer updateByPrimaryKey(@RequestBody User row){
|
||||
return userService.updateByPrimaryKey(row);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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<Role> selectAll();
|
||||
|
||||
int updateByPrimaryKey(Role row);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Role> selectAll();
|
||||
|
||||
|
||||
Role selectByPrimaryKey(Integer id);
|
||||
|
||||
Integer insert(Role row);
|
||||
|
||||
Integer deleteByPrimaryKey(Integer id);
|
||||
|
||||
Integer updateByPrimaryKey(Role row);
|
||||
}
|
|
@ -10,5 +10,14 @@ public interface UserService {
|
|||
List<User> getAllUser();
|
||||
|
||||
|
||||
User selectByPrimaryKey(Integer id);
|
||||
|
||||
Integer insert(User row);
|
||||
|
||||
Integer deleteByPrimaryKey(Integer id);
|
||||
|
||||
List<User> selectAll();
|
||||
|
||||
|
||||
Integer updateByPrimaryKey(User row);
|
||||
}
|
||||
|
|
|
@ -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<Role> 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);
|
||||
}
|
||||
}
|
|
@ -30,11 +30,39 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
@Override
|
||||
public List<User> 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<User> selectAll() {
|
||||
|
||||
return userMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateByPrimaryKey(User row) {
|
||||
|
||||
return userMapper.updateByPrimaryKey(row);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?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.bbyb.operating.examination.mapper.RoleMapper">
|
||||
<insert id="insert">
|
||||
INSERT INTO roles (roleCode, roleName, createBy, createTime, updateBy, updateTime, invalid)
|
||||
VALUES (#{roleCode}, #{roleName}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{invalid});
|
||||
</insert>
|
||||
<update id="updateByPrimaryKey">
|
||||
UPDATE roles
|
||||
SET roleCode = #{roleCode},
|
||||
roleName = #{roleName},
|
||||
createBy = #{createBy},
|
||||
createTime = #{createTime},
|
||||
updateBy = #{updateBy},
|
||||
updateTime = #{updateTime},
|
||||
invalid = #{invalid}
|
||||
WHERE id = #{id};
|
||||
</update>
|
||||
<delete id="deleteByPrimaryKey">
|
||||
DELETE FROM user WHERE id = #{id};
|
||||
</delete>
|
||||
|
||||
<select id="selectAll" resultType="com.bbyb.operating.examination.model.po.Role">
|
||||
select *
|
||||
from role;
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" resultType="com.bbyb.operating.examination.model.po.Role">
|
||||
SELECT * FROM role WHERE id = #{id};
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,26 @@
|
|||
<?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.bbyb.operating.examination.mapper.UserMapper">
|
||||
<insert id="insert">
|
||||
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});
|
||||
</insert>
|
||||
<update id="updateByPrimaryKey">
|
||||
UPDATE user
|
||||
SET userName = #{userName}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByPrimaryKey">
|
||||
DELETE FROM user WHERE id = #{id};
|
||||
</delete>
|
||||
<select id="selectByPrimaryKey" resultType="com.bbyb.operating.examination.model.po.User">
|
||||
SELECT * FROM user WHERE id = #{id};
|
||||
</select>
|
||||
<select id="selectAll" resultType="com.bbyb.operating.examination.model.po.User">
|
||||
select *
|
||||
from user;
|
||||
</select>
|
||||
</mapper>
|
Binary file not shown.
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue