diff --git a/.DS_Store b/.DS_Store index 70e93d6..8c5b905 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/collect_information/.env.development b/collect_information/.env.development index f811773..edad538 100644 --- a/collect_information/.env.development +++ b/collect_information/.env.development @@ -1,2 +1,3 @@ -TARO_APP_ID="wx8902ddbfddb820d1" +# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config +TARO_APP_ID="wx0acd1c4fcf94bdd3" TARO_APP_BASE_API="http://172.10.10.93:8765" diff --git a/collect_information/.env.production b/collect_information/.env.production index bf2df6e..be6f45e 100644 --- a/collect_information/.env.production +++ b/collect_information/.env.production @@ -1,2 +1 @@ -TARO_APP_ID="wx24cc8a872b57ac79" -TARO_APP_BASE_API="http://172.10.10.207:7000" +# TARO_APP_ID="生产环境下的小程序appid" \ No newline at end of file diff --git a/collect_information/.eslintrc b/collect_information/.eslintrc index a5306c7..59b61d8 100644 --- a/collect_information/.eslintrc +++ b/collect_information/.eslintrc @@ -5,6 +5,15 @@ "taro/vue3" ], "rules": { - "vue/multi-word-component-names": "off" + // 添加组件命名忽略规则 + "vue/multi-word-component-names": [ + "error", + { + //需要忽略的组件名 + "ignores": [ + "index" + ] + } + ] } } diff --git a/collect_information/.gitignore b/collect_information/.gitignore index e83724e..63712f5 100644 --- a/collect_information/.gitignore +++ b/collect_information/.gitignore @@ -5,8 +5,9 @@ deploy_versions/ node_modules/ .DS_Store .swc -yarn.lock -components.d.ts -package-lock.json .idea + +components.d.ts +package-lock.json +yarn.lock diff --git a/collect_information/config/dev.ts b/collect_information/config/dev.ts index 83b5450..c37eb43 100644 --- a/collect_information/config/dev.ts +++ b/collect_information/config/dev.ts @@ -1,124 +1,9 @@ -// import type { UserConfigExport } from "@tarojs/cli"; -// export default { -// logger: { -// quiet: false, -// stats: true -// }, -// mini: {}, -// h5: {} -// } satisfies UserConfigExport -import {defineConfig, type UserConfigExport} from '@tarojs/cli' -import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin' -import devConfig from './dev' -import prodConfig from './prod' -import ComponentsPlugin from 'unplugin-vue-components/webpack' -import NutUIResolver from '@nutui/auto-import-resolver' - -// https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数 -export default defineConfig(async (merge, {command, mode}) => { - const baseConfig: UserConfigExport = { - projectName: 'collect_information', - date: '2024-4-12', - designWidth(input: any) { - // 配置 NutUI 375 尺寸 - if (input?.file?.replace(/\\+/g, '/').indexOf('@nutui') > -1) { - return 375 - } - // 全局使用 Taro 默认的 750 尺寸 - return 750 - }, - deviceRatio: { - 640: 2.34 / 2, - 750: 1, - 828: 1.81 / 2, - 375: 2 - }, - sourceRoot: 'src', - outputRoot: 'dist', - plugins: ['@tarojs/plugin-html'], - defineConstants: {}, - copy: { - patterns: [], - options: {} - }, - framework: 'vue3', - compiler: 'webpack5', - cache: { - enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache - }, - mini: { - miniCssExtractPluginOption: { - ignoreOrder: true - }, - postcss: { - pxtransform: { - enable: true, - config: {} - }, - url: { - enable: true, - config: { - limit: 1024 // 设定转换尺寸上限 - } - }, - cssModules: { - enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true - config: { - namingPattern: 'module', // 转换模式,取值为 global/module - generateScopedName: '[name]__[local]___[hash:base64:5]' - } - } - }, - webpackChain(chain) { - chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin) - chain.plugin('unplugin-vue-components').use(ComponentsPlugin({ - resolvers: [NutUIResolver({taro: true})] - })) - } - }, - h5: { - publicPath: '/', - staticDirectory: 'static', - output: { - filename: 'js/[name].[hash:8].js', - chunkFilename: 'js/[name].[chunkhash:8].js' - }, - miniCssExtractPluginOption: { - ignoreOrder: true, - filename: 'css/[name].[hash].css', - chunkFilename: 'css/[name].[chunkhash].css' - }, - postcss: { - autoprefixer: { - enable: true, - config: {} - }, - cssModules: { - enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true - config: { - namingPattern: 'module', // 转换模式,取值为 global/module - generateScopedName: '[name]__[local]___[hash:base64:5]' - } - } - }, - webpackChain(chain) { - chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin) - } - }, - rn: { - appName: 'taroDemo', - postcss: { - cssModules: { - enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true - } - } - } - } - if (process.env.NODE_ENV === 'development') { - // 本地开发构建配置(不混淆压缩) - return merge({}, baseConfig, devConfig) - } - // 生产构建配置(默认开启压缩混淆等) - return merge({}, baseConfig, prodConfig) -}) - +import type { UserConfigExport } from "@tarojs/cli"; +export default { + logger: { + quiet: false, + stats: true + }, + mini: {}, + h5: {} +} satisfies UserConfigExport diff --git a/collect_information/config/index.ts b/collect_information/config/index.ts index 54a4b61..3a25c14 100644 --- a/collect_information/config/index.ts +++ b/collect_information/config/index.ts @@ -3,13 +3,13 @@ import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin' import devConfig from './dev' import prodConfig from './prod' import ComponentsPlugin from 'unplugin-vue-components/webpack' -import NutUIResolver from '@nutui/auto-import-resolver' +import NutUIResolver from "@nutui/auto-import-resolver"; // https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数 export default defineConfig(async (merge, {command, mode}) => { const baseConfig: UserConfigExport = { projectName: 'collect_information', - date: '2024-4-12', + date: '2024-9-14', designWidth(input: any) { // 配置 NutUI 375 尺寸 if (input?.file?.replace(/\\+/g, '/').indexOf('@nutui') > -1) { @@ -26,6 +26,7 @@ export default defineConfig(async (merge, {command, mode}) => { }, sourceRoot: 'src', outputRoot: 'dist', + // 开启 HTML 插件 plugins: ['@tarojs/plugin-html'], defineConstants: {}, copy: { diff --git a/collect_information/package.json b/collect_information/package.json index b1af349..1830680 100644 --- a/collect_information/package.json +++ b/collect_information/package.json @@ -2,7 +2,7 @@ "name": "collect_information", "version": "1.0.0", "private": true, - "description": "智慧派出所信息采集小程序", + "description": "警保联动小程序", "templateInfo": { "name": "default", "typescript": true, @@ -40,35 +40,33 @@ "author": "", "dependencies": { "@babel/runtime": "^7.21.5", - "@nutui/icons-vue-taro": "^0.0.9", - "@nutui/nutui-taro": "^4.3.5", - "@tarojs/components": "3.6.25", - "@tarojs/helper": "3.6.25", - "@tarojs/plugin-framework-vue3": "3.6.25", + "@nutui/nutui-taro": "^4.3.13", + "@tarojs/components": "3.6.26", + "@tarojs/helper": "3.6.26", + "@tarojs/plugin-framework-vue3": "3.6.26", "@tarojs/plugin-html": "^3.6.26", - "@tarojs/plugin-platform-alipay": "3.6.25", - "@tarojs/plugin-platform-h5": "3.6.25", - "@tarojs/plugin-platform-harmony-hybrid": "3.6.25", - "@tarojs/plugin-platform-jd": "3.6.25", - "@tarojs/plugin-platform-qq": "3.6.25", - "@tarojs/plugin-platform-swan": "3.6.25", - "@tarojs/plugin-platform-tt": "3.6.25", - "@tarojs/plugin-platform-weapp": "3.6.25", - "@tarojs/runtime": "3.6.25", - "@tarojs/shared": "3.6.25", - "@tarojs/taro": "3.6.25", - "dayjs": "^1.11.10", - "pinia": "^2.1.7", - "pinia-plugin-persistedstate": "^4.0.1", + "@tarojs/plugin-platform-alipay": "3.6.26", + "@tarojs/plugin-platform-h5": "3.6.26", + "@tarojs/plugin-platform-harmony-hybrid": "3.6.26", + "@tarojs/plugin-platform-jd": "3.6.26", + "@tarojs/plugin-platform-qq": "3.6.26", + "@tarojs/plugin-platform-swan": "3.6.26", + "@tarojs/plugin-platform-tt": "3.6.26", + "@tarojs/plugin-platform-weapp": "3.6.26", + "@tarojs/runtime": "3.6.26", + "@tarojs/shared": "3.6.26", + "@tarojs/taro": "3.6.26", + "dayjs": "^1.11.13", + "pinia": "^2.2.2", "vue": "^3.0.0" }, "devDependencies": { "@babel/core": "^7.8.0", "@nutui/auto-import-resolver": "^1.0.0", - "@tarojs/cli": "3.6.25", - "@tarojs/taro-loader": "3.6.25", + "@tarojs/cli": "3.6.26", + "@tarojs/taro-loader": "3.6.26", "@tarojs/test-utils-vue3": "^0.1.1", - "@tarojs/webpack5-runner": "3.6.25", + "@tarojs/webpack5-runner": "3.6.26", "@types/jest": "^29.3.1", "@types/node": "^18.15.11", "@types/webpack-env": "^1.13.6", @@ -76,10 +74,10 @@ "@typescript-eslint/parser": "^6.2.0", "@vue/babel-plugin-jsx": "^1.0.6", "@vue/compiler-sfc": "^3.0.0", - "babel-preset-taro": "3.6.25", + "babel-preset-taro": "3.6.26", "css-loader": "3.4.2", "eslint": "^8.12.0", - "eslint-config-taro": "3.6.25", + "eslint-config-taro": "3.6.26", "eslint-plugin-vue": "^8.0.0", "jest": "^29.3.1", "jest-environment-jsdom": "^29.5.0", @@ -89,8 +87,8 @@ "ts-node": "^10.9.1", "tsconfig-paths-webpack-plugin": "^4.1.0", "typescript": "^5.1.0", - "unplugin-vue-components": "^0.26.0", - "vue-loader": "^17.0.0", + "unplugin-vue-components": "^0.27.4", + "vue-loader": "^17.1.0", "webpack": "5.78.0" } } diff --git a/collect_information/project.config.json b/collect_information/project.config.json index 4850484..2d18dde 100644 --- a/collect_information/project.config.json +++ b/collect_information/project.config.json @@ -1,32 +1,15 @@ { - "miniprogramRoot": "dist/", + "miniprogramRoot": "./dist", "projectname": "collect_information", - "description": "智慧派出所信息采集小程序", + "description": "警保联动小程序", + "appid": "touristappid", "setting": { "urlCheck": false, "es6": false, "enhance": false, - "compileHotReLoad": true, + "compileHotReLoad": false, "postcss": false, - "minified": false, - "babelSetting": { - "ignore": [], - "disablePlugins": [], - "outputPath": "" - }, - "ignoreUploadUnusedFiles": true + "minified": false }, - "compileType": "miniprogram", - "libVersion": "3.5.0", - "srcMiniprogramRoot": "dist/", - "packOptions": { - "ignore": [], - "include": [] - }, - "condition": {}, - "editorSetting": { - "tabIndent": "insertSpaces", - "tabSize": 2 - }, - "appid": "wx8902ddbfddb820d1" -} \ No newline at end of file + "compileType": "miniprogram" +} diff --git a/collect_information/project.private.config.json b/collect_information/project.private.config.json deleted file mode 100644 index 99e9c4e..0000000 --- a/collect_information/project.private.config.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", - "projectname": "collect_information", - "setting": { - "compileHotReLoad": true - }, - "condition": { - "miniprogram": { - "list": [ - { - "name": "pages/projectManager/myProject/myProject", - "pathName": "pages/projectManager/myProject/myProject", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/mine/mine", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/login/login", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/mine/mine", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/index/index", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/index/dataEntry/buildFloorEntry/buildFloorEntry", - "query": "", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/register/register", - "query": "", - "launchMode": "default", - "scene": null - } - ] - } - } -} \ No newline at end of file diff --git a/collect_information/src/app.config.ts b/collect_information/src/app.config.ts index 32cd338..3690c73 100644 --- a/collect_information/src/app.config.ts +++ b/collect_information/src/app.config.ts @@ -1,59 +1,38 @@ +import {MINI_PROGRAM_USER_CONFIG} from "@/config"; + + +const tabBarItems = Object.values(MINI_PROGRAM_USER_CONFIG).map(item => item.tabBarList).flat() + export default defineAppConfig({ pages: [ 'pages/login/login', 'pages/register/register', - 'pages/projectManager/index/index', - 'pages/policeManager/index/index', - 'pages/mine/mine', - 'pages/employeeInfo/employeeInfo', + ...tabBarItems.map(i => i.pagePath) + ], + subPackages: [ + { + root: "subPages/projectManager", + pages: [ + 'myProject/myProject', + 'myProject/projectDetails/projectDetails', + 'securityUserForm/securityUserForm', + ] + }, { + root: "subPages/police", + pages: [ + 'myEnterprisesUnit/myEnterprisesUnit', + 'myEnterprisesUnit/projectDetails/projectDetails' + ] + } ], window: { backgroundTextStyle: 'light', navigationBarBackgroundColor: '#4e87ff', navigationBarTitleText: '', - navigationBarTextStyle:'white', + navigationBarTextStyle: 'white', }, - subpackages: [ - { - root: "subPages", - pages: [ - 'pages/policeManager/index', - 'pages/policeDetails/index', - - 'pages/myProject/myProject', - 'pages/projectDetails/projectDetails', - 'pages/form/form' - ] - } - ], tabBar: { custom: true, - list: [ - { - pagePath: 'pages/projectManager/index/index', - text: '首页', - iconPath: "assets/mine/punch.png", - selectedIconPath: "assets/mine/punch-active.png" - }, - { - pagePath: 'pages/policeManager/index/index', - text: '首页', - iconPath: "assets/mine/punch.png", - selectedIconPath: "assets/mine/punch-active.png" - }, - { - pagePath: 'pages/employeeInfo/employeeInfo', - text: '员工信息', - iconPath: "assets/mine/punch.png", - selectedIconPath: "assets/mine/punch-active.png" - }, - { - pagePath: 'pages/mine/mine', - text: '我的', - iconPath: "assets/mine/my.png", - selectedIconPath: "assets/mine/my-active.png" - }, - ] + list: tabBarItems } - }) diff --git a/collect_information/src/app.scss b/collect_information/src/app.scss index 0570844..e69de29 100644 --- a/collect_information/src/app.scss +++ b/collect_information/src/app.scss @@ -1,4 +0,0 @@ -*{ - margin: 0; - padding: 0; -} diff --git a/collect_information/src/app.ts b/collect_information/src/app.ts index 95a2ac5..28f74dd 100644 --- a/collect_information/src/app.ts +++ b/collect_information/src/app.ts @@ -1,35 +1,28 @@ import {createApp} from 'vue' -import {createPinia} from 'pinia' -import {useCounterStore} from '@/store' -import './app.scss' -import './assets/scss/colorui.scss' +import '@/app.scss' +import '@/assets/css/main.css' +import {pinia} from "@/store"; import Taro from "@tarojs/taro"; +import {MINI_PROGRAM_USER_CONFIG} from "@/config"; +import {useUserStore} from "@/store/userStore"; +import {initEnum} from "@/enums"; -const pinia = createPinia() -// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' -// pinia.use(piniaPluginPersistedstate) const App = createApp({ - onShow(options) { - // try { - // const store = useCounterStore() - // const token = Taro.getStorageSync('token') - // console.log(token) - // if (token) { - // Taro.switchTab({ - // url: '/pages/mine/mine' - // // url: '/pages/projectManager/index/index' - // - // }) - // store.setSelected(2) - // } else { - // console.log(2222) - // } - // console.log('App onShow.') - // } catch (err) { - // console.log(err) - // - // } - + onLaunch(opt) { + initEnum() + if (opt.path === 'subPages/projectManager/securityUserForm/securityUserForm' && opt.query.type === 'QcCodeInput') { + return + } + const tokenInfo = useUserStore().getTokenInfo(); + if (tokenInfo) { + Taro.switchTab({ + url: MINI_PROGRAM_USER_CONFIG[tokenInfo.extData.identity.value].toIndex + }) + } else { + Taro.navigateTo({ + url: '/pages/login/login', + }) + } }, // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖 }) diff --git a/collect_information/src/assets/scss/colorui.scss b/collect_information/src/assets/css/main.css similarity index 100% rename from collect_information/src/assets/scss/colorui.scss rename to collect_information/src/assets/css/main.css diff --git a/collect_information/src/assets/images/01.png b/collect_information/src/assets/images/01.png new file mode 100644 index 0000000..b66fa47 Binary files /dev/null and b/collect_information/src/assets/images/01.png differ diff --git a/collect_information/src/assets/images/arrow.png b/collect_information/src/assets/images/arrow.png deleted file mode 100644 index 521b08a..0000000 Binary files a/collect_information/src/assets/images/arrow.png and /dev/null differ diff --git a/collect_information/src/assets/images/banner.jpg b/collect_information/src/assets/images/banner.jpg deleted file mode 100644 index f29618c..0000000 Binary files a/collect_information/src/assets/images/banner.jpg and /dev/null differ diff --git a/collect_information/src/assets/images/project.png b/collect_information/src/assets/images/project.png new file mode 100644 index 0000000..8de6ed4 Binary files /dev/null and b/collect_information/src/assets/images/project.png differ diff --git a/collect_information/src/assets/logo/guohui.png b/collect_information/src/assets/logo/guohui.png new file mode 100644 index 0000000..d06ce3a Binary files /dev/null and b/collect_information/src/assets/logo/guohui.png differ diff --git a/collect_information/src/components/form/PersonnelInformationEntryForm.vue b/collect_information/src/components/form/PersonnelInformationEntryForm.vue deleted file mode 100644 index c283038..0000000 --- a/collect_information/src/components/form/PersonnelInformationEntryForm.vue +++ /dev/null @@ -1,225 +0,0 @@ - - diff --git a/collect_information/src/config/index.ts b/collect_information/src/config/index.ts new file mode 100644 index 0000000..f9bd5c6 --- /dev/null +++ b/collect_information/src/config/index.ts @@ -0,0 +1,46 @@ +import {UserConfig} from "@/types/config"; + +/** + * 客户端 + */ +export const CLIENT_TYPE = 'MINI_PROGRAM' + +/** + * 小程序用户配置 + */ +export const MINI_PROGRAM_USER_CONFIG: Record = { + police: { + toIndex: '/pages/police/index/index', + tabBarList: [ + { + pagePath: 'pages/police/index/index', + text: '首页', + iconPath: "assets/mine/punch.png", + selectedIconPath: "assets/mine/punch-active.png" + }, + { + pagePath: 'pages/police/mine/index', + text: '警察我的', + iconPath: "assets/mine/my.png", + selectedIconPath: "assets/mine/my-active.png" + }, + ] + }, + project_manager: { + toIndex: '/pages/projectManager/index/index', + tabBarList: [ + { + pagePath: 'pages/projectManager/index/index', + text: '首页', + iconPath: "assets/mine/punch.png", + selectedIconPath: "assets/mine/punch-active.png" + }, + { + pagePath: 'pages/projectManager/mine/index', + text: '项目经理我的', + iconPath: "assets/mine/my.png", + selectedIconPath: "assets/mine/my-active.png" + }, + ] + } +} diff --git a/collect_information/src/custom-tab-bar/index.json.js b/collect_information/src/custom-tab-bar/index.json.ts similarity index 100% rename from collect_information/src/custom-tab-bar/index.json.js rename to collect_information/src/custom-tab-bar/index.json.ts diff --git a/collect_information/src/custom-tab-bar/index.vue b/collect_information/src/custom-tab-bar/index.vue index f2b91fb..8d062e0 100644 --- a/collect_information/src/custom-tab-bar/index.vue +++ b/collect_information/src/custom-tab-bar/index.vue @@ -1,34 +1,42 @@ - @@ -63,12 +71,12 @@ function setSelected(index) { flex-direction: column; } -.tab-bar-item image { +.tab-bar-item cover-image { width: 54px; height: 54px; } -.tab-bar-item view { +.tab-bar-item cover-view { font-size: 20px; } diff --git a/collect_information/src/enums/index.ts b/collect_information/src/enums/index.ts index 3566495..efdc1ef 100644 --- a/collect_information/src/enums/index.ts +++ b/collect_information/src/enums/index.ts @@ -1,34 +1,40 @@ -export const SEX: SelectNode[] = [ - { - value: 0, - label: "男", - }, - { - value: 1, - label: "女", - }, - { - value: 2, - label: "隐藏", +import api from "@/request"; +import Taro from "@tarojs/taro"; + +type EnumType = + 'CheckStatus' + | 'DeleteFlag' + | 'IsEnable' + | 'IsOrNot' + | 'Sex' + | 'ServiceProjectType' + | 'MiniProgramUserIdentity' + +export const initEnum = () => { + api.get[]>>('/common/enums').then(resp => { + Taro.setStorageSync('enumMap', resp.data) + }) +}; + +export const enumSelectNodes = (enumType: EnumType): SelectNodeVo[] => Taro.getStorageSync('enumMap')?.[enumType] + +export const getEnumByValue = (enumType: EnumType, value: T): null | SelectNodeVo => { + const enumList = enumSelectNodes(enumType); + if (!enumList) { + return null; } -]; - -export const IDENTITY: SelectNode[] = [ - { - label: "公安", - value: "police" - }, - { - label: "项目经理", - value: "project_manager" - }, -] - -export const getLabelByEnumValue = (enums: SelectNode[], value: any): string => { - for (let i = 0; i < enums.length; i++) { - if (enums[i].value === value) { - return enums[i].label + for (let i = 0; i < enumList.length; i++) { + if (value === enumList[i].value) { + return enumList[i] } } - return '-' -} + return null; +}; + +export const getEnumLabelByValue = (enumType: EnumType, value: T): string => { + const enums = getEnumByValue(enumType, value) + if (!enums) { + return '-' + } + return enums.label; +}; diff --git a/collect_information/src/pages/employeeInfo/employeeInfo.config.ts b/collect_information/src/pages/employeeInfo/employeeInfo.config.ts deleted file mode 100644 index ca739e2..0000000 --- a/collect_information/src/pages/employeeInfo/employeeInfo.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - // navigationBarTitleText: '自定义导航栏', - navigationStyle: "custom" -}) diff --git a/collect_information/src/pages/employeeInfo/employeeInfo.scss b/collect_information/src/pages/employeeInfo/employeeInfo.scss deleted file mode 100644 index 139597f..0000000 --- a/collect_information/src/pages/employeeInfo/employeeInfo.scss +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/collect_information/src/pages/employeeInfo/employeeInfo.vue b/collect_information/src/pages/employeeInfo/employeeInfo.vue deleted file mode 100644 index 77742df..0000000 --- a/collect_information/src/pages/employeeInfo/employeeInfo.vue +++ /dev/null @@ -1,21 +0,0 @@ - - - diff --git a/collect_information/src/pages/login/login.config.ts b/collect_information/src/pages/login/login.config.ts index 97683f1..9d41d86 100644 --- a/collect_information/src/pages/login/login.config.ts +++ b/collect_information/src/pages/login/login.config.ts @@ -1,3 +1,3 @@ export default definePageConfig({ - navigationBarTitleText: '登录', + navigationBarTitleText: '登录', }) diff --git a/collect_information/src/pages/login/login.vue b/collect_information/src/pages/login/login.vue index 0ebac18..ed09acd 100644 --- a/collect_information/src/pages/login/login.vue +++ b/collect_information/src/pages/login/login.vue @@ -1,73 +1,45 @@ + + diff --git a/collect_information/src/pages/mine/mine.config.ts b/collect_information/src/pages/mine/mine.config.ts deleted file mode 100644 index 18e4d2b..0000000 --- a/collect_information/src/pages/mine/mine.config.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '我的', - navigationBarBackgroundColor:'#3d69dc', - navigationBarTextStyle:'white' -}) diff --git a/collect_information/src/pages/mine/mine.scss b/collect_information/src/pages/mine/mine.scss deleted file mode 100644 index 810e441..0000000 --- a/collect_information/src/pages/mine/mine.scss +++ /dev/null @@ -1,84 +0,0 @@ -.message { - height: 100vh; - background-color: #fff; -} - -.login-container { - height: 205rpx; - display: flex; - align-items: center; - background-image: url('../../assets/images/banner.jpg'); - background-repeat: no-repeat; - background-position: right; - overflow: hidden; - padding: 18rpx; - box-sizing: border-box; - - .contact { - height: 100rpx; - width: 100rpx; - border-radius: 50%; - border: solid 1px gray; - - .image { - width: 100%; - height: 100%; - border-radius: 50% - } - } - - .tips-text { - display: flex; - font-size: 28rpx; - color: #fff; - line-height: 50rpx; - margin-left: 20rpx; - flex-direction: column; - justify-content: space-evenly; - } -} - -.userIndex { - .exit { - height: 100rpx; - line-height: 40px; - border-bottom: solid 0.5px #ebebf7; - box-sizing: border-box; - display: flex; - justify-content: space-between; - align-items: center; - // margin-bottom: 30rpx; - color: #7d7d7d; - - .exitItem { - display: flex; - align-items: center; - margin-left: 30rpx; - } - - .exitItemIndex { - height: 40rpx; - width: 40rpx; - border-radius: 50%; - // border: solid 1px gray; - display: block; - line-height: 48rpx; - - image { - width: 100%; - height: 100%; - } - } - - .iconScope { - width: 8px; - height: 8px; - display: inline-block; - border: solid 2px #ccc; - -webkit-transform: rotate(45deg); - transform: rotate(45deg); - border-bottom: white; - border-left: white; - } - } -} diff --git a/collect_information/src/pages/mine/mine.vue b/collect_information/src/pages/mine/mine.vue deleted file mode 100644 index ba68e5e..0000000 --- a/collect_information/src/pages/mine/mine.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - - diff --git a/collect_information/src/pages/policeManager/index/index.config.ts b/collect_information/src/pages/police/index/index.config.ts similarity index 98% rename from collect_information/src/pages/policeManager/index/index.config.ts rename to collect_information/src/pages/police/index/index.config.ts index 16286d6..a7c25c7 100644 --- a/collect_information/src/pages/policeManager/index/index.config.ts +++ b/collect_information/src/pages/police/index/index.config.ts @@ -1,4 +1,3 @@ export default definePageConfig({ navigationBarTitleText: '首页', - }) diff --git a/collect_information/src/pages/police/index/index.scss b/collect_information/src/pages/police/index/index.scss new file mode 100644 index 0000000..650fcb5 --- /dev/null +++ b/collect_information/src/pages/police/index/index.scss @@ -0,0 +1,47 @@ +.swiperDemoItem { + color: #3886d0; + display: flex; + padding: 20px 0 0 50px; + overflow: hidden; + height: 70rpx; + + .swiperDemoIndex { + width: 15px; + height: 45px; + background-image: linear-gradient(to bottom, #5d9cf9, #317ad9); + //background: rgb(); + border-radius: 20px; + margin-right: 15px; + } +} + +.subModule { + display: flex; + align-items: center; + flex-wrap: wrap; + margin-right: -3px; + margin-left: -1px; + + .subModuleItem { + width: 33%; + height: 180rpx; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding-bottom: 10rpx; + border: 1px solid #ccc; + border-left: 0; + margin-top: -1px; + + .subModuleIndex { + width: 65rpx; + height: 65rpx; + + image { + width: 100%; + height: 100%; + } + } + } +} diff --git a/collect_information/src/pages/police/index/index.vue b/collect_information/src/pages/police/index/index.vue new file mode 100644 index 0000000..9ca7928 --- /dev/null +++ b/collect_information/src/pages/police/index/index.vue @@ -0,0 +1,58 @@ + + diff --git a/collect_information/src/pages/police/mine/index.config.ts b/collect_information/src/pages/police/mine/index.config.ts new file mode 100644 index 0000000..a7c25c7 --- /dev/null +++ b/collect_information/src/pages/police/mine/index.config.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '首页', +}) diff --git a/collect_information/src/pages/police/mine/index.scss b/collect_information/src/pages/police/mine/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/collect_information/src/pages/police/mine/index.vue b/collect_information/src/pages/police/mine/index.vue new file mode 100644 index 0000000..d00e9e3 --- /dev/null +++ b/collect_information/src/pages/police/mine/index.vue @@ -0,0 +1,9 @@ + + + diff --git a/collect_information/src/pages/policeManager/index/index.scss b/collect_information/src/pages/policeManager/index/index.scss deleted file mode 100644 index a3b707a..0000000 --- a/collect_information/src/pages/policeManager/index/index.scss +++ /dev/null @@ -1,39 +0,0 @@ -page { - background-color: #f0f0f0; -} - -.content { - width: 702rpx; - margin: 10rpx auto; - background-color: #fff; - border-radius: 10rpx; - height: 500rpx; - display: grid; - /* 定义两列,每列占据50%的宽度 */ - grid-template-columns: repeat(2, 1fr); - /* 定义两行,每行占据1fr(分数单位,表示剩余空间的一部分) */ - grid-template-rows: repeat(2, 1fr); - /* 可选:增加一些间隙 */ - gap: 10px; - - .grid-item { - //width: 100%; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - - - .grid-item-image { - height: 150rpx; - width: 150rpx; - background-color: #f0f0f0; - border-radius: 50%; - } - - .grid-item-text { - - - } - } -} diff --git a/collect_information/src/pages/policeManager/index/index.vue b/collect_information/src/pages/policeManager/index/index.vue deleted file mode 100644 index 94154d2..0000000 --- a/collect_information/src/pages/policeManager/index/index.vue +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/collect_information/src/pages/projectManager/index/index.config.ts b/collect_information/src/pages/projectManager/index/index.config.ts index 6b0b2af..a7c25c7 100644 --- a/collect_information/src/pages/projectManager/index/index.config.ts +++ b/collect_information/src/pages/projectManager/index/index.config.ts @@ -1,4 +1,3 @@ - export default definePageConfig({ - navigationBarTitleText: '首页', + navigationBarTitleText: '首页', }) diff --git a/collect_information/src/pages/projectManager/index/index.scss b/collect_information/src/pages/projectManager/index/index.scss index e69de29..b802829 100644 --- a/collect_information/src/pages/projectManager/index/index.scss +++ b/collect_information/src/pages/projectManager/index/index.scss @@ -0,0 +1,48 @@ +.swiperDemoItem { + color: #3886d0; + display: flex; + padding: 20px 0 0 50px; + overflow: hidden; + height: 70rpx; + + .swiperDemoIndex { + width: 15px; + height: 45px; + background-image: linear-gradient(to bottom, #5d9cf9, #317ad9); + //background: rgb(); + border-radius: 20px; + margin-right: 15px; + } +} + +.subModule { + display: flex; + align-items: center; + flex-wrap: wrap; + margin-right: -3px; + margin-left: -1px; + + .subModuleItem { + width: 33%; + height: 180rpx; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding-bottom: 10rpx; + border: 1px solid #ccc; + border-left: 0; + margin-top: -1px; + + .subModuleIndex { + width: 65rpx; + height: 65rpx; + + image { + width: 100%; + height: 100%; + } + } + } +} + diff --git a/collect_information/src/pages/projectManager/index/index.vue b/collect_information/src/pages/projectManager/index/index.vue index 0ffa443..d44d09a 100644 --- a/collect_information/src/pages/projectManager/index/index.vue +++ b/collect_information/src/pages/projectManager/index/index.vue @@ -1,41 +1,58 @@ - - diff --git a/collect_information/src/pages/projectManager/mine/index.config.ts b/collect_information/src/pages/projectManager/mine/index.config.ts new file mode 100644 index 0000000..b4d3feb --- /dev/null +++ b/collect_information/src/pages/projectManager/mine/index.config.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '我的', +}) diff --git a/collect_information/src/pages/projectManager/mine/index.scss b/collect_information/src/pages/projectManager/mine/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/collect_information/src/pages/projectManager/mine/index.vue b/collect_information/src/pages/projectManager/mine/index.vue new file mode 100644 index 0000000..55e8097 --- /dev/null +++ b/collect_information/src/pages/projectManager/mine/index.vue @@ -0,0 +1,9 @@ + + + diff --git a/collect_information/src/pages/register/register.config.ts b/collect_information/src/pages/register/register.config.ts index 7632e93..1c854c8 100644 --- a/collect_information/src/pages/register/register.config.ts +++ b/collect_information/src/pages/register/register.config.ts @@ -1,3 +1,3 @@ export default definePageConfig({ - navigationBarTitleText: '用户注册' + navigationBarTitleText: '注册' }) diff --git a/collect_information/src/pages/register/register.scss b/collect_information/src/pages/register/register.scss index eaa1ebf..d3ec4b4 100644 --- a/collect_information/src/pages/register/register.scss +++ b/collect_information/src/pages/register/register.scss @@ -27,7 +27,7 @@ } .nickNameInput{ - color: black; + color: black; } .contact { diff --git a/collect_information/src/pages/register/register.vue b/collect_information/src/pages/register/register.vue index e3e7fc7..0368d69 100644 --- a/collect_information/src/pages/register/register.vue +++ b/collect_information/src/pages/register/register.vue @@ -11,9 +11,9 @@ @@ -26,18 +26,18 @@ {{ item.label }} @@ -47,21 +47,21 @@ - {{ selectedLabel || '请选择单位'}} + {{ selectedLabel || '请选择单位' }} @@ -75,19 +75,23 @@ - diff --git a/collect_information/src/request/index.ts b/collect_information/src/request/index.ts index 0947285..8c22ad3 100644 --- a/collect_information/src/request/index.ts +++ b/collect_information/src/request/index.ts @@ -1,26 +1,33 @@ import Taro from "@tarojs/taro"; -import {ApiOptions} from "../../types/request"; -import {type} from "os"; +import {ApiOptions} from "@/types/request"; +import {useUserStore} from "@/store/userStore"; + +/** + * 请求拦截器 + * @param chain + */ const requestInterceptor = (chain: Taro.Chain) => { const requestParams = chain.requestParams - const token = Taro.getStorageSync('token') - if (token) { - requestParams.header = { - ...requestParams.header, - token: token.value - } + const tokenInfo = useUserStore().getTokenInfo() + const {header} = requestParams; + const customHeader: Record = {} + //添加token + tokenInfo && (customHeader[tokenInfo.name] = tokenInfo.value); + requestParams.header = { + ...header, + ...customHeader } return chain.proceed(requestParams) } -class CustomRequest { - BASE_API: string +//所有的拦截器 +const interceptors = [requestInterceptor]; +//注册拦截器 +interceptors.forEach((interceptorItem) => Taro.addInterceptor(interceptorItem)); - public constructor() { - this.BASE_API = process.env.TARO_APP_BASE_API - Taro.addInterceptor(requestInterceptor) - } +class CustomRequest { + BASE_API: string = process.env.TARO_APP_BASE_API; private request(url: string, method: keyof Taro.request.Method, options: ApiOptions, params?: object,): Promise> { return new Promise>((resolve, reject) => { @@ -29,7 +36,6 @@ class CustomRequest { title: '请求中...', }).then() } - Taro.request, object>({ url: this.BASE_API + url, data: params, @@ -37,10 +43,14 @@ class CustomRequest { ...options, success: (result) => { Taro.hideLoading() + if (result.header['Content-Type'] === 'application/octet-stream') { + resolve(result.data) + return + } const jsonResult = result.data if (jsonResult.code !== 200) { if ([401].includes(jsonResult.code)) { - //todo 重新登录 跳转登录页 提示错误 + // 重新登录 跳转登录页 提示错误 } Taro.showToast({ title: jsonResult.message, @@ -49,8 +59,9 @@ class CustomRequest { duration: 2000 }).then() reject(jsonResult); + } else { + resolve(jsonResult); } - resolve(jsonResult); }, fail: (res) => { Taro.hideLoading() @@ -61,13 +72,16 @@ class CustomRequest { duration: 2000 }).then() reject(res.errMsg); - console.log(res.errMsg, '000') } }) }) } get(url: string, params?: object, options: ApiOptions = {loading: false}): Promise> { + options.header = { + ...options.header, + "content-type": 'application/x-www-form-urlencoded' + } return this.request(url, "GET", options, params) } @@ -76,12 +90,17 @@ class CustomRequest { } delete(url: string, params?: object, options: ApiOptions = {loading: false}): Promise> { + options.header = { + ...options.header, + "content-type": 'application/x-www-form-urlencoded' + } return this.request(url, "DELETE", options, params) } put(url: string, params?: object, options: ApiOptions = {loading: false}): Promise> { return this.request(url, "PUT", options, params) } + } const api = new CustomRequest(); diff --git a/collect_information/src/store/index.ts b/collect_information/src/store/index.ts index e29a946..e917126 100644 --- a/collect_information/src/store/index.ts +++ b/collect_information/src/store/index.ts @@ -1,51 +1,3 @@ -import {defineStore} from 'pinia' -import Taro from '@tarojs/taro' - -export const useCounterStore = defineStore('counter', { - state: () => { - return { - userInfo: {}, - selected: 0, - list: Taro.getStorageSync('list') || [ - { - pagePath: '/pages/projectManager/index/index', - text: '首页', - iconPath: "/assets/mine/punch.png", - selectedIconPath: "/assets/mine/punch-active.png" - }, - { - pagePath: '/pages/employeeInfo/employeeInfo', - text: '员工信息', - iconPath: "/assets/mine/punch.png", - selectedIconPath: "/assets/mine/punch-active.png" - }, - { - pagePath: '/pages/mine/mine', - text: '我的', - iconPath: "/assets/mine/my.png", - selectedIconPath: "/assets/mine/my-active.png" - }, - ] - } - }, - actions: { - setSelected(index: number) { - this.selected = index - }, - updateHomePagePath(newPath: string) { - this.list[0].pagePath = newPath - // 更新 list 后存储到小程序本地存储 - Taro.setStorageSync('list', this.list) - } - }, - getters: { - getSelected: (state) => state.selected, - getList: (state) => state.list - }, - persist: { - // key: 'my-store', // 存储到 localStorage 的 key - // storage: localStorage, // 持久化方式为 localStorage - // paths: ['list'] // 持久化 list - } -}) +import {createPinia} from 'pinia' +export const pinia = createPinia() diff --git a/collect_information/src/store/tabBarStore.ts b/collect_information/src/store/tabBarStore.ts new file mode 100644 index 0000000..accf8c3 --- /dev/null +++ b/collect_information/src/store/tabBarStore.ts @@ -0,0 +1,14 @@ +import {defineStore} from "pinia"; +import {ref} from "vue"; + +export const useTabBarStore = defineStore('tabBar', () => { + const selected = ref(0) + const setSelected = (index: number) => { + selected.value = index; + } + + return { + selected, + setSelected + } +}) diff --git a/collect_information/src/store/userStore.ts b/collect_information/src/store/userStore.ts index e69de29..2dafcb3 100644 --- a/collect_information/src/store/userStore.ts +++ b/collect_information/src/store/userStore.ts @@ -0,0 +1,40 @@ +import {defineStore} from "pinia"; +import {ref} from "vue"; +import Taro from "@tarojs/taro"; + +export const useUserStore = defineStore('userStore', () => { + /** 获取token信息 **/ + const getTokenInfo = (): TokenInfo | null => { + const ti = Taro.getStorageSync('tokenInfo') + // 如果 ti 存在且不是空字符串,则返回 ti,否则返回 null + return (ti !== undefined && ti !== null && ti !== '') ? ti : null; + } + /** 用户token信息 **/ + const tokenInfo = ref(getTokenInfo()) + /** 保存token信息 **/ + const saveTokenInfo = (t: TokenInfo) => { + tokenInfo.value = t; + Taro.setStorageSync('tokenInfo', tokenInfo.value) + } + /** 清楚token信息 */ + const clearTokenInfo = () => { + tokenInfo.value = null + Taro.removeStorageSync('tokenInfo') + } + + + /** + * 重置用户数据 + * 一般用于用户退出登录 重置所有相关数据 + */ + const resetUserInfo = () => { + clearTokenInfo() + } + + return { + tokenInfo, + saveTokenInfo, + getTokenInfo, + resetUserInfo + } +}) diff --git a/collect_information/src/subPages/pages/form/form.config.ts b/collect_information/src/subPages/pages/form/form.config.ts deleted file mode 100644 index 7652664..0000000 --- a/collect_information/src/subPages/pages/form/form.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '项目人员录入', -}) diff --git a/collect_information/src/subPages/pages/form/form.scss b/collect_information/src/subPages/pages/form/form.scss deleted file mode 100644 index 93df7ae..0000000 --- a/collect_information/src/subPages/pages/form/form.scss +++ /dev/null @@ -1,8 +0,0 @@ -.form{ - .formButton{ - display: flex; - margin-top: auto; - justify-content: space-around; - margin-bottom: 30px - } -} diff --git a/collect_information/src/subPages/pages/myProject/myproject.config.ts b/collect_information/src/subPages/pages/myProject/myproject.config.ts deleted file mode 100644 index 7bccd60..0000000 --- a/collect_information/src/subPages/pages/myProject/myproject.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '我的项目', -}) diff --git a/collect_information/src/subPages/pages/myProject/myproject.scss b/collect_information/src/subPages/pages/myProject/myproject.scss deleted file mode 100644 index 867ee38..0000000 --- a/collect_information/src/subPages/pages/myProject/myproject.scss +++ /dev/null @@ -1,31 +0,0 @@ -.myProject{ - height: 100vh; - overflow: hidden; - background: #f1f1f1; - .myProjectItem{ - //height: 20%; - margin: 20px; - border-radius: 10px; - background: #ffffff; - padding: 15px; - font-size: 28px; - line-height: 50px; - color: #333333; - .myProjectIndex{ - color: #9b9b9f; - } - .project{ - display: flex; - justify-content: space-between; - flex-flow: wrap; - text-align: center; - view{ - width: 45%; - height: 100rpx; - border: 1px solid #cccccc; - line-height: 100rpx; - margin: 8px 0 8px 0; - } - } - } -} diff --git a/collect_information/src/subPages/pages/policeDetails/index.scss b/collect_information/src/subPages/pages/policeDetails/index.scss deleted file mode 100644 index b495b04..0000000 --- a/collect_information/src/subPages/pages/policeDetails/index.scss +++ /dev/null @@ -1,53 +0,0 @@ -.projectDetails{ - height: 100vh; - overflow: hidden; - background: #f1f1f1; - display: flex; - flex-direction: column; - .projectDetailsItem{ - height: 18%; - margin: 20px; - border-radius: 10px; - background: #ffffff; - padding: 15px; - font-size: 28px; - line-height: 65px; - color: #333333; - .projectDetailsIndex{ - .content{ - color: #9b9b9f; - } - } - } - .projectDetailsTableDrop{ - height: 80%; - .projectDetailsTable{ - margin: 20px; - border-radius: 10px; - background: #ffffff; - padding: 15px; - font-size: 28px; - line-height: 50px; - color: #333333; - .projectDetailsTableItem{ - //display: flex; - justify-content: space-between; - align-items: center; - flex-wrap: wrap; - font-size: 24px; - margin-bottom: 15px - } - } - } - .projectDetailsButton{ - position: fixed; - bottom: 19px; - display: flex; - -webkit-justify-content: space-around; - margin-bottom: 10rpx; - right: 0; - width: 100%; - } -} - - diff --git a/collect_information/src/subPages/pages/policeManager/index.scss b/collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.scss similarity index 99% rename from collect_information/src/subPages/pages/policeManager/index.scss rename to collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.scss index b1dd448..1cab77b 100644 --- a/collect_information/src/subPages/pages/policeManager/index.scss +++ b/collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.scss @@ -32,4 +32,3 @@ page { } } } - diff --git a/collect_information/src/subPages/pages/policeManager/index.config.ts b/collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.ts similarity index 98% rename from collect_information/src/subPages/pages/policeManager/index.config.ts rename to collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.ts index 30c5ed6..db6b2a1 100644 --- a/collect_information/src/subPages/pages/policeManager/index.config.ts +++ b/collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.ts @@ -1,4 +1,3 @@ export default definePageConfig({ navigationBarTitleText: '企事业单位', - }) diff --git a/collect_information/src/subPages/pages/policeManager/index.vue b/collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.vue similarity index 66% rename from collect_information/src/subPages/pages/policeManager/index.vue rename to collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.vue index e8d67a4..b1cb95e 100644 --- a/collect_information/src/subPages/pages/policeManager/index.vue +++ b/collect_information/src/subPages/police/myEnterprisesUnit/myEnterprisesUnit.vue @@ -13,8 +13,9 @@ 电话:{{ item?.contactPersonInfo.telephone }} - - {{ items.name }} + + {{ serviceProject.name }} @@ -25,33 +26,21 @@ import api from "@/request/index"; import {onMounted, ref} from "vue"; import Taro from "@tarojs/taro"; -import './index.scss' +import './myEnterprisesUnit.scss' +import {MyProjectList, ServiceProjectList} from "@/types/subPages/projectManager/myProject"; const myProjectList = ref() const getMyServiceProject = async () => { - const token = Taro.getStorageSync('token') - const resp = await api.get(`/policeIndex/getUnitServiceProjectList`, { - token: token.value - }) - + const resp = await api.get(`/policeIndex/getUnitServiceProjectList`) myProjectList.value = resp.data - console.log(resp.data) } -const projectClick = (items: ServiceProjectList, name: string) => { - console.log(name, JSON.stringify(items)) +const projectClick = (enterprisesUnitName: string, serviceProject: ServiceProjectList) => { Taro.navigateTo({ - - url: `/subPages/pages/policeDetails/index?name=${name}&item=${JSON.stringify(items)}`, + url: `/subPages/police/myEnterprisesUnit/projectDetails/projectDetails?enterprisesUnitName=${enterprisesUnitName}&serviceProject=${JSON.stringify(serviceProject)}`, }) } onMounted(async () => { await getMyServiceProject() }) - - - - - - diff --git a/collect_information/src/subPages/pages/projectDetails/projectDetails.scss b/collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.scss similarity index 62% rename from collect_information/src/subPages/pages/projectDetails/projectDetails.scss rename to collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.scss index 958e0cf..ef412c6 100644 --- a/collect_information/src/subPages/pages/projectDetails/projectDetails.scss +++ b/collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.scss @@ -1,10 +1,11 @@ -.projectDetails{ +.projectDetails { height: 100vh; overflow: hidden; background: #f1f1f1; display: flex; flex-direction: column; - .projectDetailsItem{ + + .projectDetailsItem { margin: 10px 20px 10px 20px; border-radius: 10px; background: #ffffff; @@ -12,19 +13,23 @@ font-size: 28px; line-height: 65px; color: #333333; - .projectDetailsIndex{ + + .projectDetailsIndex { display: flex; flex-wrap: wrap; line-height: 44rpx; margin-bottom: 20px; - .content{ - color: #9b9b9f; - } + + .content { + color: #9b9b9f; + } } } - .projectDetailsTableDrop{ + + .projectDetailsTableDrop { height: 80%; - .projectDetailsTable{ + + .projectDetailsTable { margin: 20px; border-radius: 10px; background: #ffffff; @@ -32,26 +37,30 @@ font-size: 28px; line-height: 50px; color: #333333; - .projectDetailsTableItem{ + + .projectDetailsTableItem { //display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; font-size: 24px; margin-bottom: 15px; - .projectDetailsTableIndex{ - display: flex; - justify-content: flex-end; - text-align: center; - view{ - width: 70px; - margin-right: 20px; - } + + .projectDetailsTableIndex { + display: flex; + justify-content: flex-end; + text-align: center; + + view { + width: 70px; + margin-right: 20px; + } } } } } - .projectDetailsButton{ + + .projectDetailsButton { position: fixed; bottom: 19px; display: flex; @@ -60,12 +69,11 @@ right: 0; width: 100%; } - .nutPopup{ - width: 300px; - height: 100px; - display: flex; - flex-wrap: wrap; + + .nutPopup { + width: 300px; + height: 100px; + display: flex; + flex-wrap: wrap; } } - - diff --git a/collect_information/src/subPages/pages/policeDetails/index.config.ts b/collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.ts similarity index 98% rename from collect_information/src/subPages/pages/policeDetails/index.config.ts rename to collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.ts index c155561..463c9fb 100644 --- a/collect_information/src/subPages/pages/policeDetails/index.config.ts +++ b/collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.ts @@ -1,4 +1,3 @@ export default definePageConfig({ navigationBarTitleText: '项目详情', - }) diff --git a/collect_information/src/subPages/pages/policeDetails/index.vue b/collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.vue similarity index 58% rename from collect_information/src/subPages/pages/policeDetails/index.vue rename to collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.vue index fd91676..b68a6cc 100644 --- a/collect_information/src/subPages/pages/policeDetails/index.vue +++ b/collect_information/src/subPages/police/myEnterprisesUnit/projectDetails/projectDetails.vue @@ -1,33 +1,45 @@ - diff --git a/collect_information/src/subPages/projectManager/myProject/myProject.scss b/collect_information/src/subPages/projectManager/myProject/myProject.scss new file mode 100644 index 0000000..d94d1d9 --- /dev/null +++ b/collect_information/src/subPages/projectManager/myProject/myProject.scss @@ -0,0 +1,35 @@ +.myProject { + height: 100vh; + overflow: hidden; + background: #f1f1f1; + + .myProjectItem { + //height: 20%; + margin: 20px; + border-radius: 10px; + background: #ffffff; + padding: 15px; + font-size: 28px; + line-height: 50px; + color: #333333; + + .myProjectIndex { + color: #9b9b9f; + } + + .project { + display: flex; + justify-content: space-between; + flex-flow: wrap; + text-align: center; + + view { + width: 45%; + height: 100rpx; + border: 1px solid #cccccc; + line-height: 100rpx; + margin: 8px 0 8px 0; + } + } + } +} diff --git a/collect_information/src/subPages/projectManager/myProject/myProject.ts b/collect_information/src/subPages/projectManager/myProject/myProject.ts new file mode 100644 index 0000000..7d4dae7 --- /dev/null +++ b/collect_information/src/subPages/projectManager/myProject/myProject.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '我的项目', +}) diff --git a/collect_information/src/subPages/pages/myProject/myProject.vue b/collect_information/src/subPages/projectManager/myProject/myProject.vue similarity index 61% rename from collect_information/src/subPages/pages/myProject/myProject.vue rename to collect_information/src/subPages/projectManager/myProject/myProject.vue index 68aba24..8cdf561 100644 --- a/collect_information/src/subPages/pages/myProject/myProject.vue +++ b/collect_information/src/subPages/projectManager/myProject/myProject.vue @@ -1,10 +1,9 @@ + diff --git a/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.scss b/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.scss new file mode 100644 index 0000000..4dd980a --- /dev/null +++ b/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.scss @@ -0,0 +1,8 @@ +.form { + .formButton { + display: flex; + margin-top: auto; + justify-content: space-around; + margin-bottom: 30px + } +} diff --git a/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.ts b/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.ts new file mode 100644 index 0000000..65ce4c0 --- /dev/null +++ b/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '项目人员录入', +}) diff --git a/collect_information/src/subPages/pages/form/form.vue b/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.vue similarity index 74% rename from collect_information/src/subPages/pages/form/form.vue rename to collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.vue index 04281ae..98dadd5 100644 --- a/collect_information/src/subPages/pages/form/form.vue +++ b/collect_information/src/subPages/projectManager/securityUserForm/securityUserForm.vue @@ -17,13 +17,17 @@ {{ - dayjs(formData.dateOfBirth).isValid() ? dayjs(formData.dateOfBirth).format('YYYY-MM-DD') : '请选择出生年月' + formData.dateOfBirth ? dayjs(formData.dateOfBirth).format('YYYY-MM-DD') : '请选择出生年月' }} + + + + @@ -39,7 +43,7 @@ 提交 - 重置表单 + 重置表单 - - diff --git a/collect_information/src/utils/index.ts b/collect_information/src/utils/index.ts index 6fab107..e69de29 100644 --- a/collect_information/src/utils/index.ts +++ b/collect_information/src/utils/index.ts @@ -1,67 +0,0 @@ -import Taro from "@tarojs/taro"; - - -/** - * 授权综合逻辑 - * @param {*} scope 权限代表 - * @param {*} successCallback 成功回调 - * @param {*} failCallback 失败回调 - */ -export function pullAuth(scope, successCallback, failCallback) { - const map = new Map([ - ['scope.userInfo', '用户信息'], - ['scope.userLocation', '地理位置'], - ['scope.userLocationBackground', '后台定位'], - ['scope.address', '通信地址'], - ['scope.record', '录音功能'], - ['scope.writePhotosAlbum', '保存到相册'], - ['scope.camera', '摄像头'], - ['scope.invoice', '获取发票'], - ['scope.invoiceTitle', '发票抬头'], - ['scope.werun', '微信运动步数'], - ]) - Taro.getSetting({ - success(res) { - if (!res.authSetting[scope]) { - Taro.authorize({ - scope, - success(){ // 允许授权 - successCallback() - }, - fail(){ // 拒绝授权 - if (map.has(scope)) { - let word = map.get(scope) - Taro.showModal({ - content:`检测到您没打开${word}权限,是否去设置打开?`, - confirmText: "确认", - cancelText:'取消', - success: (res) => { - if(res.confirm){ - Taro.openSetting({ - success: (res) => { - successCallback() - }, - fail: () => { - failCallback() - }, - }) - }else{ - failCallback() - } - } - }) - } else { - Taro.showToast({ - title: '无此授权功能' - }) - failCallback() - } - } - }) - } else { - successCallback() - } - } - }) - -} diff --git a/collect_information/tsconfig.json b/collect_information/tsconfig.json index 39a09c5..91cfcd5 100644 --- a/collect_information/tsconfig.json +++ b/collect_information/tsconfig.json @@ -9,9 +9,9 @@ "noImplicitAny": false, "allowSyntheticDefaultImports": true, "outDir": "lib", - "noUnusedLocals": false, - "noUnusedParameters": false, - "strictNullChecks": false, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, "sourceMap": true, "rootDir": ".", "jsx": "preserve", @@ -21,8 +21,12 @@ "node_modules/@types" ], "paths": { + // TS5090 leading './' "@/*": [ - "src/*" + "./src/*" + ], + "@/types/*": [ + "./types/*" ] } }, diff --git a/collect_information/types/config/index.ts b/collect_information/types/config/index.ts new file mode 100644 index 0000000..4069599 --- /dev/null +++ b/collect_information/types/config/index.ts @@ -0,0 +1,8 @@ +import Taro from "@tarojs/taro"; + +export interface UserConfig { + /** 跳转的首页地址 **/ + toIndex: string; + /** 身份对应的tabBar列表 **/ + tabBarList: Taro.TabBarItem[] +} diff --git a/collect_information/types/global.d.ts b/collect_information/types/global.d.ts index fe190e8..e769f68 100644 --- a/collect_information/types/global.d.ts +++ b/collect_information/types/global.d.ts @@ -22,7 +22,8 @@ declare namespace NodeJS { * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件 * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id */ - TARO_APP_ID: string, + TARO_APP_ID: string + /** 后台服务接口地址 **/ TARO_APP_BASE_API: string } } @@ -31,18 +32,37 @@ declare module '@tarojs/components' { export * from '@tarojs/components/types/index.vue3' } +/** + * 微信小程序用户身份 + */ +type MiniProgramUserIdentity = 'police' | 'project_manager' + /** * 选择 */ -interface SelectNode { - value: T, - label: string, - options?: SelectNode[] - orderIndex?: number, - disabled?: boolean, - extData?: Record +interface SelectNodeVo> { + value: T; + label: string; + orderIndex?: number; + disabled?: boolean; + extData?: E } +/** + * 树 + */ +interface TreeNodeVo> { + value: T; + parentValue: T; + label: string; + orderIndex?: number; + children?: TreeNodeVo[] + extData?: E; +} + +/** + * 全局状态返回 + */ interface JsonResult { code: number; data?: T; @@ -50,13 +70,35 @@ interface JsonResult { } /** - * 树 + * 分页对象 */ -interface TreeNode { - value: T, - parentValue: T, - label: string, - orderIndex?: number, - extData?: Record, - children?: TreeNode[] +interface PagerVo { + size: number, + total: number; + current: number; + records: T[] +} + +/** + * token信息 + */ +interface TokenInfo { + /** token名称 **/ + name: string; + /** token值 **/ + value: string; + /** 拓展属性 **/ + extData: { + /** 身份 **/ + identity: BaseEnum + } +} + +/** + * 基本枚举类型 + */ +interface BaseEnum> { + value: T; + label: string; + extData: E; } diff --git a/collect_information/types/pages/index/index.d.ts b/collect_information/types/pages/index/index.d.ts deleted file mode 100644 index f2e0c2f..0000000 --- a/collect_information/types/pages/index/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -interface PersonnelInformation { - name: string, - sex: number, - dataOfBirth: Date | string, - idCard: string, - phone: string, - householdRegistrationAddress: string, - streetCommunitySmallCommunityIds: string[], - buildingFloorHouseIds: string[] -} - -interface EnterUserInfoSaveOrUpdateParams { - snowFlakeId?: string, - - streetId?: string, - communityId?: string, - smallCommunityId?: string, - buildingId?: string, - floorId?: string, - houseId?: string, - - name: string, - sex: number, - dateOfBirth?: Date | string - idCard: string - phone: string - householdRegistrationAddress?: string - - optFlag: null | 0 | 1 -} - -interface SystemExitsPopulationInformationVo { - snowFlakeId: string, - name: string, - sex: number, - residentialDivisionDetail: string, - createTime: string, - createUserName: string -} diff --git a/collect_information/types/pages/login/index.d.ts b/collect_information/types/pages/login/index.d.ts deleted file mode 100644 index cf4cc2c..0000000 --- a/collect_information/types/pages/login/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -interface LoginUserInfo { - clientType?: string; - avatar?: string; -} - diff --git a/collect_information/types/pages/myProject/index.d.ts b/collect_information/types/pages/myProject/index.d.ts deleted file mode 100644 index d0d8d24..0000000 --- a/collect_information/types/pages/myProject/index.d.ts +++ /dev/null @@ -1,44 +0,0 @@ - interface MyProjectList { - item?:any, - address?: string; - city?: string; - cityName?: string; - contactPersonInfo:ContactPersonInfo; - districts?: string; - districtsName?: string; - name: string; - province?: string; - provinceName: string; - remark?: string; - serviceProjectList: ServiceProjectList[]; - snowFlakeId?: string; - street?: string; - streetName?:string; -} - -interface ContactPersonInfo{ - name:string; - telephone:string -} - -interface ServiceProjectList { - buildingTotal?: number; - houseTotal?: number; - idNumber?: string; - isRecruitSecurity?: null; - name?: string; - remark?: string; - securityUserTotal?: number; - serviceArea?: number; - snowFlakeId?: string; - staffTotal?: number; - type?:string; - projectManagerMiniProgramUserInfo?:ProgramUserInfo -} -interface ProgramUserInfo{ - idCard: null - name: string - telephone: string -} - - diff --git a/collect_information/types/pages/projectDetails/index.d.ts b/collect_information/types/pages/projectDetails/index.d.ts deleted file mode 100644 index 98ff724..0000000 --- a/collect_information/types/pages/projectDetails/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -interface Records{ - createTime?: string; - dateOfBirth?: string; - homeAddress?: string; - idCard?: string; - name?: string; - nativePlace?: string; - remark?: string; - securityNumber?: string; - securityUnitId?: string; - securityUnitName?: string; - serviceProjectId?: string; - snowFlakeId:string; - workPost?:string; - sex?:Sex -} -interface ProjectData { - current?:string; - pages?:string; - records?: Records[]; - size?: string; - total?: string; - data: Records[]; -} - -interface Sex { - value:number, - label:string -} diff --git a/collect_information/types/pages/register/index.d.ts b/collect_information/types/pages/register/index.d.ts deleted file mode 100644 index f759fd7..0000000 --- a/collect_information/types/pages/register/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -interface RegisterParams { - avatar: string; - name: string; - sex:number, - telephone:string, - identity: string; - unitId: any -} diff --git a/collect_information/types/pages/register/index.ts b/collect_information/types/pages/register/index.ts new file mode 100644 index 0000000..b840184 --- /dev/null +++ b/collect_information/types/pages/register/index.ts @@ -0,0 +1,8 @@ +export interface RegisterParams { + avatar: string; + name: string; + sex: number, + telephone: string, + identity: string; + unitId: string +} diff --git a/collect_information/types/request/index.d.ts b/collect_information/types/request/index.d.ts deleted file mode 100644 index e137c22..0000000 --- a/collect_information/types/request/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import Taro from "@tarojs/taro"; - -export interface ApiOptions - extends Omit< - Taro.request.Option, - "url" | "method" | "data" | "success" | "fail" - > { - loading?: boolean; -} diff --git a/collect_information/types/request/index.ts b/collect_information/types/request/index.ts new file mode 100644 index 0000000..fb99bfd --- /dev/null +++ b/collect_information/types/request/index.ts @@ -0,0 +1,5 @@ +import Taro from "@tarojs/taro"; + +export interface ApiOptions extends Omit { + loading?: boolean; +} diff --git a/collect_information/types/subPages/projectManager/myProject/index.ts b/collect_information/types/subPages/projectManager/myProject/index.ts new file mode 100644 index 0000000..bfeba41 --- /dev/null +++ b/collect_information/types/subPages/projectManager/myProject/index.ts @@ -0,0 +1,61 @@ +export interface MyProjectList { + item?: any, + address?: string; + city?: string; + cityName?: string; + contactPersonInfo: ContactPersonInfo; + districts?: string; + districtsName?: string; + name: string; + province?: string; + provinceName: string; + remark?: string; + serviceProjectList: ServiceProjectList[]; + snowFlakeId?: string; + securityUnitId: string; + street?: string; + streetName?: string; +} + +export interface ContactPersonInfo { + name: string; + telephone: string +} + +export interface ServiceProjectList { + buildingTotal?: number; + houseTotal?: number; + idNumber?: string; + isRecruitSecurity?: null; + name?: string; + remark?: string; + securityUserTotal?: number; + serviceArea?: number; + snowFlakeId?: string; + staffTotal?: number; + type?: string; + projectManagerMiniProgramUserInfo?: ProgramUserInfo +} + +export interface ProgramUserInfo { + idCard: null + name: string + telephone: string +} + +export interface ServiceProjectSecurityUserPagerVo { + createTime?: string; + dateOfBirth?: string; + homeAddress?: string; + idCard?: string; + name?: string; + nativePlace?: string; + remark?: string; + securityNumber?: string; + securityUnitId?: string; + securityUnitName?: string; + serviceProjectId?: string; + snowFlakeId: string; + workPost?: string; + sex: BaseEnum +} diff --git a/collect_information/types/pages/form/index.d.ts b/collect_information/types/subPages/projectManager/securityUserForm/index.ts similarity index 71% rename from collect_information/types/pages/form/index.d.ts rename to collect_information/types/subPages/projectManager/securityUserForm/index.ts index 4aed7ab..e02bb69 100644 --- a/collect_information/types/pages/form/index.d.ts +++ b/collect_information/types/subPages/projectManager/securityUserForm/index.ts @@ -1,5 +1,6 @@ -interface formDate { +export interface SecurityUserFormParams { snowFlakeId?: string; + securityUnitId: string; serviceProjectId: string; name?: string; workPost?: string; @@ -7,7 +8,7 @@ interface formDate { sex: number; nativePlace?: string; idCard: string; - dateOfBirth?: Date; + dateOfBirth?: Date | null; securityNumber?: string; remark?: string; homeAddress?: string diff --git a/policeSecurityServer/.DS_Store b/policeSecurityServer/.DS_Store index 4e78b01..8ed5856 100644 Binary files a/policeSecurityServer/.DS_Store and b/policeSecurityServer/.DS_Store differ diff --git a/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java b/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java new file mode 100644 index 0000000..18f25e1 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/common/annotation/CheckOpenApi.java @@ -0,0 +1,17 @@ +package com.changhu.common.annotation; + +import com.changhu.common.enums.OpenApiType; + +import java.lang.annotation.*; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:14 + * @desc 检查openApi + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface CheckOpenApi { + OpenApiType value(); +} diff --git a/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java b/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java new file mode 100644 index 0000000..370b5a2 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/common/enums/OpenApiType.java @@ -0,0 +1,21 @@ +package com.changhu.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:10 + * @desc OpenApiType... + */ +@Getter +@AllArgsConstructor +public enum OpenApiType { + Information_on_enterprises_and_institutions("获取企事业单位信息", Arrays.asList("1fe0aaf3-45a4-4be3-a989-75e914a3f36e", "1fe0aaf3-45a4-a989-75e914a3f36e")); + + private final String desc; + private final List openApiKeys; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java b/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java index c4ded54..059ce7a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java +++ b/policeSecurityServer/src/main/java/com/changhu/common/utils/JavaClassToTsUtil.java @@ -52,8 +52,16 @@ public class JavaClassToTsUtil { * @return ts类型 */ private static String convertJavaTypeToTS(Class type) { - Set> stringList = Set.of(String.class); - Set> boolList = Set.of(Boolean.class, boolean.class); + Set> stringList = Set.of( + String.class, + LocalDateTime.class, + LocalDate.class, + LocalTime.class + ); + Set> boolList = Set.of( + Boolean.class, + boolean.class + ); Set> numberList = Set.of( Integer.class, int.class, Double.class, double.class, @@ -63,15 +71,12 @@ public class JavaClassToTsUtil { BigDecimal.class, Byte.class, byte.class ); - Set> dateList = Set.of(LocalDateTime.class, LocalDate.class, LocalTime.class); if (stringList.contains(type)) { return "string"; } else if (boolList.contains(type)) { return "boolean"; } else if (numberList.contains(type)) { return "number"; - } else if (dateList.contains(type)) { - return "Dayjs"; } else { return "unsupported"; } diff --git a/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java b/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java index 0d429fc..35c4e95 100644 --- a/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java +++ b/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java @@ -3,9 +3,11 @@ package com.changhu.config; import cn.dev33.satoken.interceptor.SaInterceptor; import cn.dev33.satoken.stp.StpUtil; import com.changhu.support.interceptor.JsonBodyInterceptor; +import com.changhu.support.interceptor.OpenApiInterceptor; import com.changhu.support.interceptor.UserTypeInterceptor; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -25,6 +27,7 @@ public class WebConfig implements WebMvcConfigurer { public WebConfig() { whiteList.add("/common/**"); + whiteList.add("/open/**"); whiteList.add("/test/**"); whiteList.add("/login"); whiteList.add("/logout"); @@ -41,6 +44,8 @@ public class WebConfig implements WebMvcConfigurer { whiteList.add("/management/getCheckStatus"); //微信小程序注册 whiteList.add("/miniProgramUser/register"); + //二维码表单录入保安人员 + whiteList.add("/miniProgramUser/qrCodeFormInputSecurityUser"); } @Override @@ -53,6 +58,20 @@ public class WebConfig implements WebMvcConfigurer { registry.addInterceptor(new JsonBodyInterceptor()); // 注册clientType 拦截器 用于校验当前用户是否匹配操作客户端 registry.addInterceptor(new UserTypeInterceptor()); + // 注册开放接口 拦截器 用于校验第三方是否携带指定apiKey + registry.addInterceptor(new OpenApiInterceptor()) + .addPathPatterns("/open/**"); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE") + .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", + "Access-Control-Request-Headers", "Authorization","Token","*") + .allowCredentials(true) + .maxAge(3600); } @Override diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java new file mode 100644 index 0000000..8ec4b5a --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java @@ -0,0 +1,47 @@ +package com.changhu.controller; + +import cn.hutool.core.util.IdUtil; +import com.changhu.common.annotation.CheckOpenApi; +import com.changhu.common.annotation.JsonBody; +import com.changhu.common.enums.OpenApiType; +import com.changhu.common.pojo.vo.SelectNodeVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.service.OpenApiService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:02 + * @desc 可以给第三方对接的controller + */ +@Tag(name = "开放接口") +@JsonBody +@RequestMapping("/open") +public class OpenController { + + @Autowired + private OpenApiService openApiService; + + @Operation(summary = "获取企事业单位列表") + @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) + @GetMapping("/getEnterprisesUnit") + public List> getEnterprisesUnit(@Schema(description = "行政区划代码") @RequestParam String code, + @Schema(description = "行政区划等级") @RequestParam Integer level) { + return openApiService.getEnterprisesUnit(code, level); + } + + @Operation(summary = "企事业单位详情") + @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) + @GetMapping("/enterprisesUnitDetailById") + public EnterprisesUnitDetailDTO enterprisesUnitDetailById(@Schema(description = "企事业单位id") @RequestParam Long enterprisesUnitId) { + return openApiService.enterprisesUnitDetailById(enterprisesUnitId); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java b/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java index f1af734..a9a22a8 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/mapper/ServiceProjectMapper.java @@ -6,6 +6,8 @@ import com.changhu.module.management.pojo.entity.ServiceProject; import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams; import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo; import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,4 +38,12 @@ public interface ServiceProjectMapper extends BaseMapper { */ List getServiceProjectList(@Param("policeUnitId") Long policeUnitId, @Param("projectManagerMiniProgramUserId") Long projectManagerMiniProgramUserId); + + /** + * 获取企事业单位下的服务项目 + * + * @param enterprisesUnitId 企事业单位id + * @return 服务项目列表 + */ + List getServiceProjectByEnterprisesUnitId(@Param("enterprisesUnitId") Long enterprisesUnitId); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java b/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java index 75ce667..8c9db18 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/service/ServiceProjectService.java @@ -6,8 +6,12 @@ import com.changhu.module.management.pojo.entity.ServiceProject; import com.changhu.module.management.pojo.params.ServiceProjectSaveOrUpdateParams; import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams; import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; import com.changhu.support.mybatisplus.pojo.params.PageParams; +import java.util.List; + /** * service_project (服务项目) 服务类 * author: luozhun @@ -29,4 +33,12 @@ public interface ServiceProjectService extends IService { * @param params 参数 */ void saveOrUpdate(ServiceProjectSaveOrUpdateParams params); + + /** + * 获取企事业单位下的服务项目 + * + * @param enterprisesUnitId 企事业单位id + * @return 服务项目列表 + */ + List getServiceProjectByEnterprisesUnitId(Long enterprisesUnitId); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java index 150b684..d4e6e80 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/management/service/impl/ServiceProjectServiceImpl.java @@ -11,9 +11,13 @@ import com.changhu.module.management.pojo.params.ServiceProjectSaveOrUpdateParam import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams; import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo; import com.changhu.module.management.service.ServiceProjectService; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; import com.changhu.support.mybatisplus.pojo.params.PageParams; import org.springframework.stereotype.Service; +import java.util.List; + /** * service_project (服务项目) 服务实现类 * author: luozhun @@ -36,4 +40,9 @@ public class ServiceProjectServiceImpl extends ServiceImpl getServiceProjectByEnterprisesUnitId(Long enterprisesUnitId) { + return baseMapper.getServiceProjectByEnterprisesUnitId(enterprisesUnitId); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/MiniProgramUserController.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/MiniProgramUserController.java index 93e67d8..467439a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/MiniProgramUserController.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/MiniProgramUserController.java @@ -3,6 +3,7 @@ package com.changhu.module.miniProgram.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.changhu.common.annotation.JsonBody; import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams; +import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; import com.changhu.module.miniProgram.service.MiniProgramUserService; @@ -34,6 +35,12 @@ public class MiniProgramUserController { miniProgramUserService.register(params); } + @Operation(summary = "二维码表单录入保安人员") + @PostMapping("/qrCodeFormInputSecurityUser") + public void qrCodeFormInputSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) { + miniProgramUserService.qrCodeFormInputSecurityUser(params); + } + @Operation(summary = "服务项目保安人员分页") @PostMapping("/securityUserPager") public Page securityUserPager(@RequestBody PageParams queryParams) { diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/ProjectManageIndexController.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/ProjectManageIndexController.java index 9419b3a..b64d237 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/ProjectManageIndexController.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/ProjectManageIndexController.java @@ -9,7 +9,11 @@ import com.changhu.module.miniProgram.service.ProjectManageIndexService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.Resource; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -42,7 +46,15 @@ public class ProjectManageIndexController { @Operation(summary = "保存或更新保安人员") @PostMapping("/saveOrUpdateSecurityUser") - public void saveOrUpdateSecurityUser(@RequestBody SaveOrUpdateSecurityUserParams params) { + public void saveOrUpdateSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) { projectManageIndexService.saveOrUpdateSecurityUser(params); } + + @JsonBody(value = false) + @Operation(summary = "获取表单分享二维码") + @GetMapping(value = "/shareForm_QR_Code") + public ResponseEntity shareForm_QR_Code(@Schema(description = "要生成的路径") @RequestParam String path, + @Schema(description = "生成二维码的宽度") @RequestParam(defaultValue = "430") Integer width) { + return projectManageIndexService.shareForm_QR_Code(path, width); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java index 76e5d91..d0b0a8c 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/entity/SecurityUser.java @@ -3,6 +3,7 @@ package com.changhu.module.miniProgram.pojo.entity; import java.io.Serial; import java.io.Serializable; +import com.changhu.common.db.enums.Sex; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import lombok.Data; import lombok.AllArgsConstructor; @@ -56,7 +57,7 @@ public class SecurityUser extends BaseEntity implements Serializable { /** * 性别 */ - private Integer sex; + private Sex sex; /** * 籍贯 diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java index 34ef398..0b4dc16 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java @@ -23,6 +23,10 @@ public class SaveOrUpdateSecurityUserParams { @Schema(description = "服务项目id") private Long serviceProjectId; + @NotNull(message = "保安单位不能为空") + @Schema(description = "保安单位id") + private Long securityUnitId; + @NotBlank(message = "名字不能为空") @Schema(description = "名称") private String name; diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/vo/IndexServiceProjectListVo.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/vo/IndexServiceProjectListVo.java index 961908a..ec5e49d 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/vo/IndexServiceProjectListVo.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/vo/IndexServiceProjectListVo.java @@ -53,6 +53,8 @@ public class IndexServiceProjectListVo { static class ServiceProjectVo { @Schema(description = "服务项目id") private Long snowFlakeId; + @Schema(description = "保安单位id") + private Long securityUnitId; @Schema(description = "项目经理信息") private Dict projectManagerMiniProgramUserInfo; @Schema(description = "服务项目名称") diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/MiniProgramUserService.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/MiniProgramUserService.java index 536d1ed..543e642 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/MiniProgramUserService.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/MiniProgramUserService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser; import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams; +import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; import com.changhu.support.mybatisplus.pojo.params.PageParams; @@ -29,4 +30,11 @@ public interface MiniProgramUserService extends IService { * @return 保安人员 */ Page securityUserPager(PageParams queryParams); + + /** + * 二维码表单录入保安人员 + * + * @param params 参数 + */ + void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/ProjectManageIndexService.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/ProjectManageIndexService.java index ca365ee..69c3f9d 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/ProjectManageIndexService.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/ProjectManageIndexService.java @@ -2,6 +2,9 @@ package com.changhu.module.miniProgram.service; import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.core.io.Resource; +import org.springframework.http.ResponseEntity; import java.util.List; @@ -31,4 +34,9 @@ public interface ProjectManageIndexService { * @param params 保安人员参数 */ void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params); + + /** + * 分享表单录入的二维码 + */ + ResponseEntity shareForm_QR_Code(String path, Integer width); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/MiniProgramUserServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/MiniProgramUserServiceImpl.java index 0c9b091..fb85ceb 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/MiniProgramUserServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/MiniProgramUserServiceImpl.java @@ -13,9 +13,11 @@ import com.changhu.module.miniProgram.mapper.SecurityUserMapper; import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser; import com.changhu.module.miniProgram.pojo.entity.SecurityUser; import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams; +import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; import com.changhu.module.miniProgram.service.MiniProgramUserService; +import com.changhu.module.miniProgram.service.ProjectManageIndexService; import com.changhu.support.mybatisplus.pojo.params.PageParams; import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +37,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl securityUserPager(PageParams queryParams) { return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams()); } + + @Override + public void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params) { + projectManageIndexService.saveOrUpdateSecurityUser(params); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/ProjectManageIndexServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/ProjectManageIndexServiceImpl.java index 50f784e..82ee67c 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/ProjectManageIndexServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/ProjectManageIndexServiceImpl.java @@ -1,5 +1,7 @@ package com.changhu.module.miniProgram.service.impl; +import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; +import cn.binarywang.wx.miniapp.api.WxMaService; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.extension.toolkit.Db; import com.changhu.common.exception.MessageException; @@ -10,9 +12,18 @@ import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo; import com.changhu.module.miniProgram.service.ProjectManageIndexService; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import java.io.*; import java.util.List; import java.util.Optional; @@ -21,12 +32,16 @@ import java.util.Optional; * @createTime 2024/9/10 下午3:50 * @desc ProjectManageIndexServiceImpl... */ +@Slf4j @Service public class ProjectManageIndexServiceImpl implements ProjectManageIndexService { @Autowired private ServiceProjectMapper serviceProjectMapper; + @Autowired + private WxMaService wxMaService; + @Override public List getMyServiceProjectList() { return serviceProjectMapper.getServiceProjectList(null, UserUtil.getUserId()); @@ -43,8 +58,6 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService @Override public void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params) { SecurityUser securityUser = BeanUtil.copyProperties(params, SecurityUser.class); - //填充保安单位 - securityUser.setSecurityUnitId(UserUtil.getUnitId()); //新增的情况 Long snowFlakeId = securityUser.getSnowFlakeId(); if (snowFlakeId == null) { @@ -74,4 +87,18 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService throw new MessageException(); } } + + @Override + public ResponseEntity shareForm_QR_Code(String path, Integer width) { + WxMaQrcodeService qrcodeService = wxMaService.getQrcodeService(); + try { + File qrcodeFile = qrcodeService.createQrcode(path, width); + return ResponseEntity.ok() + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + qrcodeFile.getName()) + .contentType(MediaType.APPLICATION_OCTET_STREAM) + .body(new FileSystemResource(qrcodeFile)); + } catch (WxErrorException e) { + throw new MessageException("生成表单二维码失败:{}", e.getMessage()); + } + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/EnterprisesUnitDetailDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/EnterprisesUnitDetailDTO.java new file mode 100644 index 0000000..096f36b --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/EnterprisesUnitDetailDTO.java @@ -0,0 +1,43 @@ +package com.changhu.pojo.dto; + +import cn.hutool.core.util.DesensitizedUtil; +import com.changhu.common.annotation.Desensitized; +import com.changhu.common.db.enums.IsOrNot; +import com.changhu.common.db.enums.ServiceProjectType; +import com.changhu.common.db.enums.Sex; +import com.changhu.module.management.pojo.model.ContactPersonInfo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/10 上午9:13 + * @desc EnterprisesUnitDetailDTO... + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class EnterprisesUnitDetailDTO { + @Schema(description = "企事业单位id") + private Long snowFlakeId; + @Schema(description = "名字") + private String name; + @Schema(description = "地址") + private String address; + @Schema(description = "联系人") + private ContactPersonInfo contactPersonInfo; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "服务项目列表") + private List serviceProjectList; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectDTO.java b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectDTO.java new file mode 100644 index 0000000..7a10a63 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/dto/ServiceProjectDTO.java @@ -0,0 +1,110 @@ +package com.changhu.pojo.dto; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.changhu.common.db.enums.IsOrNot; +import com.changhu.common.db.enums.ServiceProjectType; +import com.changhu.common.db.enums.Sex; +import com.changhu.module.management.pojo.model.LegalPersonInfo; +import com.changhu.support.fastjson2.serializer.MinioPrefixSerializer; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/10 上午9:35 + * @desc ServiceProjectDTO... + */ +@Data +public class ServiceProjectDTO { + @Schema(description = "服务项目id") + private Long snowFlakeId; + @Schema(description = "项目经理信息") + private ProjectManagerInfo projectManagerInfo; + @Schema(description = "保安单位信息") + private SecurityUnitInfo securityUnitInfo; + @Schema(description = "名字") + private String name; + @Schema(description = "类型") + private ServiceProjectType type; + @Schema(description = "是否自招保安") + private IsOrNot isRecruitSecurity; + @Schema(description = "保安证号") + private String idNumber; + @Schema(description = "服务面积") + private Double serviceArea; + @Schema(description = "楼栋数量") + private Integer buildingTotal; + @Schema(description = "户数") + private Integer houseTotal; + @Schema(description = "工作人员数量") + private Integer staffTotal; + @Schema(description = "保安人员数量") + private Integer securityUserTotal; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "保安人员列表") + private List securityUserList; + + @Data + static class SecurityUnitInfo { + @Schema(description = "保安单位名称") + private String name; + @Schema(description = "统一社会编码") + private String socialCode; + @JSONField(serializeUsing = MinioPrefixSerializer.class) + @Schema(description = "营业执照") + private String businessLicense; + @Schema(description = "法人信息") + private LegalPersonInfo legalPersonInfo; + @Schema(description = "详细地址") + private String address; + @Schema(description = "公司性质") + private String nature; + } + + @Data + static class ProjectManagerInfo { + @Schema(description = "名称") + private String name; + @Schema(description = "性别") + private Sex sex; + @Schema(description = "手机号") + private String telephone; + @Schema(description = "身份证") + private String idCard; + } + + @Data + static class SecurityUserInfo { + @Schema(description = "id") + private Long snowFlakeId; + @Schema(description = "名字") + private String name; + @Schema(description = "手机号") + private String telephone; + @Schema(description = "工作岗位") + private String workPost; + @Schema(description = "性别") + private Sex sex; + @Schema(description = "户籍地") + private String nativePlace; + @Schema(description = "身份证") + private String idCard; + @Schema(description = "出身日期") + private java.time.LocalDate dateOfBirth; + @Schema(description = "保安证号") + private String securityNumber; + @Schema(description = "家庭住址") + private String homeAddress; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建时间") + private String createTime; + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java new file mode 100644 index 0000000..cb97c56 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java @@ -0,0 +1,30 @@ +package com.changhu.service; + +import com.changhu.common.pojo.vo.SelectNodeVo; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:28 + * @desc 开放接口 + */ +public interface OpenApiService { + /** + * 获取企事业单位列表 + * + * @param code 行政区划代码 + * @param level 行政区划等级 + * @return 企事业单位列表 + */ + List> getEnterprisesUnit(String code, Integer level); + + /** + * 企事业单位详情 + * + * @param enterprisesUnitId 单位id + * @return 企事业单位详情 + */ + EnterprisesUnitDetailDTO enterprisesUnitDetailById(Long enterprisesUnitId); +} diff --git a/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java new file mode 100644 index 0000000..88a3bf4 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java @@ -0,0 +1,60 @@ +package com.changhu.service.impl; + +import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.exception.MessageException; +import com.changhu.common.pojo.vo.SelectNodeVo; +import com.changhu.module.management.pojo.entity.EnterprisesUnit; +import com.changhu.module.management.service.ServiceProjectService; +import com.changhu.pojo.dto.EnterprisesUnitDetailDTO; +import com.changhu.pojo.dto.ServiceProjectDTO; +import com.changhu.service.OpenApiService; +import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:29 + * @desc OpenApiServiceImpl... + */ +@Service +public class OpenApiServiceImpl implements OpenApiService { + + @Autowired + private ServiceProjectService serviceProjectService; + + @Override + public List> getEnterprisesUnit(String code, Integer level) { + return Db.lambdaQuery(EnterprisesUnit.class) + .eq(level == 1, EnterprisesUnit::getProvince, code) + .eq(level == 2, EnterprisesUnit::getCity, code) + .eq(level == 3, EnterprisesUnit::getDistricts, code) + .eq(level == 4, EnterprisesUnit::getStreet, code) + .list() + .stream() + .map(item -> SelectNodeVo.builder() + .value(item.getSnowFlakeId()) + .label(item.getName()) + .build()) + .toList(); + } + + @Override + public EnterprisesUnitDetailDTO enterprisesUnitDetailById(Long enterprisesUnitId) { + return Db.lambdaQuery(EnterprisesUnit.class) + .eq(BaseEntity::getSnowFlakeId, enterprisesUnitId) + .oneOpt() + .map(item -> EnterprisesUnitDetailDTO.builder() + .snowFlakeId(item.getSnowFlakeId()) + .name(item.getName()) + .address(item.getAddress()) + .contactPersonInfo(item.getContactPersonInfo()) + .remark(item.getRemark()) + .serviceProjectList(serviceProjectService.getServiceProjectByEnterprisesUnitId(item.getSnowFlakeId())) + .createTime(item.getCreateTime()) + .build()) + .orElseThrow(() -> new MessageException("企事业单位不存在")); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/support/fastjson2/serializer/MinioPrefixSerializer.java b/policeSecurityServer/src/main/java/com/changhu/support/fastjson2/serializer/MinioPrefixSerializer.java new file mode 100644 index 0000000..5142540 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/fastjson2/serializer/MinioPrefixSerializer.java @@ -0,0 +1,27 @@ +package com.changhu.support.fastjson2.serializer; + +import cn.hutool.extra.spring.SpringUtil; +import com.alibaba.fastjson2.JSONWriter; +import com.alibaba.fastjson2.writer.ObjectWriter; + +import java.lang.reflect.Type; + +/** + * @author 20252 + * @createTime 2024/10/10 下午3:19 + * @desc MinioPrefixSerializer... + */ +public class MinioPrefixSerializer implements ObjectWriter { + + private final String minioPrefix = SpringUtil.getProperty("minio.url"); + + public static final MinioPrefixSerializer instance = new MinioPrefixSerializer(); + + private MinioPrefixSerializer() { + } + + @Override + public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) { + jsonWriter.writeString(minioPrefix + object); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java new file mode 100644 index 0000000..e0cc567 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/interceptor/OpenApiInterceptor.java @@ -0,0 +1,38 @@ +package com.changhu.support.interceptor; + +import com.changhu.common.annotation.CheckOpenApi; +import com.changhu.common.exception.MessageException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/10/9 下午5:05 + * @desc OpenApiInterceptor... + */ +@Slf4j +public class OpenApiInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) { + String header = request.getHeader("X-API-KEY"); + log.info("apiKey:{} {} 请求:{}", header, LocalDateTime.now(), request.getRequestURI()); + if (handler instanceof HandlerMethod handlerMethod) { + CheckOpenApi methodAnnotation = handlerMethod.getMethodAnnotation(CheckOpenApi.class); + if (methodAnnotation != null) { + List openApiKeys = methodAnnotation.value().getOpenApiKeys(); + if (!openApiKeys.contains(header)) { + throw new MessageException("openApiKey error!"); + } + } + } + return true; + } +} diff --git a/policeSecurityServer/src/main/resources/env/dev/application.yml b/policeSecurityServer/src/main/resources/env/dev/application.yml index d108324..ac28684 100644 --- a/policeSecurityServer/src/main/resources/env/dev/application.yml +++ b/policeSecurityServer/src/main/resources/env/dev/application.yml @@ -23,7 +23,7 @@ knife4j: spring: application: # 服务名称 - name: managementDevServer + name: policeSecurityDevServer servlet: multipart: # 设置单个文件最大大小为500MB @@ -90,10 +90,10 @@ spring: cache-names: common data: redis: - database: 10 - password: lonsung301 + database: 1 + password: redis_csPDNr port: 6380 - host: 172.10.10.238 + host: 118.253.177.137 timeout: 10s lettuce: pool: @@ -116,7 +116,7 @@ logging: config: classpath:conf/log4j2.xml minio: - url: http://118.253.177.137:9000 + url: https://www.hnjinglian.cn:9000 accessKey: admin secretKey: lonsung301 bucketName: police-security-dev @@ -144,9 +144,9 @@ sa-token: wx: miniapp: #微信小程序的appid - appid: wx8902ddbfddb820d1 + appid: wx0acd1c4fcf94bdd3 #微信小程序的Secret - secret: 8674decea33df3362245937444944596 + secret: 4b700dbacb42ef258537ddc61d964a17 msgDataFormat: JSON project: diff --git a/policeSecurityServer/src/main/resources/env/prod/application.yml b/policeSecurityServer/src/main/resources/env/prod/application.yml index 6130758..8a3d696 100644 --- a/policeSecurityServer/src/main/resources/env/prod/application.yml +++ b/policeSecurityServer/src/main/resources/env/prod/application.yml @@ -1,5 +1,5 @@ server: - port: 8090 + port: 8765 springdoc: swagger-ui: @@ -23,10 +23,7 @@ knife4j: spring: application: # 服务名称 - name: managementProdServer - mvc: - # 如果找不到对应的handler 就抛出404异常 - throw-exception-if-no-handler-found: true + name: policeSecurityProdServer servlet: multipart: # 设置单个文件最大大小为500MB @@ -42,9 +39,9 @@ spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://172.10.10.238:3306/management_prod?serverTimezone=Asia/Shanghai&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false - username: management_prod - password: lonsung301 + url: jdbc:mysql://118.253.177.137:3306/police_security_dev?serverTimezone=Asia/Shanghai&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: police_security_dev + password: GejDeCNj3ZBSNxSP # druid 连接池管理 druid: # 初始化时建立物理连接的个数 @@ -91,17 +88,12 @@ spring: cache: type: redis cache-names: common - mail: - host: smtp.qq.com - port: 587 - username: 2025254074@qq.com - password: vgkvmhlwfogucbfd data: redis: database: 0 - password: lonsung301 + password: redis_csPDNr port: 6380 - host: 172.10.10.238 + host: 118.253.177.137 timeout: 10s lettuce: pool: @@ -124,10 +116,10 @@ logging: config: classpath:conf/log4j2.xml minio: - url: http://172.10.10.238:9000 + url: https://www.hnjinglian.cn:9000 accessKey: admin secretKey: lonsung301 - bucketName: management-prod + bucketName: police-security-dev sa-token: # token 名称(同时也是 cookie 名称) @@ -146,6 +138,16 @@ sa-token: is-log: true # 是否尝试从 cookie 里读取 token is-read-cookie: false + # jwt秘钥 + jwt-secret-key: a29216f8-cd60-4e96-89c5-ab6012159052 + +wx: + miniapp: + #微信小程序的appid + appid: wx0acd1c4fcf94bdd3 + #微信小程序的Secret + secret: 4b700dbacb42ef258537ddc61d964a17 + msgDataFormat: JSON project: env: prod diff --git a/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml b/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml index b18db61..dbe90f9 100644 --- a/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml +++ b/policeSecurityServer/src/main/resources/mapper/ServiceProjectMapper.xml @@ -48,6 +48,7 @@ ad4.name as 'streetName', JSON_ARRAYAGG(JSON_OBJECT( 'snowFlakeId', sp.snow_flake_id, + 'securityUnitId',sp.security_unit_id, 'name', sp.name, 'type', sp.type, 'isRecruitSecurity', sp.is_recruit_security, @@ -81,4 +82,56 @@ group by eu.snow_flake_id order by any_value(sp.create_time) desc; + + + + + + diff --git a/securityManagement/src/main.ts b/securityManagement/src/main.ts index ed5c439..a2ab554 100644 --- a/securityManagement/src/main.ts +++ b/securityManagement/src/main.ts @@ -2,11 +2,12 @@ import {createApp} from 'vue' import App from '@/App.vue' import '@/reset.css' import './index.css' + +// iconfont css +import "@/assets/iconfont/iconfont.css"; // 公共样式 import '@/assets/scss/common.scss' import '@/assets/scss/myAntD.scss' -// iconfont css -import "@/assets/iconfont/iconfont.css"; // vue Router import router from "@/router"; // pinia stores diff --git a/securityManagement/src/views/serviceManagement/index.vue b/securityManagement/src/views/serviceManagement/index.vue index 817c081..bb325e2 100644 --- a/securityManagement/src/views/serviceManagement/index.vue +++ b/securityManagement/src/views/serviceManagement/index.vue @@ -126,17 +126,17 @@ const columns: TableProps['columns'] = [ dataIndex:'isRecruitSecurity', title: '是否自招保安', customRender: ({text}) => {text?.label}, - width:100 + width:120 }, { dataIndex:'idNumber', - title: '证件号', + title: '保安服务许可证', width:170 }, { dataIndex:'serviceArea', title:'服务区域面积', - width:100 + width:120 }, { dataIndex:'buildingTotal', @@ -151,17 +151,17 @@ const columns: TableProps['columns'] = [ { dataIndex:'staffTotal', title:'工作人员数量', - width:100 + width:120 }, { dataIndex:'securityUserTotal', title:'保安人员数量', - width:100 + width:120 }, { dataIndex:'createUserName', title:'创建人名称', - width:100 + width:110 }, { dataIndex: 'createTime', @@ -190,7 +190,7 @@ const columns: TableProps['columns'] = [ message.success(resp.message) await tableRef.value?.requestGetTableData() }}> - 删除 + 删除 { // console.log(record) @@ -275,6 +275,7 @@ const formItemOptions = ref } - return - { - const resp = await api.post('/management/disableOrEnableMiniProgramUser', { - dataId: record.snowFlakeId, - unitOptType: UNIT_TYPE.security - }) - message.success(resp.message) - await tableRef.value?.requestGetTableData() - }} - >{record.isEnable.value === 0 ? '禁用' : '启用'} - - + return ( + record.isEnable.value === 0? { + const resp = await api.post('/management/disableOrEnableMiniProgramUser', { + dataId: record.snowFlakeId, + unitOptType: UNIT_TYPE.security + }) + message.success(resp.message) + await tableRef.value?.requestGetTableData() + }} + >{record.isEnable.value === 0 ? '禁用' : '启用'} + : { + const resp = await api.post('/management/disableOrEnableMiniProgramUser', { + dataId: record.snowFlakeId, + unitOptType: UNIT_TYPE.security + }) + message.success(resp.message) + await tableRef.value?.requestGetTableData() + }} + >{record.isEnable.value === 0 ? '禁用' : '启用'} + + ) } }, ]