Skip to content

Commit

Permalink
Merge branch 'pz/master' into pzjack/master
Browse files Browse the repository at this point in the history
  • Loading branch information
dzfang committed May 15, 2016
2 parents 2f54c3c + 457c020 commit 770862e
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 385 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/sj/oaprj/core/UserType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public enum UserType {

UserType(Integer usertype) {
switch(usertype) {
case 1:
case 0:
this.intState = usertype;
this.strName = "employee";
break;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sj/oaprj/entity/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Account extends ID {
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "USER_ID")
private Employee user;
@ManyToMany(targetEntity=org.sj.oaprj.entity.Role.class, fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@ManyToMany(targetEntity=org.sj.oaprj.entity.Role.class, fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
@JoinTable(
name = "T_ACCOUNT_ROLE",
joinColumns = @JoinColumn(name = "ACCOUNT_ID"),
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/sj/oaprj/home/mvc/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping(value = "/sys/user")
@RequestMapping(value = "/user")
@Api(value = "用户管理API", description = "用户管理<br>@author Jack.Alexander")
public class UserController {
@Autowired
Expand All @@ -32,7 +32,7 @@ public class UserController {
@ApiOperation(value = "用户列表页面", notes = "用户列表页面<br/>@auther Jack.Alexander")
@RequestMapping(value = "/listInit", method = RequestMethod.GET)
public String listInit() {
return "sys/userList";
return "system/userList";
}

@ApiOperation(value = "用户列表", notes = "用户列表<br/>@auther Jack.Alexander")
Expand All @@ -49,7 +49,7 @@ private PageRequest buildPageRequest(final int page, final int size) {
@ApiOperation(value = "用户新增画面", notes = "用户新增画面<br/>@auther Jack.Alexander")
@RequestMapping(value = "/formInit", method = RequestMethod.GET)
public ModelAndView formInit() {
ModelAndView modelAndView = new ModelAndView("sys/userForm");
ModelAndView modelAndView = new ModelAndView("system/userForm");
UserUpdateDomain user = new UserUpdateDomain();
user.setRoles(roleServiceImpl.findAllRole());
user.setDeps(departmentServiceImpl.findAll());
Expand All @@ -69,7 +69,7 @@ public ModelAndView formInit() {
@RequestMapping(value = "/findOne", method = RequestMethod.GET)
public ModelAndView findOne(Long id) {
UserUpdateDomain user = userServiceImpl.findUpdate(id);
ModelAndView modelAndView = new ModelAndView("sys/userUpdateForm");
ModelAndView modelAndView = new ModelAndView("system/userUpdateForm");
// user.setRoles(roleServiceImpl.findAllRole());
user.setDeps(departmentServiceImpl.findAll());
modelAndView.addObject("user", user);
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/org/sj/oaprj/home/service/RoleServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public String delete(Long id) {
// 删除角色
roleRepository.delete(id);
// 删除角色授权
String sql = " delete from T_ROLE_MENU where ROLE_ID=:id";
Query query = entityManager.createNativeQuery(sql);
query.setParameter("id", id);
query.executeUpdate();
// String sql = " delete from T_ROLE_MENU where ROLE_ID=:id";
// Query query = entityManager.createNativeQuery(sql);
// query.setParameter("id", id);
// query.executeUpdate();
roleMenuRepository.deleteByRoleId(id);
// 删除用户角色
String userRoleSql = " delete from T_ACCOUNT_ROLE where ROLE_ID=:id";
Query userRoleQuery = entityManager.createNativeQuery(userRoleSql);
Expand Down Expand Up @@ -119,10 +120,11 @@ public List<RespTreeNode> findAll() {
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public String saveRoleAuth(Long roleId, Long[] menuIdArray) {
// 删除角色授权
String sql = " delete from T_ROLE_MENU where ROLE_ID=:id";
Query query = entityManager.createNativeQuery(sql);
query.setParameter("id", roleId);
query.executeUpdate();
// String sql = " delete from T_ROLE_MENU where ROLE_ID=:id";
// Query query = entityManager.createNativeQuery(sql);
// query.setParameter("id", roleId);
// query.executeUpdate();
roleMenuRepository.deleteByRoleId(roleId);
// 新增授权
for (Long menuId : menuIdArray) {
RoleMenu entity = new RoleMenu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void delete(Long[] idArray) {
entity.setDeleteFlag(Constants.DELETE_FLAG_1);
userRepository.save(entity);
}
accountRepository.deleteByUser_IdIn(idArray);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Map;

import org.sj.oaprj.home.service.DepartmentServiceImpl;
import org.sj.oaprj.project.domain.ProjectGroupUpdateDomain;
import org.sj.oaprj.project.service.ProjectGroupServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -23,8 +22,6 @@
public class ProjectGroupController {
@Autowired
private ProjectGroupServiceImpl projectGroupServiceImpl;
@Autowired
private DepartmentServiceImpl departmentServiceImpl;

@ApiOperation(value = "项目组列表页面", notes = "项目组列表页面<br/>@auther Jack.Alexander")
@RequestMapping(value = "/listInit", method = RequestMethod.GET)
Expand All @@ -48,8 +45,6 @@ private PageRequest buildPageRequest(final int page, final int size) {
public ModelAndView formInit() {
ModelAndView modelAndView = new ModelAndView("projects/projectgroup/ProjectGroupForm");
ProjectGroupUpdateDomain pg = new ProjectGroupUpdateDomain();
pg.setDeps(departmentServiceImpl.findAll());
//部门和角色,可以修改成点击下拉的时候动态获取
modelAndView.addObject("projectgroup", pg);
return modelAndView;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/sj/oaprj/repository/AccountRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import java.util.List;

import org.sj.oaprj.entity.Account;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface AccountRepository extends PagingAndSortingRepository<Account, Long> {
List<Account> findByAccount(String account);
Long countByAccount(String account);
@Modifying
Integer deleteByUser_IdIn(Long[] userIds);
}
4 changes: 4 additions & 0 deletions src/main/java/org/sj/oaprj/repository/RoleMenuRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import java.util.List;

import org.sj.oaprj.entity.RoleMenu;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface RoleMenuRepository extends PagingAndSortingRepository<RoleMenu, Long> {
public List<RoleMenu> findByRoleId(Long roleId);

@Modifying
public Integer deleteByRoleId(Long RoleId);
}
183 changes: 0 additions & 183 deletions src/main/resources/static/js/custom/sys/role.js

This file was deleted.

Loading

0 comments on commit 770862e

Please sign in to comment.