Commit 65e62a07 authored by Administrator's avatar Administrator

Merge branch 'dev' of http://121.22.111.250:8000/zhangyusheng/YX_IDENT_REFACTORING into dev

# Conflicts:
#	src/main/java/com/yxproject/start/Main.java
#	src/main/java/com/yxproject/start/api/UserInfoApi.java
#	src/main/java/com/yxproject/start/config/MyShiroRealm.java
#	src/main/resources/application.properties
#	src/main/resources/mapper/SysPermissionMapper.xml
#	src/main/resources/mapper/SystemUserMapper.xml
parents 4749c5fa 8107cedb
...@@ -91,6 +91,16 @@ ...@@ -91,6 +91,16 @@
<version>2.0.0</version> <version>2.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies> </dependencies>
......
package com.yxproject.start; package com.yxproject.start;
//import com.yxproject.start.config.JerseyConfig; import com.yxproject.start.config.JerseyConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.glassfish.jersey.servlet.ServletProperties;
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.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
/** /**
* @author Administrator * @author Administrator
...@@ -12,13 +17,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -12,13 +17,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class Main{ public class Main{
// @Bean @Bean
// public ServletRegistrationBean jerseyServlet() { public ServletRegistrationBean jerseyServlet() {
// ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/rest/*"); ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/rest/*");
// registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS,
// JerseyConfig.class.getName()); JerseyConfig.class.getName());
// return registration; return registration;
// } }
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Main.class, args); SpringApplication.run(Main.class, args);
......
...@@ -24,11 +24,6 @@ public class ShiroApi { ...@@ -24,11 +24,6 @@ public class ShiroApi {
//获取到用户信息; //获取到用户信息;
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
UserInfo ui = (UserInfo) subject.getPrincipal(); UserInfo ui = (UserInfo) subject.getPrincipal();
for(SysRole role:ui.getRoleList()){
for(SysPermission memu:role.getPermissions()){
System.out.println(memu.getPermission()+","+memu.getUrl());
}
}
map.put("userInfo",ui); map.put("userInfo",ui);
return "/index"; return "/index";
} }
...@@ -61,12 +56,35 @@ public class ShiroApi { ...@@ -61,12 +56,35 @@ public class ShiroApi {
return "/login"; return "/login";
} }
/**
* 角色添加;
* @return
*/
@RequestMapping("/roleAdd")
@RequiresPermissions("role.add")//权限管理;
public String roleAdd(Map<String,Object> map){
Subject subject = SecurityUtils.getSubject();
UserInfo ui = (UserInfo) subject.getPrincipal();
map.put("userInfo",ui);
return "roleAdd";
}
/**
* 权限添加;
* @return
*/
@RequestMapping("/permissionAdd")
@RequiresPermissions("permission.add")//权限管理;
public String permissionAdd(){
return "permissionAdd";
}
/** /**
* 用户添加; * 用户添加;
* @return * @return
*/ */
@RequestMapping("/userAdd") @RequestMapping("/userAdd")
@RequiresPermissions("userInfo.del")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
public String userInfoAdd(){ public String userInfoAdd(){
return "userInfoAdd"; return "userInfoAdd";
} }
......
package com.yxproject.start.api; package com.yxproject.start.api;
import com.yxproject.start.entity.SysPermission; import com.yxproject.start.entity.SysPermission;
import com.yxproject.start.entity.SysRole;
import com.yxproject.start.entity.UserInfo; import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.service.ProductionTaskListService; import com.yxproject.start.service.ProductionTaskListService;
import com.yxproject.start.service.SysPermissionService; import com.yxproject.start.service.SysPermissionService;
import com.yxproject.start.service.SysRoleService;
import com.yxproject.start.service.UserInfoService; import com.yxproject.start.service.UserInfoService;
import com.yxproject.start.service.impl.UserInfoServiceImpl; import com.yxproject.start.service.impl.UserInfoServiceImpl;
import com.yxproject.start.utils.Md5Utils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException; import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException; import org.apache.shiro.authc.UnknownAccountException;
...@@ -14,101 +17,109 @@ import org.apache.shiro.authz.Permission; ...@@ -14,101 +17,109 @@ import org.apache.shiro.authz.Permission;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.HashMap; import java.util.*;
import java.util.LinkedHashMap;
import java.util.Map;
@Controller
/** /**
* @author Administrator * @author Administrator
*/ */
@Controller
public class UserInfoApi { public class UserInfoApi {
@Autowired @Autowired
private SysPermissionService sysPermissionService; private SysPermissionService sysPermissionService;
@Autowired @Autowired
private ProductionTaskListService productionTaskListService; private UserInfoService userInfoService;
@Autowired
private SysRoleService sysRoleService;
// @RequestMapping("login")
// @Produces(MediaType.APPLICATION_JSON) @Autowired
// public Map<String, Object> submitLogin(@QueryParam("username") String username, @QueryParam("password") String password) { private ProductionTaskListService productionTaskListService;
// Map<String, Object> resultMap = new LinkedHashMap<String, Object>(); @RequestMapping("login")
// Subject currentUser = SecurityUtils.getSubject(); @Produces(MediaType.APPLICATION_JSON)
// public Map<String, Object> submitLogin(@QueryParam("username") String username, @QueryParam("password") String password) {
// // 把用户名和密码封装为 UsernamePasswordToken 对象 Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
// UsernamePasswordToken token = new UsernamePasswordToken(username, password); Subject currentUser = SecurityUtils.getSubject();
// try {
// currentUser.login(token); // 把用户名和密码封装为 UsernamePasswordToken 对象
// resultMap.put("status", 200); UsernamePasswordToken token = new UsernamePasswordToken(username, password);
// resultMap.put("message", "登录成功"); try {
// } catch (UnknownAccountException e) { currentUser.login(token);
// resultMap.put("status", 500); resultMap.put("status", 200);
// resultMap.put("message", "账号不存在!"); resultMap.put("message", "登录成功");
// }catch(IncorrectCredentialsException e1){ } catch (UnknownAccountException e) {
// resultMap.put("status", 501); resultMap.put("status", 500);
// resultMap.put("message", "密码错误!"); resultMap.put("message", "账号不存在!");
// }catch (Exception e) { }catch(IncorrectCredentialsException e1){
// resultMap.put("status", 500); resultMap.put("status", 501);
// resultMap.put("message", "账号不存在"); resultMap.put("message", "密码错误!");
// } }catch (Exception e) {
// resultMap.put("status", 500);
// return resultMap; resultMap.put("message", "账号不存在");
// } }
return resultMap;
}
@RequestMapping(value="/permissionAdd",method= RequestMethod.POST) @RequestMapping(value="/permissionAdd",method= RequestMethod.POST)
@RequiresPermissions("userInfo.add") @RequiresPermissions("permission.add")
@ResponseBody @ResponseBody
public String userAdd(@ModelAttribute SysPermission sysPermission) { public Map<String, String> userAdd(@ModelAttribute SysPermission sysPermission) {
Map<String,String> map = new HashMap<>();
// Map<String, Object> resultMap = new HashMap<String, Object>(); boolean flag = false;
// String name = sysPermission.getName(); flag = sysPermissionService.addPermission(sysPermission);
// String resourceType = sysPermission.getResourceType(); if (flag){
// String url = sysPermission.getUrl(); map.put("resultMsg","添加成功");
// String permission =sysPermission.getPermission();
// long parentId = sysPermission.getParentId(); }else {
// String parentIds = sysPermission.getParentIds(); map.put("resultMsg","添加失败");
// resultMap.put("id",4); }
// resultMap.put("name",name); return map;
// resultMap.put("resourceType",resourceType);
// resultMap.put("url",url);
// resultMap.put("permission",permission);
// resultMap.put("parentId",parentId);
// resultMap.put("parentIds",parentIds);
// resultMap.put("available",false);
// System.out.println(resultMap.toString());
System.out.println("?????");
sysPermissionService.addPermission(sysPermission);
return "yes";
} }
// /** /**
// * 用户添加; * 用户添加;
// * @return * @return
// */ */
// @RequestMapping(value = "/userAdd",method = RequestMethod.POST) @RequestMapping(value = "/userInfoAdd",method = RequestMethod.POST)
// @RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")
// public String userInfoAdd(@QueryParam("username") String username, @QueryParam("password") String password){ @ResponseBody
// System.out.println("username------"+username+" -----password-----"+password); public Map<String, String> userInfoAdd(@ModelAttribute UserInfo userInfo){
// UserInfoService systemUserService = new UserInfoServiceImpl(); String pwd = userInfo.getPassword();
// int i = systemUserService.addUsername(new UserInfo()); String salt = UUID.randomUUID().toString();
//// int i = 0; userInfo.setPassword(Md5Utils.entryptPassword(pwd,salt));
// System.out.println(i+"------返回值"); userInfo.setSalt(salt);
// return i+"userInfoAdd"; Map<String,String> map = new HashMap<>();
// } System.out.println(userInfo.getUsername());
// System.out.println(userInfo.getPassword());
System.out.println(userInfo.getSalt());
boolean flag = false;
flag = userInfoService.addUser(userInfo);
if (flag){
map.put("resultMsg","添加成功");
}else {
map.put("resultMsg","添加失败");
}
return map;
}
// /** // /**
// * 用户删除; // * 用户删除;
// * @return // * @return
...@@ -139,6 +150,25 @@ public class UserInfoApi { ...@@ -139,6 +150,25 @@ public class UserInfoApi {
// return i+"userInfoAdd"; // return i+"userInfoAdd";
// } // }
@RequestMapping(value="/roleInfoAdd",method= RequestMethod.POST)
@RequiresPermissions("role.add")
@ResponseBody
public Map<String, String> roleAdd(@ModelAttribute SysRole sysRole) {
Map<String,String> map = new HashMap<>();
boolean flag = false;
flag = sysRoleService.addRole(sysRole);
System.out.println(sysRole.getId());
if (flag){
map.put("resultMsg","添加成功");
}else {
map.put("resultMsg","添加失败");
}
return map;
}
/** /**
* 查询任务单; * 查询任务单;
* @return * @return
......
//package com.yxproject.start.config; package com.yxproject.start.config;
//
//import com.yxproject.start.api.UserInfoApi; import com.yxproject.start.api.UserInfoApi;
//import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
//
//public class JerseyConfig extends ResourceConfig { public class JerseyConfig extends ResourceConfig {
// public JerseyConfig() { public JerseyConfig() {
// register(UserInfoApi.class); register(UserInfoApi.class);
// } }
//} }
...@@ -5,6 +5,7 @@ import com.yxproject.start.entity.SysPermission; ...@@ -5,6 +5,7 @@ import com.yxproject.start.entity.SysPermission;
import com.yxproject.start.entity.SysRole; import com.yxproject.start.entity.SysRole;
import com.yxproject.start.entity.UserInfo; import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.service.ProductionTaskListService; import com.yxproject.start.service.ProductionTaskListService;
import com.yxproject.start.service.LoginService;
import com.yxproject.start.service.UserInfoService; import com.yxproject.start.service.UserInfoService;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationInfo;
...@@ -14,6 +15,7 @@ import org.apache.shiro.authz.AuthorizationInfo; ...@@ -14,6 +15,7 @@ import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection; import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -28,6 +30,7 @@ public class MyShiroRealm extends AuthorizingRealm { ...@@ -28,6 +30,7 @@ public class MyShiroRealm extends AuthorizingRealm {
@Autowired @Autowired
private ProductionTaskListService productionTaskListService; private ProductionTaskListService productionTaskListService;
private LoginService loginService;
@Override @Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
System.out.println(principals.getPrimaryPrincipal()); System.out.println(principals.getPrimaryPrincipal());
...@@ -59,20 +62,17 @@ public class MyShiroRealm extends AuthorizingRealm { ...@@ -59,20 +62,17 @@ public class MyShiroRealm extends AuthorizingRealm {
System.out.println(token.getCredentials().toString()); System.out.println(token.getCredentials().toString());
//通过username从数据库中查找 User对象,如果找到,没找到. //通过username从数据库中查找 User对象,如果找到,没找到.
//实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法 //实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法
UserInfo user = userInfoService.findByUsername(username); UserInfo user = loginService.findByUsername(username);
if(user == null){ if(user == null){
return null; return null;
} }
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
user, user,
user.getPassword(), user.getPassword(),
ByteSource.Util.bytes(user.getSalt()),
getName() getName()
); );
return authenticationInfo; return authenticationInfo;
} }
public ProductionTaskListEntity getProductionTaskListByID(String ID){
return productionTaskListService.findProductionTaskListEntityByID(ID);
}
} }
\ No newline at end of file
...@@ -71,7 +71,7 @@ public class ShiroConfig { ...@@ -71,7 +71,7 @@ public class ShiroConfig {
//散列算法:这里使用MD5算法; //散列算法:这里使用MD5算法;
hashedCredentialsMatcher.setHashAlgorithmName("md5"); hashedCredentialsMatcher.setHashAlgorithmName("md5");
//散列的次数,比如散列两次,相当于 md5(""); //散列的次数,比如散列两次,相当于 md5("");
hashedCredentialsMatcher.setHashIterations(1); hashedCredentialsMatcher.setHashIterations(1024);
return hashedCredentialsMatcher; return hashedCredentialsMatcher;
} }
......
...@@ -4,24 +4,41 @@ import javax.persistence.*; ...@@ -4,24 +4,41 @@ import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
/**
* @author liboyang
*/
@Entity @Entity
@Table(name="SYS_PERMISSION")
public class SysPermission implements Serializable { public class SysPermission implements Serializable {
@Id @Id
@GeneratedValue @GeneratedValue(strategy = GenerationType.IDENTITY)
//主键. /**
* 主键.
*/
private Integer id; private Integer id;
//名称. /**
* 名称.
*/
private String name; private String name;
@Column(columnDefinition="enum('menu','button')") /**
//资源类型,[menu|button] * 资源类型
*/
private String resourceType; private String resourceType;
//资源路径. /**
* 资源路径.
*/
private String url; private String url;
//权限字符串,menu例子:role:*,button例子:role:create,role:update,role:delete,role:view /**
* 权限字符串,menu例子:role:*,button例子:role:create,role:update,role:delete,role:view
*/
private String permission; private String permission;
//父编号 /**
* 父编号
*/
private Long parentId; private Long parentId;
//父编号列表 /**
* 父编号列表
*/
private String parentIds; private String parentIds;
private Boolean available = Boolean.FALSE; private Boolean available = Boolean.FALSE;
@ManyToMany @ManyToMany
......
...@@ -3,24 +3,49 @@ package com.yxproject.start.entity; ...@@ -3,24 +3,49 @@ package com.yxproject.start.entity;
import javax.persistence.*; import javax.persistence.*;
import java.util.List; import java.util.List;
/**
* @author liboyang
*/
@Entity @Entity
@Table(name="SYS_ROLE")
public class SysRole { public class SysRole {
@Id @Id
@GeneratedValue @GeneratedValue
private Integer id; // 编号 /**
private String role; // 角色标识程序中判断使用,如"admin",这个是唯一的: * 编号
private String description; // 角色描述,UI界面显示使用 */
private Boolean available = Boolean.FALSE; // 是否可用,如果不可用将不会添加给用户 private Integer id;
/**
//角色 -- 权限关系:多对多关系; * 角色标识程序中判断使用,如"admin",这个是唯一的:
*/
private String role;
/**
* 角色描述,UI界面显示使用
*/
private String description;
/**
* 是否可用,如果不可用将不会添加给用户
*/
private Boolean available = Boolean.FALSE;
/**
* 角色 -- 权限关系:多对多关系;
*/
@ManyToMany(fetch= FetchType.EAGER) @ManyToMany(fetch= FetchType.EAGER)
@JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="permissionId")}) @JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="permissionId")})
private List<SysPermission> permissions; private List<SysPermission> permissions;
// 用户 - 角色关系定义; /**
* 用户 - 角色关系定义;
*/
@ManyToMany @ManyToMany
@JoinTable(name="SysUserRole",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="uId")}) @JoinTable(name="SysUserRole",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="userId")})
private List<UserInfo> userInfos;// 一个角色对应多个用户 /**
* 一个角色对应多个用户
*/
private List<UserInfo> userInfos;
public Integer getId() { public Integer getId() {
return id; return id;
...@@ -46,7 +71,7 @@ public class SysRole { ...@@ -46,7 +71,7 @@ public class SysRole {
this.description = description; this.description = description;
} }
public Boolean getAvailable() { public Boolean getAvailable(boolean b) {
return available; return available;
} }
......
package com.yxproject.start.entity; package com.yxproject.start.entity;
import com.yxproject.start.entity.SysRole;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
/**
* @author liboyang
*/
@Entity @Entity
@Table(name="USER_INFO")
public class UserInfo implements Serializable { public class UserInfo implements Serializable {
@Id @Id
@GeneratedValue @GeneratedValue
private Integer uId; private Integer id;
@Column(unique =true) @Column(unique =true)
private String username;//帐号 private String username;
private String name;//名称(昵称或者真实姓名,不同系统不同定义) private String name;
private String password; //密码; private String password;
private String salt;//加密密码的盐 private String salt;
private byte state;//用户状态,0:创建未认证(比如没有激活,没有输入验证码等等)--等待验证的用户 , 1:正常状态,2:用户被锁定. private byte state;
@ManyToMany(fetch= FetchType.EAGER)//立即从数据库中进行加载数据; @ManyToMany(fetch= FetchType.EAGER)
@JoinTable(name = "SysUserRole", joinColumns = { @JoinColumn(name = "uId") }, inverseJoinColumns ={@JoinColumn(name = "roleId") }) @JoinTable(name = "SysUserRole", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns ={@JoinColumn(name = "roleId") })
private List<SysRole> roleList;// 一个用户具有多个角色 private List<SysRole> roleList;
public Integer getUid() { public Integer getId() {
return uId; return id;
} }
public void setUid(Integer uid) { public void setUid(Integer id) {
this.uId = uId; this.id = id;
} }
public String getUsername() { public String getUsername() {
......
package com.yxproject.start.mapper;
import com.yxproject.start.entity.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.Map;
/**
* @author Administrator
*/
@Repository
public interface LoginMapper extends CrudRepository<UserInfo,Long> {
/**
* 通过用户名查询用户信息
* @param username
* @return
*/
public UserInfo findUserByUsername(String username);
}
...@@ -12,9 +12,12 @@ import java.util.Map; ...@@ -12,9 +12,12 @@ import java.util.Map;
* @author Administrator * @author Administrator
*/ */
@Mapper @Mapper
@Repository
public interface SysPermissionMapper { public interface SysPermissionMapper {
// @Insert("INSERT INTO sys_permission (id,available,name,parent_id,parent_ids,permission,resource_type,url)\n" + /**
// "VALUES (PERMISSION_seq.nextval,false,'用户删除',1,'0/1','userInfo:del','button','userInfo/userDel')") * 新增权限
* @param sysPermission
*/
@Insert("INSERT INTO sys_permission (id,available,name,parent_id,parent_ids,permission,resource_type,url)\n" +
"VALUES (PERMISSION_seq.nextval,0,#{name},#{parentId},#{parentIds},#{permission},#{resourceType},#{url})")
public void addPermissionByMap(SysPermission sysPermission); public void addPermissionByMap(SysPermission sysPermission);
} }
package com.yxproject.start.mapper;
import com.yxproject.start.entity.SysRole;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author liboyang
*/
@Mapper
public interface SysRoleMapper {
/**
* 添加角色
* @param sysRole
*/
@Insert({"INSERT INTO DAHAI.SYS_ROLE(ID,AVAILABLE,DESCRIPTION,ROLE)\n" +
"VALUES(PERMISSION_seq.nextval,0,#{description},#{role})"})
public void addRoleByMap(SysRole sysRole);
}
package com.yxproject.start.mapper; package com.yxproject.start.mapper;
import com.yxproject.start.entity.UserInfo; import com.yxproject.start.entity.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.Map;
/** /**
* @author Administrator * @author liboyang
*/ */
@Mapper @Mapper
@Repository public interface UserInfoMapper {
public interface UserInfoMapper extends CrudRepository<UserInfo,Long> { /**
* 新增用户
public UserInfo findUserByUsername(String username); * @param userinfo
// public int addUserInfo(UserInfo userInfo); */
@Insert("INSERT INTO DAHAI.USER_INFO(ID, NAME, PASSWORD, STATE, USERNAME, SALT) " +
"VALUES(USER_INFO_seq.nextval,#{name},#{password},0,#{username},#{salt})\n")
public void saveUserInfo(UserInfo userinfo);
// public int delUserInfo(int userInfoID); // public int delUserInfo(int userInfoID);
// public int updateUserInfo(UserInfo userInfo); // public int updateUserInfo(UserInfo userInfo);
} }
package com.yxproject.start.service;
import com.yxproject.start.entity.UserInfo;
/**
* @author liboyang
*/
public interface LoginService {
/**
* 查询用户
* @param username
* @return
*/
public UserInfo findByUsername(String username);
}
...@@ -7,7 +7,7 @@ import java.util.Map; ...@@ -7,7 +7,7 @@ import java.util.Map;
public interface SysPermissionService { public interface SysPermissionService {
public void addPermission(SysPermission sysPermission); public boolean addPermission(SysPermission sysPermission);
} }
package com.yxproject.start.service;
import com.yxproject.start.entity.SysRole;
/**
* @author liboyang
*/
public interface SysRoleService {
/**
* 角色添加
* @param sysRole
* @return
*/
public boolean addRole(SysRole sysRole);
}
...@@ -4,12 +4,16 @@ import com.yxproject.start.entity.UserInfo; ...@@ -4,12 +4,16 @@ import com.yxproject.start.entity.UserInfo;
import java.util.Map; import java.util.Map;
/**
* @author liboyang
*/
public interface UserInfoService { public interface UserInfoService {
/**
// public UserInfo findUserRoleMenu(Map<String,String> map); * 新增用户
* @param userinfo
public UserInfo findByUsername(String username); * @return
// int addUsername( UserInfo userInfo); */
public boolean addUser(UserInfo userinfo);
// int delUsername( UserInfo userInfo); // int delUsername( UserInfo userInfo);
// int updateUsername(UserInfo userInfo); // int updateUsername(UserInfo userInfo);
} }
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.mapper.LoginMapper;
import com.yxproject.start.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author liboyang
*/
@Service
public class LoginServiceImpl implements LoginService {
@Autowired
private LoginMapper loginMapper;
@Override
public UserInfo findByUsername(String username) {
UserInfo user = loginMapper.findUserByUsername(username);
return user;
}
}
...@@ -18,9 +18,9 @@ public class SysPermissionServiceImpl implements SysPermissionService{ ...@@ -18,9 +18,9 @@ public class SysPermissionServiceImpl implements SysPermissionService{
private SysPermissionMapper sysPermissionMapper; private SysPermissionMapper sysPermissionMapper;
@Override @Override
public void addPermission(SysPermission sysPermission) { public boolean addPermission(SysPermission sysPermission) {
sysPermissionMapper.addPermissionByMap(sysPermission); sysPermissionMapper.addPermissionByMap(sysPermission);
return true;
} }
......
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.SysRole;
import com.yxproject.start.mapper.SysRoleMapper;
import com.yxproject.start.service.SysRoleService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @author liboyang
*/
@Service
@Transactional(rollbackFor=Exception.class)
public class SysRoleServiceImpl implements SysRoleService {
@Autowired
private SysRoleMapper sysRoleMapper;
@Override
public boolean addRole(SysRole sysRole) {
sysRoleMapper.addRoleByMap(sysRole);
return true;
}
}
package com.yxproject.start.service.impl; package com.yxproject.start.service.impl;
import com.yxproject.start.entity.UserInfo; import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.mapper.LoginMapper;
import com.yxproject.start.mapper.UserInfoMapper; import com.yxproject.start.mapper.UserInfoMapper;
import com.yxproject.start.service.UserInfoService; import com.yxproject.start.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -16,18 +17,11 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -16,18 +17,11 @@ public class UserInfoServiceImpl implements UserInfoService {
private UserInfoMapper userInfoMapper; private UserInfoMapper userInfoMapper;
@Override @Override
public UserInfo findByUsername(String username) { public boolean addUser(UserInfo userinfo) {
System.out.println("SystemUserService.addUser(UserInfo userInfo)");
UserInfo user = userInfoMapper.findUserByUsername(username); userInfoMapper.saveUserInfo(userinfo);
return true;
return user;
} }
// @Override
// public int addUsername(UserInfo userInfo) {
// System.out.println("SystemUserService.addUsername(UserInfo userInfo)");
// userInfoMapper.addUserInfo(userInfo);
// return 1;
// }
// //
// @Override // @Override
// public int delUsername(UserInfo userInfo) { // public int delUsername(UserInfo userInfo) {
......
#spring集成Mybatis环境 #spring集成Mybatis环境
mybatis.type-aliases-package=com.yx_project.start.entity mybatis.type-aliases-package=com.yx_project.start.entity
#加载Mybatis配置文件 #加载Mybatis配置文件
mybatis.mapper-locations = classpath:mapper/*Mapper.xml #mybatis.mapper-locations = classpath:mapper/*Mapper.xml
mybatis.config-location = classpath:mapper/config/mybatis-config.xml #mybatis.config-location = classpath:mapper/config/mybatis-config.xml
#配置调度生产库数据库 #配置调度生产库数据库
spring.datasource.driver-class-name= oracle.jdbc.driver.OracleDriver spring.datasource.driver-class-name= oracle.jdbc.driver.OracleDriver
spring.datasource.url = jdbc:oracle:thin:@192.168.10.208:1521:GTYX spring.datasource.url = jdbc:oracle:thin:@192.168.10.208:1521:GTYX
spring.datasource.username = dahai spring.datasource.username = dahai
spring.datasource.password = dahai spring.datasource.password = dahai
#spring.datasource.schema = classpath:database/import.sql
#配置mysql数据库
#spring.datasource.driver-class-name= com.mysql.jdbc.Driver
#spring.datasource.url = jdbc:mysql://localhost:3306/test
#spring.datasource.username = root
#spring.datasource.password = root
##配置调度生产库数据库 ##配置调度生产库数据库
...@@ -30,7 +37,7 @@ spring.datasource.password = dahai ...@@ -30,7 +37,7 @@ spring.datasource.password = dahai
#spring.03.datasource.username = dahai #spring.03.datasource.username = dahai
#spring.03.datasource.password = dahai #spring.03.datasource.password = dahai
#自动根据实体类生成数据库表 #自动根据实体类生成数据库表
#spring.jpa.hibernate.ddl-auto= update spring.jpa.hibernate.ddl-auto= update
spring.jpa.show-sql=true spring.jpa.show-sql=true
##jsp 支持 ##jsp 支持
......
<?xml version="1.0" encoding="UTF-8" ?> <!--<?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" > <!--<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >-->
<mapper namespace="com.yxproject.start.mapper.SysPermissionMapper"> <!--<mapper namespace="com.yxproject.start.mapper.SysPermissionMapper">-->
<resultMap id="PermissionMap" type="com.yxproject.start.entity.SysPermission"> <!--&lt;!&ndash;<resultMap id="PermissionMap" type="com.yxproject.start.entity.SysPermission">&ndash;&gt;-->
<id column="id" property="id" /> <!--&lt;!&ndash;<id column="id" property="id" />&ndash;&gt;-->
<result column="name" property="name"/> <!--&lt;!&ndash;<result column="name" property="name"/>&ndash;&gt;-->
<result column="resource_type" property="resourceType"/> <!--&lt;!&ndash;<result column="resource_type" property="resourceType"/>&ndash;&gt;-->
<result column="url" property="url"/> <!--&lt;!&ndash;<result column="url" property="url"/>&ndash;&gt;-->
<result column="permission" property="permission"/> <!--&lt;!&ndash;<result column="permission" property="permission"/>&ndash;&gt;-->
<result column="parent_id" property="parentId"/> <!--&lt;!&ndash;<result column="parent_id" property="parentId"/>&ndash;&gt;-->
<result column="parent_ids" property="parentIds"/> <!--&lt;!&ndash;<result column="parent_ids" property="parentIds"/>&ndash;&gt;-->
<result column="available" property="available"/> <!--&lt;!&ndash;<result column="available" property="available"/>&ndash;&gt;-->
</resultMap> <!--&lt;!&ndash;</resultMap>&ndash;&gt;-->
<insert id="addPermissionByMap" parameterType="com.yxproject.start.entity.SysPermission"> <!--&lt;!&ndash;<insert id="addPermissionByMap" parameterType="com.yxproject.start.entity.SysPermission">&ndash;&gt;-->
Insert into DAHAI.SYS_PERMISSION (ID,AVAILABLE,NAME,PARENT_ID,PARENT_IDS,PERMISSION,RESOURCE_TYPE,URL) values (PERMISSION_seq.nextval,0,#{name},#{parentId},#{parentIds},#{permission},#{resourceType},#{url}) <!--&lt;!&ndash;Insert into DAHAI.SYS_PERMISSION (ID,AVAILABLE,NAME,PARENT_ID,PARENT_IDS,PERMISSION,RESOURCE_TYPE,URL) values (PERMISSION_seq.nextval,0,#{name},#{parentId},#{parentIds},#{permission},#{resourceType},#{url})&ndash;&gt;-->
</insert> <!--&lt;!&ndash;</insert>&ndash;&gt;-->
</mapper> <!--</mapper>-->
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?> <!--<?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" > <!--<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >-->
<mapper namespace="com.yxproject.start.mapper.UserInfoMapper"> <!--<mapper namespace="com.yxproject.start.mapper.UserInfoMapper">-->
<!--用户--> <!--&lt;!&ndash;&lt;!&ndash;用户&ndash;&gt;&ndash;&gt;-->
<resultMap id="UserRoleMenuMap" type="com.yxproject.start.entity.UserInfo"> <!--&lt;!&ndash;<resultMap id="UserRoleMenuMap" type="com.yxproject.start.entity.UserInfo">&ndash;&gt;-->
<id property="uid" column="uid"/> <!--&lt;!&ndash;<id property="uid" column="uid"/>&ndash;&gt;-->
<result column="username" property="username"/> <!--&lt;!&ndash;<result column="username" property="username"/>&ndash;&gt;-->
<result column="password" property="password"/> <!--&lt;!&ndash;<result column="password" property="password"/>&ndash;&gt;-->
<result column="state" property="state"/> <!--&lt;!&ndash;<result column="state" property="state"/>&ndash;&gt;-->
<result column="name" property="name"/> <!--&lt;!&ndash;<result column="name" property="name"/>&ndash;&gt;-->
<!--角色集合--> <!--&lt;!&ndash;&lt;!&ndash;角色集合&ndash;&gt;&ndash;&gt;-->
<collection property="roleList" ofType="com.yxproject.start.entity.SysRole"> <!--&lt;!&ndash;<collection property="roleList" ofType="com.yxproject.start.entity.SysRole">&ndash;&gt;-->
<id column="id" property="rid" /> <!--&lt;!&ndash;<id column="id" property="rid" />&ndash;&gt;-->
<result column="description" property="description"/> <!--&lt;!&ndash;<result column="description" property="description"/>&ndash;&gt;-->
<result column="role" property="role"/> <!--&lt;!&ndash;<result column="role" property="role"/>&ndash;&gt;-->
<!--权限集合--> <!--&lt;!&ndash;&lt;!&ndash;权限集合&ndash;&gt;&ndash;&gt;-->
<collection property="permissions" ofType="com.yxproject.start.entity.SysPermission"> <!--&lt;!&ndash;<collection property="permissions" ofType="com.yxproject.start.entity.SysPermission">&ndash;&gt;-->
<id column="id" property="pid" /> <!--&lt;!&ndash;<id column="id" property="pid" />&ndash;&gt;-->
<result column="name" property="pname"/> <!--&lt;!&ndash;<result column="name" property="pname"/>&ndash;&gt;-->
<result column="url" property="url"/> <!--&lt;!&ndash;<result column="url" property="url"/>&ndash;&gt;-->
</collection> <!--&lt;!&ndash;</collection>&ndash;&gt;-->
</collection> <!--&lt;!&ndash;</collection>&ndash;&gt;-->
</resultMap> <!--&lt;!&ndash;</resultMap>&ndash;&gt;-->
<!--<select id="findUserByUsername" resultMap="UserRoleMenuMap" parameterType="string">--> <!--&lt;!&ndash;<select id="findUserByUsername" resultMap="UserRoleMenuMap" parameterType="string">&ndash;&gt;-->
<!--select user_info.uid,user_info.username,user_info.password,user_info.name,sys_role.id as rid,sys_role.role,sys_role.description,--> <!--&lt;!&ndash;select user_info.uid,user_info.username,user_info.password,user_info.name,sys_role.id as rid,sys_role.role,sys_role.description,&ndash;&gt;-->
<!--sys_permission.id as pid,sys_permission.name as pname,sys_permission.url--> <!--&lt;!&ndash;sys_permission.id as pid,sys_permission.name as pname,sys_permission.url&ndash;&gt;-->
<!--from user_info--> <!--&lt;!&ndash;from user_info&ndash;&gt;-->
<!--left join sys_user_role on user_info.uid = sys_user_role.uid--> <!--&lt;!&ndash;left join sys_user_role on user_info.uid = sys_user_role.uid&ndash;&gt;-->
<!--left join sys_role on sys_user_role.role_id= sys_role.id--> <!--&lt;!&ndash;left join sys_role on sys_user_role.role_id= sys_role.id&ndash;&gt;-->
<!--left join sys_role_permission on sys_role.id = sys_role_permission.permission_id--> <!--&lt;!&ndash;left join sys_role_permission on sys_role.id = sys_role_permission.permission_id&ndash;&gt;-->
<!--left join sys_permission on sys_role_permission.permission_id = sys_permission.id--> <!--&lt;!&ndash;left join sys_permission on sys_role_permission.permission_id = sys_permission.id&ndash;&gt;-->
<!--where username=#{username}--> <!--&lt;!&ndash;where username=#{username}&ndash;&gt;-->
<!--</select>--> <!--&lt;!&ndash;</select>&ndash;&gt;-->
<!--<insert id = "addUserInfo" parameterType = "map" statementType = "PREPARED" keyProperty = "u_id" useGeneratedKeys = "true" >--> <!--&lt;!&ndash;<insert id = "addUserInfo" parameterType = "map" statementType = "PREPARED" keyProperty = "u_id" useGeneratedKeys = "true" >&ndash;&gt;-->
<!--insert into USER_INFO (`u_id`,`username`,`name`,`password`,`salt`,`state`) VALUES (USER_INFO_seq.nextval, 'admin', '管理员', 'd3c59d25033dbf980d29554025c23a75', '8d78869f470951332959580424d4bf4f', 0)--> <!--&lt;!&ndash;insert into USER_INFO (`u_id`,`username`,`name`,`password`,`salt`,`state`) VALUES (USER_INFO_seq.nextval, 'admin', '管理员', 'd3c59d25033dbf980d29554025c23a75', '8d78869f470951332959580424d4bf4f', 0)&ndash;&gt;-->
<!--</insert>--> <!--&lt;!&ndash;</insert>&ndash;&gt;-->
<!--<update id = "delUserInfo" parameterType = "int" >--> <!--&lt;!&ndash;<update id = "delUserInfo" parameterType = "int" >&ndash;&gt;-->
<!--update user_info set STATE = 1 where u_id =#{uId}--> <!--&lt;!&ndash;update user_info set STATE = 1 where u_id =#{uId}&ndash;&gt;-->
<!--</update>--> <!--&lt;!&ndash;</update>&ndash;&gt;-->
<!--<update id = "updateUserInfo" parameterType = "map" >--> <!--&lt;!&ndash;<update id = "updateUserInfo" parameterType = "map" >&ndash;&gt;-->
<!--update user_info set username =#{username},name =#{name},password =#{password} where u_id =#{uId}--> <!--&lt;!&ndash;update user_info set username =#{username},name =#{name},password =#{password} where u_id =#{uId}&ndash;&gt;-->
<!--</update>--> <!--&lt;!&ndash;</update>&ndash;&gt;-->
<!--<select id="findUserByUsername" resultMap="UserRoleMenuMap" parameterType="string">--> <!--&lt;!&ndash;<select id="findUserByUsername" resultMap="UserRoleMenuMap" parameterType="string">&ndash;&gt;-->
<!--select user_info.uid,user_info.username,user_info.password,user_info.name,sys_role.id as rid,sys_role.role,sys_role.description,--> <!--&lt;!&ndash;select user_info.uid,user_info.username,user_info.password,user_info.name,sys_role.id as rid,sys_role.role,sys_role.description,&ndash;&gt;-->
<!--sys_permission.id as pid,sys_permission.name as pname,sys_permission.url--> <!--&lt;!&ndash;sys_permission.id as pid,sys_permission.name as pname,sys_permission.url&ndash;&gt;-->
<!--from user_info--> <!--&lt;!&ndash;from user_info&ndash;&gt;-->
<!--left join sys_user_role on user_info.uid = sys_user_role.uid--> <!--&lt;!&ndash;left join sys_user_role on user_info.uid = sys_user_role.uid&ndash;&gt;-->
<!--left join sys_role on sys_user_role.role_id= sys_role.id--> <!--&lt;!&ndash;left join sys_role on sys_user_role.role_id= sys_role.id&ndash;&gt;-->
<!--left join sys_role_permission on sys_role.id = sys_role_permission.permission_id--> <!--&lt;!&ndash;left join sys_role_permission on sys_role.id = sys_role_permission.permission_id&ndash;&gt;-->
<!--left join sys_permission on sys_role_permission.permission_id = sys_permission.id--> <!--&lt;!&ndash;left join sys_permission on sys_role_permission.permission_id = sys_permission.id&ndash;&gt;-->
<!--where username=#{username}--> <!--&lt;!&ndash;where username=#{username}&ndash;&gt;-->
<!--</select>--> <!--&lt;!&ndash;</select>&ndash;&gt;-->
<!--<select id="findUserByUsername" resultType="com.yxproject.start.entity.SystemUserEntity" parameterType="String">--> <!--&lt;!&ndash;<select id="findUserByUsername" resultType="com.yxproject.start.entity.SystemUserEntity" parameterType="String">&ndash;&gt;-->
<!--select * from "SYSTEM_USER" where username=#{username}--> <!--&lt;!&ndash;select * from "SYSTEM_USER" where username=#{username}&ndash;&gt;-->
<!--</select>--> <!--&lt;!&ndash;</select>&ndash;&gt;-->
</mapper> <!--</mapper>-->
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <!--<?xml version="1.0" encoding="UTF-8"?>-->
<!DOCTYPE configuration <!--<!DOCTYPE configuration-->
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" <!--PUBLIC "-//mybatis.org//DTD Config 3.0//EN"-->
"http://mybatis.org/dtd/mybatis-3-config.dtd"> <!--"http://mybatis.org/dtd/mybatis-3-config.dtd">-->
<configuration> <!--<configuration> -->
<!---->
</configuration> <!--</configuration>-->
\ No newline at end of file \ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="Thymeleaf" <html xmlns:shiro="http://www.w3.org/1999/xhtml" xmlns:th="http://www.w3.org/1999/xhtml">
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head> <head>
<meta charset="UTF-8"/> <meta charset="UTF-8"/>
<title>Insert title here</title> <title>Insert title here</title>
...@@ -25,6 +24,9 @@ ...@@ -25,6 +24,9 @@
<p shiro:hasPermission="userInfo.add"> <p shiro:hasPermission="userInfo.add">
<a href="/userAdd">用户添加</a> <a href="/userAdd">用户添加</a>
</p> </p>
<p shiro:hasPermission="permission.add">
<a href="/permissionAdd">权限添加</a>
</p>
<hr /> <hr />
......
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="Thymeleaf" <html xmlns:th="http://www.w3.org/1999/xhtml">
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Login</title> <title>Login</title>
<!--<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.theme.min.css}"/>--> <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.theme.min.css}"/>
<link rel="stylesheet" type="text/css" href="../static/css/bootstrap.theme.min.css"/> <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.min.css}"/>
<link rel="stylesheet" type="text/css" href="../static/css/bootstrap.min.css"/> <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<script type="text/javascript" src="../static/js/jquery.min.js"></script> <script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
<script type="text/javascript" src="../static/js/bootstrap.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var dheight = $(document).height(); var dheight = $(document).height();
...@@ -18,7 +16,7 @@ ...@@ -18,7 +16,7 @@
}) })
</script> </script>
</head> </head>
<body background="images\body_bg5.jpg"> <body background="@{/images/body_bg5.jpg}">
错误信息:<h4 th:text="${msg}"></h4> 错误信息:<h4 th:text="${msg}"></h4>
<div class="container"> <div class="container">
<div id="login" class="row"> <div id="login" class="row">
......
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Add</title>
</head>
<body>
<h3>权限添加界面</h3>
<form action="" th:action="@{/permissionAdd}" method="post">
<p>名称:<input type="text" name="name" value="名称"/></p>
<p>资源类型:<input type="radio" name="resourceType" value="menu"/>menu
<input type="radio" name="resourceType" value="button"/>button</p>
<p>资源路径:<input type="text" name="url" value="userAdd"/></p>
<p>权限字符串:<input type="text" name="permission" value="userInfo.add"/></p>
<p>父编号:<input type="text" name="parentId" value="1"/></p>
<p>父编号列表:<input type="text" name="parentIds" value="0/1"/></p>
<p><input type="submit" value="添加"/></p>
</form>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Add</title>
</head>
<body>
<h3>角色添加界面</h3>
<form action="" th:action="@{/roleInfoAdd}" method="post">
<p>角色名称:<input type="text" name="role" value="vip"/></p>
<p>角色描述:<input type="text" name="description" value="会员"/></p>
<p>分配权限:<span th:each="roleList:${userInfo.roleList}">
<span th:each="permList:${roleList.permissions}">
<input type="checkbox" name="permissions" value="${permList.id}"><span th:text="${permList.name}"></span>
</span>
</span>
</p>
<p><input type="submit" value="添加"/></p>
</form>
</body>
</html>
\ No newline at end of file
...@@ -6,14 +6,10 @@ ...@@ -6,14 +6,10 @@
</head> </head>
<body> <body>
<h3>用户添加界面</h3> <h3>用户添加界面</h3>
<form action="" th:action="@{/permissionAdd}" method="post"> <form action="" th:action="@{/userInfoAdd}" method="post">
<p>名称:<input type="text" name="name" value="名称"/></p> <p>用户名:<input type="text" name="username" value="用户名"/></p>
<p>资源类型:<input type="radio" name="resourceType" value="menu"/>menu <p>名称:<input type="text" name="name" value="会员"/></p>
<input type="radio" name="resourceType" value="button"/>button</p> <p>密码:<input type="password" name="password" value="123456"/></p>
<p>资源路径:<input type="text" name="url" value="userAdd"/></p>
<p>权限字符串:<input type="text" name="permission" value="userInfo.add"/></p>
<p>父编号:<input type="text" name="parentId" value="1"/></p>
<p>父编号列表:<input type="text" name="parentIds" value="0/1"/></p>
<p><input type="submit" value="添加"/></p> <p><input type="submit" value="添加"/></p>
</form> </form>
</body> </body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment