From 8527d83c19bf5047a0e6dfd1363d74b51acb0e8e Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期日, 18 二月 2024 16:29:27 +0800 Subject: [PATCH] # --- /dev/null | 16 - zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/utils/CodeBuilder.java | 4 zy-asrs-flow/src/pages/system/userLogin/components/edit.jsx | 118 ++++++++++ zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserLoginController.java | 101 +++++++++ zy-asrs-wcs/src/main/java/userLogin.sql | 9 zy-asrs-flow/src/pages/system/userLogin/index.jsx | 385 +++++++++++++++++++++++++++++++++++ 6 files changed, 615 insertions(+), 18 deletions(-) diff --git a/zy-asrs-flow/src/pages/system/user-login/index.jsx b/zy-asrs-flow/src/pages/system/user-login/index.jsx deleted file mode 100644 index 5081bb7..0000000 --- a/zy-asrs-flow/src/pages/system/user-login/index.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { - PageContainer, -} from '@ant-design/pro-components'; - -const User = () => { - return ( - <> - <PageContainer> - <h1>Hello world</h1> - </PageContainer> - </> - ) -} - -export default User; diff --git a/zy-asrs-flow/src/pages/system/userLogin/components/edit.jsx b/zy-asrs-flow/src/pages/system/userLogin/components/edit.jsx new file mode 100644 index 0000000..f9fa16a --- /dev/null +++ b/zy-asrs-flow/src/pages/system/userLogin/components/edit.jsx @@ -0,0 +1,118 @@ +import React, { useState, useRef, useEffect } from 'react'; +import { + ProForm, + ProFormDigit, + ProFormText, + ProFormSelect, + ProFormDateTimePicker +} from '@ant-design/pro-components'; +import { Form, Modal } from 'antd'; +import moment from 'moment'; +import Http from '@/utils/http'; + +const Edit = (props) => { + const [form] = Form.useForm(); + const { } = props; + + useEffect(() => { + form.resetFields(); + form.setFieldsValue({ + ...props.values + }) + }, [form, props]) + + const handleCancel = () => { + props.onCancel(); + }; + + const handleOk = () => { + form.submit(); + } + + const handleFinish = async (values) => { + props.onSubmit({ ...values }); + } + + return ( + <> + <Modal + title="Edit" + width={640} + forceRender + destroyOnClose + open={props.open} + onCancel={handleCancel} + onOk={handleOk} + > + <ProForm + form={form} + submitter={false} + onFinish={handleFinish} + layout="horizontal" + grid={true} + > + <ProFormDigit + name="id" + disabled + hidden={true} + /> + <ProForm.Group> + <ProFormSelect + name="userId" + label="鐢ㄦ埛" + colProps={{ md: 12, xl: 12 }} + fieldProps={{ precision: 0 }} + placeholder="璇烽�夋嫨" + rules={[{ required: true, message: "鐢ㄦ埛涓嶈兘涓虹┖锛�" }]} + showSearch + debounceTime={300} + request={async ({ keyWords }) => { + const resp = await Http.doPostForm('api/user/query', { condition: keyWords }); + return resp.data; + }} + /> + <ProFormText + name="token" + label="瀵嗛挜" + colProps={{ md: 12, xl: 12 }} + placeholder="璇疯緭鍏�" + /> + </ProForm.Group> + <ProForm.Group> + <ProFormText + name="ip" + label="鐧诲綍ip" + colProps={{ md: 12, xl: 12 }} + placeholder="璇疯緭鍏�" + /> + <ProFormDigit + name="type" + label="绫诲瀷" + colProps={{ md: 12, xl: 12 }} + fieldProps={{ precision: 0 }} + placeholder="璇疯緭鍏�" + /> + </ProForm.Group> + <ProForm.Group> + <ProFormDateTimePicker + name="createTime" + label="娣诲姞鏃堕棿" + colProps={{ md: 12, xl: 12 }} + placeholder="璇烽�夋嫨" + transform={(value) => moment(value).toISOString()} + /> + <ProFormText + name="system" + label="鐧诲綍绯荤粺" + colProps={{ md: 12, xl: 12 }} + placeholder="璇疯緭鍏�" + /> + </ProForm.Group> + + </ProForm> + </Modal> + </> + ) +} + +export default Edit; diff --git a/zy-asrs-flow/src/pages/system/userLogin/index.jsx b/zy-asrs-flow/src/pages/system/userLogin/index.jsx new file mode 100644 index 0000000..b151c90 --- /dev/null +++ b/zy-asrs-flow/src/pages/system/userLogin/index.jsx @@ -0,0 +1,385 @@ + +import React, { useState, useRef, useEffect } from 'react'; +import { Button, message, Modal } from 'antd'; +import { + FooterToolbar, + PageContainer, + ProTable, + LightFilter, +} from '@ant-design/pro-components'; +import { PlusOutlined, ExportOutlined } from '@ant-design/icons'; +import Http from '@/utils/http'; +import Edit from './components/edit' +import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch' + +const handleSave = async (val) => { + const hide = message.loading('姝e湪娣诲姞'); + try { + const resp = await Http.doPost('api/userLogin/save', val); + if (resp.code === 200) { + message.success('娣诲姞鎴愬姛'); + return true; + } else { + message.error(resp.msg); + return false; + } + } catch (error) { + message.error('娣诲姞澶辫触璇烽噸璇曪紒'); + return false; + } finally { + hide(); + } +}; + +const handleUpdate = async (val) => { + const hide = message.loading('姝e湪鏇存柊'); + try { + const resp = await Http.doPost('api/userLogin/update', val); + if (resp.code === 200) { + message.success('鏇存柊鎴愬姛'); + return true; + } else { + message.error(resp.msg); + return false; + } + } catch (error) { + message.error('閰嶇疆澶辫触璇烽噸璇曪紒'); + return false; + } finally { + hide(); + } +}; + +const handleRemove = async (rows) => { + if (!rows) return true; + const hide = message.loading('姝e湪鍒犻櫎'); + try { + const resp = await Http.doPost('api/userLogin/remove/' + rows.map((row) => row.id).join(',')); + if (resp.code === 200) { + message.success('鍒犻櫎鎴愬姛'); + return true; + } else { + message.error(resp.msg); + return false; + } + } catch (error) { + message.error('鍒犻櫎澶辫触锛岃閲嶈瘯'); + return false; + } finally { + hide(); + } +}; + +const handleExport = async () => { + const hide = message.loading('姝e湪瀵煎嚭'); + try { + const resp = await Http.doPostBlob('api/userLogin/export'); + const blob = new Blob([resp], { type: 'application/vnd.ms-excel' }); + window.location.href = window.URL.createObjectURL(blob); + message.success('瀵煎嚭鎴愬姛'); + return true; + } catch (error) { + message.error('瀵煎嚭澶辫触锛岃閲嶈瘯'); + return false; + } finally { + hide(); + } +}; + + +const Main = () => { + const formTableRef = useRef(); + const actionRef = useRef(); + const [selectedRows, setSelectedRows] = useState([]); + const [modalVisible, setModalVisible] = useState(false); + const [currentRow, setCurrentRow] = useState(); + const [searchParam, setSearchParam] = useState({}); + + useEffect(() => { + + }, []); + + const columns = [ + { + title: 'No', + dataIndex: 'index', + valueType: 'indexBorder', + width: 48, + }, + { + title: '鐢ㄦ埛', + dataIndex: 'userId$', + valueType: 'text', + hidden: false, + width: 140, + filterDropdown: (props) => <LinkFilter + name='userId' + major='user' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + { + title: '瀵嗛挜', + dataIndex: 'token', + valueType: 'text', + hidden: false, + width: 140, + copyable: true, + filterDropdown: (props) => <TextFilter + name='token' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + { + title: '鐧诲綍ip', + dataIndex: 'ip', + valueType: 'text', + hidden: false, + width: 140, + filterDropdown: (props) => <TextFilter + name='ip' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + { + title: '绫诲瀷', + dataIndex: 'type', + valueType: 'text', + hidden: false, + width: 140, + filterDropdown: (props) => <TextFilter + name='type' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + { + title: '娣诲姞鏃堕棿', + dataIndex: 'createTime$', + valueType: 'text', + hidden: false, + width: 140, + filterDropdown: (props) => <DatetimeRangeFilter + name='createTime' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + { + title: '鐧诲綍绯荤粺', + dataIndex: 'system', + valueType: 'text', + hidden: false, + width: 140, + filterDropdown: (props) => <TextFilter + name='system' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + { + title: '澶囨敞', + dataIndex: 'memo', + valueType: 'text', + hidden: false, + width: 140, + filterDropdown: (props) => <TextFilter + name='memo' + {...props} + actionRef={actionRef} + setSearchParam={setSearchParam} + />, + }, + + { + title: '鎿嶄綔', + dataIndex: 'option', + width: 140, + valueType: 'option', + render: (_, record) => [ + <Button + type="link" + key="edit" + onClick={() => { + setModalVisible(true); + setCurrentRow(record); + }} + > + 缂栬緫 + </Button>, + <Button + type="link" + danger + key="batchRemove" + onClick={async () => { + Modal.confirm({ + title: '鍒犻櫎', + content: '纭畾鍒犻櫎璇ラ」鍚楋紵', + onOk: async () => { + const success = await handleRemove([record]); + if (success) { + if (actionRef.current) { + actionRef.current.reload(); + } + } + }, + }); + }} + > + 鍒犻櫎 + </Button>, + ], + }, + ]; + + return ( + <PageContainer> + <div style={{ width: '100%', float: 'right' }}> + <ProTable + key="userLogin" + rowKey="id" + actionRef={actionRef} + formRef={formTableRef} + columns={columns} + cardBordered + scroll={{ x: 1300 }} + dateFormatter="string" + pagination={{ pageSize: 20 }} + search={false} + toolbar={{ + search: { + onSearch: (value) => { + setSearchParam(prevState => ({ + ...prevState, + condition: value + })); + actionRef.current?.reload(); + }, + }, + filter: ( + <LightFilter + onValuesChange={(val) => { + }} + > + </LightFilter> + ), + actions: [ + <Button + type="primary" + key="save" + onClick={async () => { + setModalVisible(true) + }} + > + <PlusOutlined /> + 娣诲姞 + </Button>, + <Button + key="export" + onClick={async () => { + handleExport(); + }} + > + <ExportOutlined /> + 瀵煎嚭 + </Button>, + ], + }} + request={(params, sorter, filter) => + Http.doPostPromise('/api/userLogin/page', { ...params, ...searchParam }, (res) => { + return { + data: res.data.records, + total: res.data.total, + success: true, + } + }) + } + rowSelection={{ + onChange: (ids, rows) => { + setSelectedRows(rows); + } + }} + columnsState={{ + persistenceKey: 'pro-table-userLogin', + persistenceType: 'localStorage', + defaultValue: { + option: { fixed: 'right', disable: true }, + }, + onChange(value) { + }, + }} + /> + </div> + + {selectedRows?.length > 0 && ( + <FooterToolbar + extra={ + <div> + 宸查�夋嫨 + <a style={{ fontWeight: 600 }}>{selectedRows.length}</a> + 椤� + </div> + } + > + <Button + key="remove" + danger + onClick={async () => { + Modal.confirm({ + title: '鍒犻櫎', + content: '纭畾鍒犻櫎璇ラ」鍚楋紵', + onOk: async () => { + const success = await handleRemove(selectedRows); + if (success) { + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + } + }, + }); + }} + > + 鎵归噺鍒犻櫎 + </Button> + </FooterToolbar> + )} + + <Edit + open={modalVisible} + values={currentRow || {}} + onCancel={ + () => { + setModalVisible(false); + setCurrentRow(undefined); + } + } + onSubmit={async (values) => { + let ok = false; + if (values.id) { + ok = await handleUpdate({ ...values }) + } else { + ok = await handleSave({ ...values }) + } + if (ok) { + setModalVisible(false); + setCurrentRow(undefined); + if (actionRef.current) { + actionRef.current.reload(); + } + } + } + } + /> + </PageContainer> + ); +}; + +export default Main; diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserLoginController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserLoginController.java new file mode 100644 index 0000000..c34ccc9 --- /dev/null +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserLoginController.java @@ -0,0 +1,101 @@ +package com.zy.asrs.wcs.system.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zy.asrs.framework.common.Cools; +import com.zy.asrs.framework.common.R; +import com.zy.asrs.wcs.common.annotation.OperationLog; +import com.zy.asrs.wcs.common.domain.BaseParam; +import com.zy.asrs.wcs.common.domain.KeyValVo; +import com.zy.asrs.wcs.common.domain.PageParam; +import com.zy.asrs.wcs.system.entity.UserLogin; +import com.zy.asrs.wcs.system.service.UserLoginService; +import com.zy.asrs.wcs.utils.ExcelUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/api") +public class UserLoginController extends BaseController { + + @Autowired + private UserLoginService userLoginService; + + @PreAuthorize("hasAuthority('system:userLogin:list')") + @PostMapping("/userLogin/page") + public R page(@RequestBody Map<String, Object> map) { + BaseParam baseParam = buildParam(map, BaseParam.class); + PageParam<UserLogin, BaseParam> pageParam = new PageParam<>(baseParam, UserLogin.class); + return R.ok().add(userLoginService.page(pageParam, pageParam.buildWrapper(true))); + } + + @PreAuthorize("hasAuthority('system:userLogin:list')") + @PostMapping("/userLogin/list") + public R list(@RequestBody Map<String, Object> map) { + return R.ok().add(userLoginService.list()); + } + + @PreAuthorize("hasAuthority('system:userLogin:list')") + @GetMapping("/userLogin/{id}") + public R get(@PathVariable("id") Long id) { + return R.ok().add(userLoginService.getById(id)); + } + + @PreAuthorize("hasAuthority('system:userLogin:save')") + @OperationLog("娣诲姞鐧诲綍鏃ュ織") + @PostMapping("/userLogin/save") + public R save(@RequestBody UserLogin userLogin) { + if (!userLoginService.save(userLogin)) { + return R.error("娣诲姞澶辫触"); + } + return R.ok("娣诲姞鎴愬姛"); + } + + @PreAuthorize("hasAuthority('system:userLogin:update')") + @OperationLog("淇敼鐧诲綍鏃ュ織") + @PostMapping("/userLogin/update") + public R update(@RequestBody UserLogin userLogin) { + if (!userLoginService.updateById(userLogin)) { + return R.error("淇敼澶辫触"); + } + return R.ok("淇敼鎴愬姛"); + } + + @PreAuthorize("hasAuthority('system:userLogin:remove')") + @OperationLog("鍒犻櫎鐧诲綍鏃ュ織") + @PostMapping("/userLogin/remove/{ids}") + public R remove(@PathVariable Long[] ids) { + if (!userLoginService.removeByIds(Arrays.asList(ids))) { + return R.error("鍒犻櫎澶辫触"); + } + return R.ok("鍒犻櫎鎴愬姛"); + } + + @PreAuthorize("hasAuthority('system:userLogin:list')") + @PostMapping("/userLogin/query") + public R query(@RequestParam(required = false) String condition) { + List<KeyValVo> vos = new ArrayList<>(); + LambdaQueryWrapper<UserLogin> wrapper = new LambdaQueryWrapper<>(); + if (!Cools.isEmpty(condition)) { + wrapper.like(UserLogin::getToken, condition); + } + userLoginService.page(new Page<>(1, 30), wrapper).getRecords().forEach( + item -> vos.add(new KeyValVo(item.getId(), item.getToken())) + ); + return R.ok().add(vos); + } + + @PreAuthorize("hasAuthority('system:userLogin:list')") + @PostMapping("/userLogin/export") + public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { + ExcelUtil.build(ExcelUtil.create(userLoginService.list(), UserLogin.class), response); + } + +} diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/utils/CodeBuilder.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/utils/CodeBuilder.java index 2809506..063092c 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/utils/CodeBuilder.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/utils/CodeBuilder.java @@ -22,8 +22,8 @@ // generator.username="sa"; // generator.password="Zoneyung@zy56$"; - generator.table="sys_menu"; - generator.tableName="鑿滃崟"; + generator.table="sys_user_login"; + generator.tableName="鐧诲綍鏃ュ織"; generator.packagePath="com.zy.asrs.wcs.system"; generator.build(); diff --git a/zy-asrs-wcs/src/main/java/userLogin.sql b/zy-asrs-wcs/src/main/java/userLogin.sql new file mode 100644 index 0000000..2fb5170 --- /dev/null +++ b/zy-asrs-wcs/src/main/java/userLogin.sql @@ -0,0 +1,9 @@ +-- save userLogin record +-- mysql +insert into `sys_menu` ( `name`, `parent_id`, `route`, `type`, `sort`, `host_id`, `status`) values ( '鐧诲綍鏃ュ織', '0', '/system/userLogin', '0' , '0', '1' , '1'); + +insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '鏌ヨ鐧诲綍鏃ュ織', '27', '1', 'system:userLogin:list', '0', '1', '1'); +insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '娣诲姞鐧诲綍鏃ュ織', '27', '1', 'system:userLogin:save', '1', '1', '1'); +insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '淇敼鐧诲綍鏃ュ織', '27', '1', 'system:userLogin:update', '2', '1', '1'); +insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '鍒犻櫎鐧诲綍鏃ュ織', '27', '1', 'system:userLogin:remove', '3', '1', '1'); + -- Gitblit v1.9.1