Skip to content

Commit

Permalink
系统管理功能完善
Browse files Browse the repository at this point in the history
  • Loading branch information
penggle committed May 8, 2017
1 parent 38501bd commit 233a3ba
Show file tree
Hide file tree
Showing 18 changed files with 517 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
public class AdminConstants extends AbstractConstants {

/**
* 上传文件临时保存目录
* 用户默认头像
*/
public static final String UPLOAD_TEMP_PATH = "/upload/temp/";
public static final String DEFAULT_USER_ICON = valueOf("/resources/images/default-user-icon.png");

/**
* 用户头像默认保存路径,相对于#GlobalConstants.IMAGE_SERVER_ROOT
*/
public static final String USER_ICON_IMAGE_SAVE_PATH = valueOf("/img/admin/usericon/");

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.certusnet.xproject.admin.consts.AdminConstants;
import com.certusnet.xproject.admin.consts.em.AdminUserStatusEnum;
import com.certusnet.xproject.admin.consts.em.AdminUserTypeEnum;
import com.certusnet.xproject.admin.model.AdminRole;
import com.certusnet.xproject.admin.model.AdminUser;
import com.certusnet.xproject.admin.service.AdminResourceService;
import com.certusnet.xproject.admin.service.AdminUserService;
import com.certusnet.xproject.admin.web.LoginToken;
import com.certusnet.xproject.common.consts.GlobalConstants;
import com.certusnet.xproject.common.support.OrderBy;
import com.certusnet.xproject.common.support.Pager;
import com.certusnet.xproject.common.support.PagingList;
import com.certusnet.xproject.common.support.Result;
import com.certusnet.xproject.common.util.DateTimeUtils;
import com.certusnet.xproject.common.util.FileUtils;
import com.certusnet.xproject.common.util.StringUtils;
import com.certusnet.xproject.common.web.BaseController;
import com.certusnet.xproject.common.web.shiro.ShiroUtils;
Expand Down Expand Up @@ -74,12 +77,25 @@ public Object listRole(HttpServletRequest request, HttpServletResponse response,
* @return
*/
@RequestMapping(value="/admin/user/add/submit", method=POST)
public Object addUser(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser userAddForm) {
public Object addUser(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser userAddForm) throws Exception {
LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
userAddForm.setCreateTime(DateTimeUtils.formatNow());
userAddForm.setCreateBy(loginToken.getLoginId());
userAddForm.setStatus(AdminUserStatusEnum.ADMIN_USER_STATUS_ENABLED.getStatusCode());
userAddForm.setUserType(AdminUserTypeEnum.ADMIN_USER_TYPE_NORMAL.getTypeCode());

if(StringUtils.isEmpty(userAddForm.getUserIcon())){
userAddForm.setUserIcon(AdminConstants.DEFAULT_USER_ICON);
}else{
String userIcon = userAddForm.getUserIcon();
if(userIcon.toLowerCase().startsWith(GlobalConstants.DEFAULT_UPLOAD_SAVE_PATH)){
String srcFullFileName = FileUtils.formatFilePath(request.getSession().getServletContext().getRealPath("/") + userIcon);
userIcon = userIcon.replace(GlobalConstants.DEFAULT_UPLOAD_SAVE_PATH, AdminConstants.USER_ICON_IMAGE_SAVE_PATH);
String destFullFileName = FileUtils.formatFilePath(GlobalConstants.IMAGE_SERVER_ROOT_PATH + userIcon);
FileUtils.copyFile(srcFullFileName, destFullFileName);
userAddForm.setUserIcon(userIcon);
}
}
adminUserService.createUser(userAddForm);
return genSuccessResult("保存成功!", null);
}
Expand All @@ -93,10 +109,23 @@ public Object addUser(HttpServletRequest request, HttpServletResponse response,
* @return
*/
@RequestMapping(value="/admin/user/edit/submit", method=POST)
public Object editUser(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser userEditForm) {
public Object editUser(HttpServletRequest request, HttpServletResponse response, @RequestBody AdminUser userEditForm) throws Exception {
LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
userEditForm.setUpdateBy(loginToken.getLoginId());
userEditForm.setUpdateTime(DateTimeUtils.formatNow());

if(StringUtils.isEmpty(userEditForm.getUserIcon())){
userEditForm.setUserIcon(AdminConstants.DEFAULT_USER_ICON);
}else{
String userIcon = userEditForm.getUserIcon();
if(userIcon.toLowerCase().startsWith(GlobalConstants.DEFAULT_UPLOAD_SAVE_PATH)){
String srcFullFileName = FileUtils.formatFilePath(request.getSession().getServletContext().getRealPath("/") + userIcon);
userIcon = userIcon.replace(GlobalConstants.DEFAULT_UPLOAD_SAVE_PATH, AdminConstants.USER_ICON_IMAGE_SAVE_PATH);
String destFullFileName = FileUtils.formatFilePath(GlobalConstants.IMAGE_SERVER_ROOT_PATH + userIcon);
FileUtils.copyFile(srcFullFileName, destFullFileName);
userEditForm.setUserIcon(userIcon);
}
}
adminUserService.updateUser(userEditForm);
return genSuccessResult("保存成功!", null);
}
Expand Down Expand Up @@ -172,8 +201,8 @@ protected Result<Object> updateUserStatus(HttpServletRequest request, HttpServle
* @return
*/
@RequestMapping(value="/admin/user/roles")
public Object loadUserRoles(HttpServletRequest request, HttpServletResponse response, Long userId) {
List<AdminRole> roleList = adminUserService.getUserRoleList(userId);
public Object loadUserRoles(HttpServletRequest request, HttpServletResponse response, Long userId, AdminRole filterParam) {
List<AdminRole> roleList = adminUserService.getUserRoleList(userId, filterParam);
return genSuccessResult(roleList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ public Object uploadImage(HttpServletRequest request, HttpServletResponse respon
} catch (Throwable e) {
logger.error(e.getMessage(), e);
result.setCode("500");
result.setMessage("上传文件出错:" + e.getMessage());
result.setMessage("上传图片出现未知错误!");
}
result.setSuccess("200".equals(result.getCode()));
if(!dataList.isEmpty()){
result.setData(dataList.size() == 1 ? dataList.get(0) : dataList);
}
Expand Down Expand Up @@ -222,8 +223,9 @@ public Object uploadFile(HttpServletRequest request, HttpServletResponse respons
} catch (Throwable e) {
logger.error(e.getMessage(), e);
result.setCode("500");
result.setMessage("上传文件出错:" + e.getMessage());
result.setMessage("上传文件出现未知错误!");
}
result.setSuccess("200".equals(result.getCode()));
if(!dataList.isEmpty()){
result.setData(dataList.size() == 1 ? dataList.get(0) : dataList);
}
Expand Down
2 changes: 1 addition & 1 deletion xproject-admin/src/main/resources/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
global.imgserver.domain=http://127.0.0.1
#global.imgserver.domain=http://www.certusnet.com.cn
#\u5168\u5c40\u56fe\u7247\u670d\u52a1\u6839\u7269\u7406\u8def\u5f84
global.imgserver.root=D:/data/xproject
global.imgserver.root=D:/GIT/flexscape-all/webui
#global.imgserver.root=/data/xproject
12 changes: 6 additions & 6 deletions xproject-admin/src/main/webapp/admin/role/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ <h3 class="el-title">
</template>
</el-table-column>
</el-table>
<div class="el-search-list-pager" v-show="showPager">
<el-pagination class="el-pagination-small" @current-change="onCurrentPageChange" :current-page="roleQueryForm.currentPage" :page-size="roleQueryForm.pageSize" layout="slot, prev, pager, next, total" :total="roleQueryTotal">
<div class="el-search-list-pager" v-show="showRoleQueryPager">
<el-pagination class="el-pagination-small" @current-change="onRoleQueryCurrentPageChange" :current-page="roleQueryForm.currentPage" :page-size="roleQueryForm.pageSize" layout="slot, prev, pager, next, total" :total="roleQueryTotal">
<div class="el-pagination-pagesize">
<span>每页显示</span>
<el-button-group>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 10}" @click="onPageSizeChange($event, 10);">10</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 20}" @click="onPageSizeChange($event, 20);">20</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 50}" @click="onPageSizeChange($event, 50);">50</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 100}" @click="onPageSizeChange($event, 100);">100</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 10}" @click="onRoleQueryPageSizeChange($event, 10);">10</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 20}" @click="onRoleQueryPageSizeChange($event, 20);">20</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 50}" @click="onRoleQueryPageSizeChange($event, 50);">50</el-button>
<el-button type="gray" :class="{active: roleQueryForm.pageSize == 100}" @click="onRoleQueryPageSizeChange($event, 100);">100</el-button>
</el-button-group>
<span></span>
</div>
Expand Down
Loading

0 comments on commit 233a3ba

Please sign in to comment.