用户管理、端口池管理页面调通

This commit is contained in:
aoshiguchen
2022-08-28 14:34:19 +08:00
parent 6c4deb15aa
commit 30ccfb47cb
17 changed files with 519 additions and 66 deletions
@@ -78,13 +78,16 @@ public class HttpRequestHandler {
try {
String routePath = requestParser.getRoutePath();
HttpMethod httpMethod = HttpMethod.of(requestParser.getMethod().name());
HttpContextHolder.setInterceptorList(getInterceptorsForPath(routePath));
if (httpMethod == HttpMethod.OPTIONS) {
responseWrapper.headers().add("Access-Control-Allow-Origin", "*");
responseWrapper.headers().add("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
responseWrapper.headers().add("Access-Control-Max-Age", "86400");
responseWrapper.headers().add("Access-Control-Allow-Headers", "*");
responseWrapper.headers().add("Access-Control-Allow-Credentials", "true");
responseWrapper.headers().add("XDomainRequestAllowed", "1");
// responseWrapper.headers().add("Access-Control-Allow-Origin", "*");
// responseWrapper.headers().add("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
// responseWrapper.headers().add("Access-Control-Max-Age", "86400");
// responseWrapper.headers().add("Access-Control-Allow-Headers", "*");
// responseWrapper.headers().add("Access-Control-Allow-Credentials", "true");
// responseWrapper.headers().add("XDomainRequestAllowed", "1");
postHandle(requestParser.getRoutePath(), null, null);
HttpServerUtil.sendResponse(HttpResponseStatus.OK);
return;
}
@@ -93,10 +96,11 @@ public class HttpRequestHandler {
HttpServerUtil.send404Response(requestParser.getUrl());
return;
}
HttpContextHolder.setInterceptorList(getInterceptorsForPath(httpRouteResult.getPageRoute()));
// HttpContextHolder.setInterceptorList(getInterceptorsForPath(httpRouteResult.getPageRoute()));
if (HttpRouterType.METHOD == httpRouteResult.getType()) {
if (!preHandle(httpRouteResult.getPageRoute(), httpRouteResult.getMethod())) {
postHandle(requestParser.getRoutePath(), httpRouteResult.getMethod(), null);
HttpServerUtil.sendResponse(HttpResponseStatus.UNAUTHORIZED);
return;
}
@@ -145,9 +149,14 @@ public class HttpRequestHandler {
return;
}
} catch (Throwable e) {
Object res = exceptionHandler(e);
if (null != res) {
HttpServerUtil.send200Response(res);
try {
postHandle(requestParser.getRoutePath(), null, null);
Object res = exceptionHandler(e);
if (null != res) {
HttpServerUtil.send200Response(res);
}
} catch (Exception e2) {
e2.printStackTrace();
}
} finally {
release();
+2 -1
View File
@@ -1,5 +1,6 @@
module.exports = {
NODE_ENV: '"development"',
ENV_CONFIG: '"dev"',
BASE_API: '"http://localhost:8080"'
// BASE_API: '"http://localhost:8080"'
BASE_API: '"http://192.168.0.103:8080"'
}
+1 -1
View File
@@ -6,7 +6,7 @@
"license": "MIT",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host=0.0.0.0",
"build:dev": "cross-env NODE_ENV=dev env_config=dev node build/build.js",
"build:prod": "cross-env NODE_ENV=production env_config=prod node build/build.js",
"build:sit": "cross-env NODE_ENV=production env_config=sit node build/build.js",
+38
View File
@@ -0,0 +1,38 @@
import request from '@/utils/request'
export function fetchList(query) {
return request({
url: '/port-pool/page',
method: 'get',
params: query
})
}
export function updateEnableStatus(id, enable) {
return request({
url: '/port-pool/update/enable-status',
method: 'post',
data: {
id: id,
enable: enable
}
})
}
export function createPortPool(data) {
return request({
url: '/port-pool/create',
method: 'post',
data
})
}
export function deletePortPool(id) {
return request({
url: '/port-pool/delete',
method: 'post',
params: {
id: id
}
})
}
+12 -1
View File
@@ -2,7 +2,7 @@ import request from '@/utils/request'
export function fetchList(query) {
return request({
url: '/user/list',
url: '/user/page',
method: 'get',
params: query
})
@@ -38,6 +38,17 @@ export function currentUserInfo() {
})
}
export function updateEnableStatus(id, enable) {
return request({
url: '/user/update/enable-status',
method: 'post',
data: {
id: id,
enable: enable
}
})
}
export function hello() {
return request({
url: '/test1/hello',
+6 -2
View File
@@ -44,7 +44,9 @@ export default {
theme: '换肤',
clipboardDemo: 'clipboard',
i18n: '国际化',
user: '用户管理'
user: '用户管理',
system: '系统管理',
portPool: '端口池管理'
},
navbar: {
logOut: '退出登录',
@@ -110,7 +112,9 @@ export default {
createTime: '创建时间',
updateTime: '更新时间',
disable: '禁用',
enable: '启用'
enable: '启用',
loginName: '登录名',
port: '端口'
},
errorLog: {
tips: '请点击右上角bug小图标',
+4 -5
View File
@@ -2,7 +2,6 @@ import Mock from 'mockjs'
import articleAPI from './article'
import remoteSearchAPI from './remoteSearch'
import transactionAPI from './transaction'
import userAPI from './user'
// Mock.setup({
// timeout: '350-600'
@@ -27,9 +26,9 @@ Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)
Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList)
// 用户管理
Mock.mock(/\/user\/list/, 'get', userAPI.getList)
Mock.mock(/\/user\/detail/, 'get', userAPI.getUser)
Mock.mock(/\/user\/create/, 'post', userAPI.createUser)
Mock.mock(/\/user\/update/, 'post', userAPI.updateUser)
// Mock.mock(/\/user\/list/, 'get', userAPI.getList)
// Mock.mock(/\/user\/detail/, 'get', userAPI.getUser)
// Mock.mock(/\/user\/create/, 'post', userAPI.createUser)
// Mock.mock(/\/user\/update/, 'post', userAPI.updateUser)
export default Mock
+11 -7
View File
@@ -240,13 +240,17 @@ export const asyncRouterMap = [
{ path: '*', redirect: '/404', hidden: true },
{
path: '/user',
path: '/system',
component: Layout,
children: [{
path: 'index',
component: _import('user/index'),
name: 'user',
meta: { title: 'user', icon: 'user', noCache: true }
}]
redirect: 'noredirect',
name: 'system',
meta: {
title: 'system',
icon: 'component'
},
children: [
{ path: 'user', component: _import('system/user'), name: 'user', meta: { title: 'user' }},
{ path: 'portPool', component: _import('system/portPool'), name: 'portPool', meta: { title: 'portPool' }}
]
}
]
+11 -1
View File
@@ -26,9 +26,19 @@ service.interceptors.request.use(config => {
service.interceptors.response.use(
response => {
console.log('response', response)
console.log('router', this.router)
const res = response.data
if (res.code !== 0) {
console.log('请求异常', response)
Message({
message: `[${res.code}]${res.msg}`,
type: 'error',
duration: 5 * 1000
})
if (res.code === 4 && !window.location.href.endsWith('#/login')) {
store.dispatch('FedLogOut').then(() => {
location.reload() // 为了重新实例化vue-router对象 避免bug
})
}
}
return response
},
@@ -0,0 +1,274 @@
<template>
<div class="app-container calendar-list-container">
<div class="filter-container">
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button>
</div>
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
style="width: 100%">
<el-table-column align="center" :label="$t('table.id')" width="100">
<template slot-scope="scope">
<span>{{scope.row.id}}</span>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.port')" width="200">
<template slot-scope="scope">
<span>{{scope.row.port}}</span>
</template>
</el-table-column>
<el-table-column width="150px" align="center" :label="$t('table.createTime')">
<template slot-scope="scope">
<span>{{scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
</template>
</el-table-column>
<el-table-column width="150px" align="center" :label="$t('table.updateTime')">
<template slot-scope="scope">
<span>{{scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
</template>
</el-table-column>
<el-table-column class-name="status-col" :label="$t('table.status')" width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.enable | statusFilter">{{scope.row.enable | statusName}}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.actions')" width="230" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.enable =='1'" size="mini" type="danger" @click="handleModifyStatus(scope.row,2)">{{$t('table.disable')}}</el-button>
<el-button v-if="scope.row.enable =='2'" size="mini" type="success" @click="handleModifyStatus(scope.row,1)">{{$t('table.enable')}}</el-button>
<el-button v-if="scope.row.status!='deleted'" size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.currentPage"
:page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
<el-form-item :label="$t('table.port')" prop="userName">
<el-input v-model="temp.port"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">{{$t('table.cancel')}}</el-button>
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">{{$t('table.confirm')}}</el-button>
</div>
</el-dialog>
<el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
<el-table :data="pvData" border fit highlight-current-row style="width: 100%">
<el-table-column prop="key" label="Channel"> </el-table-column>
<el-table-column prop="pv" label="Pv"> </el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dialogPvVisible = false">{{$t('table.confirm')}}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { fetchList, updateEnableStatus, createPortPool, deletePortPool } from '@/api/portPool'
import waves from '@/directive/waves' // 水波纹指令
import { parseTime } from '@/utils'
const calendarTypeOptions = [
{ key: 'CN', display_name: 'China' },
{ key: 'US', display_name: 'USA' },
{ key: 'JP', display_name: 'Japan' },
{ key: 'EU', display_name: 'Eurozone' }
]
// arr to obj ,such as { CN : "China", US : "USA" }
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
acc[cur.key] = cur.display_name
return acc
}, {})
export default {
name: 'complexTable',
directives: {
waves
},
data() {
return {
tableKey: 0,
list: null,
total: null,
listLoading: true,
listQuery: {
currentPage: 1,
pageSize: 20,
importance: undefined,
title: undefined,
type: undefined
},
importanceOptions: [1, 2, 3],
calendarTypeOptions,
sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
statusOptions: ['published', 'draft', 'deleted'],
showReviewer: false,
temp: {
id: undefined,
importance: 1,
remark: '',
timestamp: new Date(),
title: '',
type: '',
status: 'published'
},
dialogFormVisible: false,
dialogStatus: '',
textMap: {
update: '编辑',
create: '新建'
},
dialogPvVisible: false,
pvData: [],
rules: {
port: [{ required: true, message: '端口必填', trigger: 'blur' }]
},
downloadLoading: false
}
},
filters: {
statusName(status) {
const statusMap = {
1: '启用',
2: '禁用'
}
return statusMap[status]
},
statusFilter(status) {
const statusMap = {
1: 'success',
2: 'danger'
}
return statusMap[status]
},
typeFilter(type) {
return calendarTypeKeyValue[type]
}
},
created() {
this.getList()
},
methods: {
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = response.data.data.records
this.total = response.data.data.total
this.listLoading = false
})
},
handleFilter() {
this.listQuery.currentPage = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.currentPage = val
this.getList()
},
handleModifyStatus(row, enable) {
console.log('route', this.$route)
updateEnableStatus(row.id, enable).then(response => {
if (response.data.data.code === 0) {
this.$message({
message: '操作成功',
type: 'success'
})
}
this.getList()
})
},
resetTemp() {
this.temp = {
id: undefined,
importance: 1,
remark: '',
timestamp: new Date(),
title: '',
status: 'published',
type: ''
}
},
handleCreate() {
this.resetTemp()
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
createPortPool(this.temp).then(response => {
if (response.data.code === 0) {
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
this.getList()
}
})
}
})
},
handleUpdate(row) {
this.temp = Object.assign({}, row) // copy obj
this.temp.timestamp = new Date(this.temp.timestamp)
this.dialogStatus = 'update'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
handleDelete(row) {
deletePortPool(row.id).then(response => {
if (response.data.code === 0) {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
})
this.getList()
}
})
},
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
const data = this.formatJson(filterVal, this.list)
excel.export_json_to_excel(tHeader, data, 'table-list')
this.downloadLoading = false
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
if (j === 'timestamp') {
return parseTime(v[j])
} else {
return v[j]
}
}))
}
}
}
</script>
@@ -1,27 +1,24 @@
<template>
<div class="app-container calendar-list-container">
<div class="filter-container">
<el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" :placeholder="$t('table.userName')" v-model="listQuery.userName">
</el-input>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{$t('table.search')}}</el-button>
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button>
</div>
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
style="width: 100%">
<el-table-column align="center" :label="$t('table.userId')" width="100">
<el-table-column align="center" :label="$t('table.id')" width="100">
<template slot-scope="scope">
<span>{{scope.row.id}}</span>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.userName')" width="200">
<template slot-scope="scope">
<span>{{scope.row.userName}}</span>
<span>{{scope.row.name}}</span>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.license')" width="300">
<el-table-column align="center" :label="$t('table.loginName')" width="200">
<template slot-scope="scope">
<span>{{scope.row.license}}</span>
<span>{{scope.row.loginName}}</span>
</template>
</el-table-column>
<el-table-column width="150px" align="center" :label="$t('table.createTime')">
@@ -36,22 +33,20 @@
</el-table-column>
<el-table-column class-name="status-col" :label="$t('table.status')" width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.status | statusFilter">{{scope.row.status | statusName}}</el-tag>
<el-tag :type="scope.row.enable | statusFilter">{{scope.row.enable | statusName}}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.actions')" width="230" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{$t('table.edit')}}</el-button>
<el-button v-if="scope.row.status =='1'" size="mini" type="danger" @click="handleModifyStatus(scope.row,2)">{{$t('table.disable')}}</el-button>
<el-button v-if="scope.row.status =='2'" size="mini" type="success" @click="handleModifyStatus(scope.row,1)">{{$t('table.enable')}}</el-button>
<el-button size="mini" type="danger" @click="handleDelete(scope.row)">{{$t('table.delete')}}</el-button>
<el-button v-if="scope.row.enable =='1'" size="mini" type="danger" @click="handleModifyStatus(scope.row,2)">{{$t('table.disable')}}</el-button>
<el-button v-if="scope.row.enable =='2'" size="mini" type="success" @click="handleModifyStatus(scope.row,1)">{{$t('table.enable')}}</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
:page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.currentPage"
:page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
@@ -85,7 +80,7 @@
</template>
<script>
import { fetchList, createUser, updateUser, hello } from '@/api/user'
import { fetchList, createUser, updateUser, updateEnableStatus } from '@/api/user'
import waves from '@/directive/waves' //
import { parseTime } from '@/utils'
@@ -114,12 +109,11 @@
total: null,
listLoading: true,
listQuery: {
page: 1,
limit: 20,
currentPage: 1,
pageSize: 20,
importance: undefined,
title: undefined,
type: undefined,
sort: '+id'
type: undefined
},
importanceOptions: [1, 2, 3],
calendarTypeOptions,
@@ -175,31 +169,35 @@
methods: {
getList() {
this.listLoading = true
hello()
fetchList(this.listQuery).then(response => {
this.list = response.data.items
this.total = response.data.total
this.list = response.data.data.records
this.total = response.data.data.total
this.listLoading = false
})
},
handleFilter() {
this.listQuery.page = 1
this.listQuery.currentPage = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.limit = val
this.listQuery.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.listQuery.currentPage = val
this.getList()
},
handleModifyStatus(row, status) {
this.$message({
message: '操作成功',
type: 'success'
handleModifyStatus(row, enable) {
console.log('route', this.$route)
updateEnableStatus(row.id, enable).then(response => {
if (response.data.data.code === 0) {
this.$message({
message: '操作成功',
type: 'success'
})
}
this.getList()
})
row.status = status
},
resetTemp() {
this.temp = {
@@ -25,6 +25,7 @@ import com.alibaba.fastjson.JSONObject;
import fun.asgc.neutrino.core.web.context.HttpRequestWrapper;
import fun.asgc.neutrino.core.web.context.HttpResponseWrapper;
import fun.asgc.neutrino.core.web.interceptor.HandlerInterceptor;
import fun.asgc.neutrino.proxy.server.base.rest.SystemContext;
import fun.asgc.neutrino.proxy.server.base.rest.SystemContextHolder;
import lombok.extern.slf4j.Slf4j;
@@ -47,6 +48,9 @@ public class VisitLogInterceptor implements HandlerInterceptor {
@Override
public void postHandle(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod, Object result) throws Exception {
if (null == SystemContextHolder.getContext() || null == SystemContextHolder.getContext().getReceiveTime()) {
return;
}
Date receiveTime = SystemContextHolder.getContext().getReceiveTime();
Date now = new Date();
long elapsedTime = now.getTime() - receiveTime.getTime();
@@ -25,13 +25,16 @@ import fun.asgc.neutrino.core.annotation.Autowired;
import fun.asgc.neutrino.core.annotation.NonIntercept;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.GetMapping;
import fun.asgc.neutrino.core.web.annotation.RequestMapping;
import fun.asgc.neutrino.core.web.annotation.RestController;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.controller.req.PortPoolUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.req.UserInfoReq;
import fun.asgc.neutrino.proxy.server.controller.req.UserListReq;
import fun.asgc.neutrino.proxy.server.controller.req.UserUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.res.PortPoolUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.res.UserInfoRes;
import fun.asgc.neutrino.proxy.server.controller.res.UserListRes;
import fun.asgc.neutrino.proxy.server.controller.res.UserUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.service.UserService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
@@ -66,4 +69,14 @@ public class UserController {
public UserInfoRes info() {
return userService.info();
}
@OnlyAdmin
@PostMapping("update/enable-status")
public UserUpdateEnableStatusRes updateEnableStatus(@RequestBody UserUpdateEnableStatusReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
return userService.updateEnableStatus(req);
}
}
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.controller.req;
import lombok.Data;
/**
*
* @author: aoshiguchen
* @date: 2022/8/28
*/
@Data
public class UserUpdateEnableStatusReq {
/**
* id
*/
private Integer id;
/**
* 启用状态
*/
private Integer enable;
}
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.controller.res;
import lombok.Data;
/**
*
* @author: aoshiguchen
* @date: 2022/8/28
*/
@Data
public class UserUpdateEnableStatusRes {
}
@@ -25,6 +25,7 @@ import fun.asgc.neutrino.core.annotation.Component;
import fun.asgc.neutrino.core.annotation.Param;
import fun.asgc.neutrino.core.db.annotation.ResultType;
import fun.asgc.neutrino.core.db.annotation.Select;
import fun.asgc.neutrino.core.db.annotation.Update;
import fun.asgc.neutrino.core.db.mapper.SqlMapper;
import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.proxy.server.controller.req.UserListReq;
@@ -69,4 +70,7 @@ public interface UserMapper extends SqlMapper {
@ResultType(UserListRes.class)
@Select("select * from user where enable = 1")
List<UserListRes> list();
@Update("update `user` set enable = :enable where id = :id")
void updateEnableStatus(@Param("id") Integer id, @Param("enable") Integer enable);
}
@@ -28,15 +28,15 @@ import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.util.CollectionUtil;
import fun.asgc.neutrino.core.util.DateUtil;
import fun.asgc.neutrino.core.web.annotation.GetMapping;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.proxy.server.base.rest.constant.EnableStatusEnum;
import fun.asgc.neutrino.proxy.server.base.rest.constant.ExceptionConstant;
import fun.asgc.neutrino.proxy.server.base.rest.ServiceException;
import fun.asgc.neutrino.proxy.server.base.rest.SystemContextHolder;
import fun.asgc.neutrino.proxy.server.controller.req.LoginReq;
import fun.asgc.neutrino.proxy.server.controller.req.UserListReq;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseListRes;
import fun.asgc.neutrino.proxy.server.controller.res.LoginRes;
import fun.asgc.neutrino.proxy.server.controller.res.UserInfoRes;
import fun.asgc.neutrino.proxy.server.controller.res.UserListRes;
import fun.asgc.neutrino.proxy.server.controller.req.UserUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.dal.UserLoginRecordMapper;
import fun.asgc.neutrino.proxy.server.dal.UserMapper;
import fun.asgc.neutrino.proxy.server.dal.UserTokenMapper;
@@ -70,6 +70,9 @@ public class UserService {
if (null == userDO || !Md5Util.encode(req.getLoginPassword()).equals(userDO.getLoginPassword())) {
throw ServiceException.create(ExceptionConstant.USER_NAME_OR_PASSWORD_ERROR);
}
if (EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
throw ServiceException.create(ExceptionConstant.USER_DISABLE);
}
String token = UUID.randomUUID().toString().replaceAll("-", "");
Date now = new Date();
@@ -150,4 +153,10 @@ public class UserService {
.setCreateTime(userDO.getCreateTime())
.setUpdateTime(userDO.getUpdateTime());
}
public UserUpdateEnableStatusRes updateEnableStatus(UserUpdateEnableStatusReq req) {
userMapper.updateEnableStatus(req.getId(), req.getEnable());
return new UserUpdateEnableStatusRes();
}
}