Browse Source

update admin gen token

pull/2/head
qiaozhanwei 6 years ago
parent
commit
27b20b5277
  1. 23
      escheduler-api/src/main/java/cn/escheduler/api/controller/UsersController.java
  2. 21
      escheduler-api/src/main/java/cn/escheduler/api/service/UsersService.java
  3. 19
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/UserMapper.java
  4. 18
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/UserMapperProvider.java
  5. 4
      escheduler-ui/src/js/conf/home/pages/user/pages/token/_source/createToken.vue
  6. 14
      escheduler-ui/src/js/conf/home/store/security/actions.js

23
escheduler-api/src/main/java/cn/escheduler/api/controller/UsersController.java

@ -135,7 +135,7 @@ public class UsersController extends BaseController{
logger.info("login user {}, updateProcessInstance user, userName: {}, email: {}, tenantId: {}, userPassword: {}, phone: {}, user queue: {}",
loginUser.getUserName(), userName, email, tenantId, Constants.PASSWORD_DEFAULT, phone,queue);
try {
Map<String, Object> result = usersService.updateUser(id,userName,userPassword,email,tenantId,phone,queue);
Map<String, Object> result = usersService.updateUser(id, userName, userPassword, email, tenantId, phone, queue);
return returnDataList(result);
}catch (Exception e){
logger.error(UPDATE_USER_ERROR.getMsg(),e);
@ -283,6 +283,26 @@ public class UsersController extends BaseController{
@GetMapping(value="/list")
@ResponseStatus(HttpStatus.OK)
public Result listUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser){
logger.info("login user {}, user list");
try{
Map<String, Object> result = usersService.queryAllGeneralUsers(loginUser);
return returnDataList(result);
}catch (Exception e){
logger.error(USER_LIST_ERROR.getMsg(),e);
return error(Status.USER_LIST_ERROR.getCode(), Status.USER_LIST_ERROR.getMsg());
}
}
/**
* user list no paging
*
* @param loginUser
* @return
*/
@GetMapping(value="/list-all")
@ResponseStatus(HttpStatus.OK)
public Result listAll(@RequestAttribute(value = Constants.SESSION_USER) User loginUser){
logger.info("login user {}, user list");
try{
Map<String, Object> result = usersService.queryUserList(loginUser);
@ -293,6 +313,7 @@ public class UsersController extends BaseController{
}
}
/**
* verify username
*

21
escheduler-api/src/main/java/cn/escheduler/api/service/UsersService.java

@ -518,6 +518,27 @@ public class UsersService extends BaseService {
return result;
}
/**
* query user list
*
* @param loginUser
* @return
*/
public Map<String, Object> queryAllGeneralUsers(User loginUser) {
Map<String, Object> result = new HashMap<>(5);
//only admin can operate
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM, Constants.STATUS)) {
return result;
}
List<User> userList = userMapper.queryAllGeneralUsers();
result.put(Constants.DATA_LIST, userList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query user list
*

19
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/UserMapper.java

@ -76,6 +76,25 @@ public interface UserMapper {
@SelectProvider(type = UserMapperProvider.class, method = "queryById")
User queryById(@Param("userId") int userId);
/**
* query all general user list
* @return
*/
@Results(value = {
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = UserMapperProvider.class, method = "queryAllGeneralUsers")
List<User> queryAllGeneralUsers();
/**
* query all user list
* @return

18
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/UserMapperProvider.java

@ -118,7 +118,7 @@ public class UserMapperProvider {
*
* @return
*/
public String queryAllUsers() {
public String queryAllGeneralUsers() {
return new SQL() {
{
SELECT("*");
@ -130,6 +130,22 @@ public class UserMapperProvider {
}.toString();
}
/**
* query all user list
*
* @return
*/
public String queryAllUsers() {
return new SQL() {
{
SELECT("*");
FROM(TABLE_NAME);
}
}.toString();
}
/**
* check user name and password
*

4
escheduler-ui/src/js/conf/home/pages/user/pages/token/_source/createToken.vue

@ -140,7 +140,7 @@
}
}
if (this.auth) {
this.store.dispatch(`security/getUsersList`).then(res => {
this.store.dispatch(`security/getUsersAll`).then(res => {
this.userIdList = _.map(res, v => _.pick(v, ['id', 'userName']))
d(this.userIdList[0].id)
})
@ -158,4 +158,4 @@
.create-token-model {
width: 640px;
}
</style>
</style>

14
escheduler-ui/src/js/conf/home/store/security/actions.js

@ -100,7 +100,7 @@ export default {
})
},
/**
* Paging query user list
* user list expect admin
*/
getUsersList ({ state }, payload) {
return new Promise((resolve, reject) => {
@ -111,6 +111,18 @@ export default {
})
})
},
/**
* user all list
*/
getUsersAll ({ state }, payload) {
return new Promise((resolve, reject) => {
io.get(`users/list-all`, payload, res => {
resolve(res.data)
}).catch(e => {
reject(e)
})
})
},
/**
* Update user
* @param "id":int,

Loading…
Cancel
Save