📄 userserviceimpl.java
字号:
package com.suncms.service.ibatis;
import java.util.*;
import org.apache.log4j.*;
import com.suncms.comm.GenGUID;
import com.suncms.domain.*;
import com.suncms.exception.SuncmsException;
import com.suncms.persistence.iface.*;
import com.suncms.service.*;
public class UserServiceImpl implements UserService {
private OrgClassDao orgclassDao;
private RolesDao rolesDao;
private AuthorityDao authorityDao;
private UgroupsDao ugroupsDao;
private UserDao userDao;
private UserRoleDao userroleDao;
private UserGroupDao usergroupDao;
private UserOrgDao userorgDao;
public UserGroupDao getUsergroupDao() {
return usergroupDao;
}
public UserOrgDao getUserorgDao() {
return userorgDao;
}
public void setUserorgDao(UserOrgDao userorgDao) {
this.userorgDao = userorgDao;
}
public void setUsergroupDao(UserGroupDao usergroupDao) {
this.usergroupDao = usergroupDao;
}
public UserServiceImpl() {
}
public UserRoleDao getUserroleDao() {
return userroleDao;
}
public void setUserroleDao(UserRoleDao userroleDao) {
this.userroleDao = userroleDao;
}
public UserDao getUserDao() {
return userDao;
}
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
public UgroupsDao getUgroupsDao() {
return ugroupsDao;
}
public void setUgroupsDao(UgroupsDao ugroupsDao) {
this.ugroupsDao = ugroupsDao;
}
public AuthorityDao getAuthorityDao() {
return authorityDao;
}
public void setAuthorityDao(AuthorityDao authorityDao) {
this.authorityDao = authorityDao;
}
public RolesDao getRolesDao() {
return rolesDao;
}
public void setRolesDao(RolesDao rolesDao) {
this.rolesDao = rolesDao;
}
public OrgClassDao getOrgclassDao() {
return orgclassDao;
}
public void setOrgclassDao(OrgClassDao orgclassDao) {
this.orgclassDao = orgclassDao;
}
public void addNewOrgClass(Org_Struct org_struct) throws SuncmsException {
try {
GenGUID guid = new GenGUID();
String id = guid.toString();
org_struct.setRow_id(id);
orgclassDao.insertOrgClass(org_struct);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public Org_Struct getOrgClassById(String RowId) throws SuncmsException {
try{
return orgclassDao.getOrgClassById(RowId);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Org_Struct> getOrgClassByParId(String ParId) throws SuncmsException {
try{
return (List<Org_Struct>) orgclassDao.getOrgClassByParId(ParId);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Org_Struct> getOrgClassRoot() throws SuncmsException {
try{
return (List<Org_Struct>) orgclassDao.getOrgClassRoot();
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Org_Struct> getValidOrgClass() {
return null;
}
public void updateOrgClassById(Org_Struct org_struct) throws SuncmsException {
try {
orgclassDao.updateOrgClassById(org_struct);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Uroles> getAllRole() throws SuncmsException {
try{
return (List<Uroles>) rolesDao.getAllRole();
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public Uroles getRolesById(String RowId) throws SuncmsException {
try{
return rolesDao.getRolesById(RowId);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void addNewRoles(Uroles uroles) throws SuncmsException {
try{
GenGUID guid = new GenGUID();
String id = guid.toString();
uroles.setRow_id(id);
rolesDao.insertRoles(uroles);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Authority> getAllInfoByRoles(String roles_id) throws SuncmsException {
try{
return (List<Authority>) authorityDao.getAllInfoByRoles(roles_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void addNewAuth(String[] if_edit, String[] if_check,
String[] if_publish, String roles_id) throws SuncmsException {
try {
Map<String, Authority> ht = new Hashtable<String, Authority>();
for (String e : if_edit) {
Authority auth = new Authority();
auth.setRole_id(roles_id);
auth.setClass_id(e);
auth.setEdit("Y");
ht.put(e, auth);
}
for (String c : if_check) {
if (ht.containsKey(c)) {
ht.get(c).setCheck("Y");
} else {
Authority auth = new Authority();
auth.setRole_id(roles_id);
auth.setClass_id(c);
auth.setCheck("Y");
ht.put(c, auth);
}
}
for (String p : if_publish) {
if (ht.containsKey(p)) {
ht.get(p).setPublish("Y");
} else {
Authority auth = new Authority();
auth.setRole_id(roles_id);
auth.setClass_id(p);
auth.setPublish("Y");
ht.put(p, auth);
}
}
authorityDao.delByRoleId(roles_id);
Set<String> keySet = ht.keySet();
for (String key : keySet) {
GenGUID guid = new GenGUID();
String id = guid.toString();
Authority a = ht.get(key);
a.setRow_id(id);
authorityDao.insertAuthority(a);
}
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void addNewUgroups(Ugroups ugroups) throws SuncmsException {
try{
GenGUID guid = new GenGUID();
String id = guid.toString();
ugroups.setRow_id(id);
ugroupsDao.insertUgroups(ugroups);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public Ugroups getUgroupsById(String RowId) throws SuncmsException {
try{
return ugroupsDao.getUgroupsById(RowId);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Ugroups> getUgroupsByParId(String ParId) throws SuncmsException {
try{
return (List<Ugroups>) ugroupsDao.getUgroupsByParId(ParId);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Ugroups> getUgroupsRoot() throws SuncmsException {
try{
return (List<Ugroups>) ugroupsDao.getUgroupsRoot();
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Users> getAllUser() throws SuncmsException {
try{
return (List<Users>) userDao.getAllUser();
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void addNewUser(Users users) throws SuncmsException {
try{
GenGUID guid = new GenGUID();
String id = guid.toString();
users.setRow_id(id);
userDao.insertUsers(users);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public Users getUserByID(String row_id) throws SuncmsException {
try{
return userDao.getUserByID(row_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Uroles> getRolesIsUser(String User_id) throws SuncmsException {
try{
return rolesDao.getRoleIsUser(User_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Uroles> getRolesNotIsUser(String User_id) throws SuncmsException {
try{
return rolesDao.getRoleNotIsUser(User_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void updatetRolesUser(String user_id, List<String> RoleList) throws SuncmsException {
try {
userroleDao.delByUserID(user_id);
for (String role_id : RoleList) {
User_Role ur = new User_Role();
GenGUID guid = new GenGUID();
String id = guid.toString();
ur.setRow_id(id);
ur.setUser_id(user_id);
ur.setRole_id(role_id);
userroleDao.insertUserRole(ur);
}
String roleid=RoleList.get(0);
if(roleid!=null){
Users us=userDao.getUserByID(user_id);
Uroles ur=rolesDao.getRolesById(roleid);
us.setUser_role(ur.getRole_name());
userDao.updateUsers(us);
}
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Ugroups> getGroupsIsUser(String user_id) throws SuncmsException {
try{
return ugroupsDao.getGroupIsUser(user_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Ugroups> getGroupsNotIsUser(String user_id) throws SuncmsException {
try{
return ugroupsDao.getGroupNotIsUser(user_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void updatetGroupsUser(String user_id, List<String> GroupsList) throws SuncmsException {
try {
usergroupDao.delGroupByUserID(user_id);
for (String group_id : GroupsList) {
User_Group ug = new User_Group();
GenGUID guid = new GenGUID();
String id = guid.toString();
ug.setRow_id(id);
ug.setUser_id(user_id);
ug.setGroup_id(group_id);
usergroupDao.insertUserGroup(ug);
}
String groupid=GroupsList.get(0);
if(groupid!=null){
Users us=userDao.getUserByID(user_id);
Ugroups ug=ugroupsDao.getUgroupsById(groupid);
us.setUser_group(ug.getGroup_name());
userDao.updateUsers(us);
}
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public boolean existOrgName(String orgname) throws SuncmsException {
try{
List<Org_Struct> org = orgclassDao.getOrgByName(orgname);
if (org != null && org.size() > 0)
return true;
return false;
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public boolean existRoleName(String role_name) throws SuncmsException {
try{
List<Uroles> role = rolesDao.getRolesByName(role_name);
if (role != null && role.size() > 0)
return true;
return false;
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public boolean existGroupName(String group_name) throws SuncmsException {
try{
List<Ugroups> group =ugroupsDao.getUgroupsByName(group_name);
if (group != null && group.size() > 0)
return true;
return false;
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void updateUser(Users users) throws SuncmsException {
try {
userDao.updateUsers(users);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Org_Struct> getOrgIsUser(String User_id) throws SuncmsException {
try{
return orgclassDao.getOrgIsUser(User_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public List<Org_Struct> getOrgNotIsUser(String User_id) throws SuncmsException {
try{
return orgclassDao.getOrgNotIsUser(User_id);
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
public void updatetOrgUser(String User_id, List<String> OrgList) throws SuncmsException {
try {
userorgDao.delByUserID(User_id);
for (String org_id : OrgList) {
User_Org uo = new User_Org();
GenGUID guid = new GenGUID();
String id = guid.toString();
uo.setRow_id(id);
uo.setUser_id(User_id);
uo.setOrg_id(org_id);
userorgDao.insertUserOrg(uo);
}
String orgid=OrgList.get(0);
if(orgid!=null){
Users us=userDao.getUserByID(User_id);
Org_Struct os=orgclassDao.getOrgClassById(orgid);
us.setUser_org(os.getOrg_name());
userDao.updateUsers(us);
}
}catch(Exception e){
throw new SuncmsException("error in UserServiceImpl.addNewArticleClass()");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -