master
bseayin 2019-09-07 15:48:20 +08:00
parent 8d106ae0f9
commit 5247009c06
15 changed files with 388 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package com.zz;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* --run as application mainspringboot
SpringBoot tomcat main tomcat
* @author jiyu
*
*/
@SpringBootApplication
@MapperScan("com.zz.mapper")
public class App {
public static void main(String[] args) {
// TODO Auto-generated method stub
SpringApplication.run(App.class, args);
}
}

View File

@ -0,0 +1,52 @@
package com.zz.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.zz.util.KeyUtil;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zz.entity.User;
import com.zz.service.UserService;
@RestController
@RequestMapping("user")
public class UserController {
@Resource
UserService userService;
@RequestMapping("add/{name}/{pwd}")
public User add(@PathVariable("name") String uname,@PathVariable("pwd") String pwd){
User user=new User();
user.setPasswd(pwd);
user.setUsername(uname);
user.setId(KeyUtil.genUniqueKey());
userService.add(user);
return user;
}
@RequestMapping("show/{id}")
public User getById(@PathVariable("id") String id){
return userService.selectByPrimaryKey(id);
}
@RequestMapping("showall")
public List<User> getall(){
return userService.selectAll();
}
@RequestMapping("showbyname/{name}")
public User getByName(@PathVariable("name") String name){
return userService.selectByName(name);
}
}

View File

@ -0,0 +1,33 @@
package com.zz.entity;
public class Permission {
private String id;
private String name;
private String url;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url == null ? null : url.trim();
}
}

View File

@ -0,0 +1,33 @@
package com.zz.entity;
public class Role {
private String id;
private String detail;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail == null ? null : detail.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
}

View File

@ -0,0 +1,23 @@
package com.zz.entity;
public class RolePermissionKey {
private String rId;
private String pId;
public String getrId() {
return rId;
}
public void setrId(String rId) {
this.rId = rId == null ? null : rId.trim();
}
public String getpId() {
return pId;
}
public void setpId(String pId) {
this.pId = pId == null ? null : pId.trim();
}
}

View File

@ -0,0 +1,55 @@
package com.zz.entity;
import java.util.Date;
public class User {
private String id;
private Date createTime;
private String passwd;
private String status;
private String username;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd == null ? null : passwd.trim();
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username == null ? null : username.trim();
}
}

View File

@ -0,0 +1,23 @@
package com.zz.entity;
public class UserRoleKey {
private String uId;
private String rId;
public String getuId() {
return uId;
}
public void setuId(String uId) {
this.uId = uId == null ? null : uId.trim();
}
public String getrId() {
return rId;
}
public void setrId(String rId) {
this.rId = rId == null ? null : rId.trim();
}
}

View File

@ -0,0 +1,17 @@
package com.zz.mapper;
import com.zz.entity.Permission;
public interface PermissionMapper {
int deleteByPrimaryKey(String id);
int insert(Permission record);
int insertSelective(Permission record);
Permission selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(Permission record);
int updateByPrimaryKey(Permission record);
}

View File

@ -0,0 +1,17 @@
package com.zz.mapper;
import com.zz.entity.Role;
public interface RoleMapper {
int deleteByPrimaryKey(String id);
int insert(Role record);
int insertSelective(Role record);
Role selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(Role record);
int updateByPrimaryKey(Role record);
}

View File

@ -0,0 +1,11 @@
package com.zz.mapper;
import com.zz.entity.RolePermissionKey;
public interface RolePermissionMapper {
int deleteByPrimaryKey(RolePermissionKey key);
int insert(RolePermissionKey record);
int insertSelective(RolePermissionKey record);
}

View File

@ -0,0 +1,43 @@
package com.zz.mapper;
import com.zz.entity.User;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface UserMapper {
int deleteByPrimaryKey(String id);
int insert(User record);
int insertSelective(User record);
User selectByPrimaryKey(String id);
List<User> selectAll();
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
@Select("select * from t_user where username=#{name}")
User selectByName(String name);
/**
* @Insert("insert into student(sno,sname,ssex) values(#{sno},#{name},#{sex})")
* int add(Student student);
*
* @Update("update student set sname=#{name},ssex=#{sex} where sno=#{sno}")
* int update(Student student);
*
* @Delete("delete from student where sno=#{sno}")
* int deleteBysno(String sno);
*
* @Select("select * from student where sno=#{sno}")
* @Results(id = "student",value= {
* @Result(property = "sno", column = "sno", javaType = String.class),
* @Result(property = "name", column = "sname", javaType = String.class),
* @Result(property = "sex", column = "ssex", javaType = String.class)
* })
* Student queryStudentBySno(String sno);
*/
}

View File

@ -0,0 +1,11 @@
package com.zz.mapper;
import com.zz.entity.UserRoleKey;
public interface UserRoleMapper {
int deleteByPrimaryKey(UserRoleKey key);
int insert(UserRoleKey record);
int insertSelective(UserRoleKey record);
}

View File

@ -0,0 +1,31 @@
package com.zz.service;
import com.zz.entity.User;
import com.zz.mapper.UserMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class UserService {
@Resource
UserMapper userMapper;
public int add(User user){
return userMapper.insert(user);
}
public User selectByPrimaryKey(String id){
return userMapper.selectByPrimaryKey(id);
};
public List<User> selectAll(){
return userMapper.selectAll();
};
public User selectByName(String name){
return userMapper.selectByName(name);
};
}

View File

@ -0,0 +1,10 @@
server.port=9018
server.servlet.context-path=/mybatisdemo
spring.datasource.url = jdbc:mysql://localhost:3306/java10?useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username = root
spring.datasource.password = Java20190713*yy
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
mybatis.typeAliasesPackage=org.spring.springboot.domain
#mybatis.mapperLocations=classpath:com/zz/mapping/*.xml,com/zz/EDGE/mapping/*.xml,com/zz/jwh/mapping/*.xml,com/zz/hc/mapping/*.xml,com/zz/simpleSpade/mapping/*.xml,com/zz/lsw/mapping/*.xml,com/zz/wsq/mapping/*.xml,com/zz/zcj/mapping/*.xml
mybatis.mapperLocations=classpath:mapping/*.xml

View File

@ -17,6 +17,13 @@
from t_user from t_user
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</select> </select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_user
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from t_user delete from t_user
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}