| @@ -1,8 +0,0 @@ | |||||
| <template> | |||||
| <div></div> | |||||
| </template> | |||||
| <script> | |||||
| export default { | |||||
| name: '' | |||||
| } | |||||
| </script> | |||||
| @@ -1,153 +0,0 @@ | |||||
| <template> | |||||
| <div> | |||||
| <v-data-table class="pa-3 pt-5" :headers="headers"> | |||||
| <template v-slot:top> | |||||
| <v-toolbar flat> | |||||
| <v-dialog | |||||
| v-model="dialog" | |||||
| max-width="500px" | |||||
| > | |||||
| <template v-slot:activator="{ on, attrs }"> | |||||
| <v-spacer></v-spacer> | |||||
| <v-btn | |||||
| color="primary" | |||||
| v-bind="attrs" | |||||
| v-on="on" | |||||
| > | |||||
| <v-icon large>mdi-plus-circle</v-icon> | |||||
| 新增 | |||||
| </v-btn> | |||||
| </template> | |||||
| <v-card> | |||||
| <v-card-title> | |||||
| <!-- <span class="headline">{{ formTitle }}</span>--> | |||||
| </v-card-title> | |||||
| <!-- <v-card-text>--> | |||||
| <!-- <v-container>--> | |||||
| <!-- <v-row>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.name"--> | |||||
| <!-- label="Dessert name"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.calories"--> | |||||
| <!-- label="Calories"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.fat"--> | |||||
| <!-- label="Fat (g)"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.carbs"--> | |||||
| <!-- label="Carbs (g)"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.protein"--> | |||||
| <!-- label="Protein (g)"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- </v-row>--> | |||||
| <!-- </v-container>--> | |||||
| <!-- </v-card-text>--> | |||||
| <v-card-actions> | |||||
| <v-spacer></v-spacer> | |||||
| <!-- <v-btn--> | |||||
| <!-- color="blue darken-1"--> | |||||
| <!-- text--> | |||||
| <!-- @click="close"--> | |||||
| <!-- >--> | |||||
| <!-- Cancel--> | |||||
| <!-- </v-btn>--> | |||||
| <!-- <v-btn--> | |||||
| <!-- color="blue darken-1"--> | |||||
| <!-- text--> | |||||
| <!-- @click="save"--> | |||||
| <!-- >--> | |||||
| <!-- Save--> | |||||
| <!-- </v-btn>--> | |||||
| </v-card-actions> | |||||
| </v-card> | |||||
| </v-dialog> | |||||
| <!-- <v-dialog v-model="dialogDelete" max-width="500px">--> | |||||
| <!-- <v-card>--> | |||||
| <!-- <v-card-title class="headline">Are you sure you want to delete this item?</v-card-title>--> | |||||
| <!-- <v-card-actions>--> | |||||
| <!-- <v-spacer></v-spacer>--> | |||||
| <!-- <v-btn color="blue darken-1" text @click="closeDelete">Cancel</v-btn>--> | |||||
| <!-- <v-btn color="blue darken-1" text @click="deleteItemConfirm">OK</v-btn>--> | |||||
| <!-- <v-spacer></v-spacer>--> | |||||
| <!-- </v-card-actions>--> | |||||
| <!-- </v-card>--> | |||||
| <!-- </v-dialog>--> | |||||
| </v-toolbar> | |||||
| </template> | |||||
| </v-data-table> | |||||
| </div> | |||||
| </template> | |||||
| <script> | |||||
| export default { | |||||
| name: '', | |||||
| data() { | |||||
| return { | |||||
| dialog: false, | |||||
| headers: [ | |||||
| {text: '主機名稱', value: 'hostname'}, | |||||
| {text: '資產群組', value: 'type'}, | |||||
| {text: '對應應用系統', value: 'descript'}, | |||||
| {text: 'IP1', value: 'ip1'}, | |||||
| {text: 'IP2', value: 'ip2'}, | |||||
| {text: '機型(型號)', value: 'model'}, | |||||
| {text: '環境別', value: 'environment'}, | |||||
| {text: '放置地點', value: 'position'}, | |||||
| {text: '機櫃編號', value: 'position_number'}, | |||||
| {text: '數量', value: 'amount'}, | |||||
| {text: '擁有者', value: 'owner_department'}, | |||||
| {text: '保管單位', value: 'keep_department'}, | |||||
| {text: '保管者', value: 'keeper'}, | |||||
| {text: '備註', value: 'remark'}, | |||||
| ], | |||||
| items: [], | |||||
| } | |||||
| }, | |||||
| mounted() { | |||||
| this.getHardwares(); | |||||
| }, | |||||
| methods: { | |||||
| async getHardwares() { | |||||
| this.items = await this.$axios.get('/hardware/hardwares'); | |||||
| } | |||||
| } | |||||
| } | |||||
| </script> | |||||
| @@ -1,7 +1,8 @@ | |||||
| <template> | <template> | ||||
| <v-app id="inspire"> | |||||
| <v-app> | |||||
| <v-navigation-drawer | <v-navigation-drawer | ||||
| v-model="drawer" | v-model="drawer" | ||||
| width="130" | |||||
| :clipped="$vuetify.breakpoint.lgAndUp" | :clipped="$vuetify.breakpoint.lgAndUp" | ||||
| app | app | ||||
| > | > | ||||
| @@ -41,13 +42,15 @@ | |||||
| v-else | v-else | ||||
| :key="item.text" | :key="item.text" | ||||
| link | link | ||||
| dense | |||||
| :to="item.route" | :to="item.route" | ||||
| class="px-0 pl-5" | |||||
| > | > | ||||
| <v-list-item-action> | |||||
| <v-icon>{{ item.icon }}</v-icon> | |||||
| </v-list-item-action> | |||||
| <!-- <v-list-item-action>--> | |||||
| <!-- <v-icon>{{ item.icon }}</v-icon>--> | |||||
| <!-- </v-list-item-action>--> | |||||
| <v-list-item-content> | <v-list-item-content> | ||||
| <v-list-item-title> | |||||
| <v-list-item-title class="font-weight-bold subtitle-2"> | |||||
| {{ item.text }} | {{ item.text }} | ||||
| </v-list-item-title> | </v-list-item-title> | ||||
| </v-list-item-content> | </v-list-item-content> | ||||
| @@ -60,6 +63,7 @@ | |||||
| app | app | ||||
| color="blue darken-3" | color="blue darken-3" | ||||
| dark | dark | ||||
| dense | |||||
| > | > | ||||
| <v-app-bar-nav-icon @click.stop="drawer = !drawer" /> | <v-app-bar-nav-icon @click.stop="drawer = !drawer" /> | ||||
| <v-toolbar-title | <v-toolbar-title | ||||
| @@ -85,11 +89,9 @@ | |||||
| </v-btn> | </v-btn> | ||||
| </v-app-bar> | </v-app-bar> | ||||
| <v-content> | <v-content> | ||||
| <v-container class="grey lighten-5"> | |||||
| <keep-alive> | <keep-alive> | ||||
| <router-view></router-view> | <router-view></router-view> | ||||
| </keep-alive> | </keep-alive> | ||||
| </v-container> | |||||
| </v-content> | </v-content> | ||||
| <v-snackbar v-model="error" top :timeout="2500"> | <v-snackbar v-model="error" top :timeout="2500"> | ||||
| {{ message }} | {{ message }} | ||||
| @@ -116,6 +118,7 @@ | |||||
| drawer: null, | drawer: null, | ||||
| error: false, | error: false, | ||||
| message: "", | message: "", | ||||
| items: [{ text: '資訊資產群組', route: '/asset_group' }], | |||||
| }), | }), | ||||
| created(){ | created(){ | ||||
| this.$root.$on('showError', (message) => { | this.$root.$on('showError', (message) => { | ||||
| @@ -128,27 +131,25 @@ | |||||
| let roles = localStorage.getItem('roles'); | let roles = localStorage.getItem('roles'); | ||||
| return (roles != null && roles.indexOf('ADMIN') >= 0 ); | return (roles != null && roles.indexOf('ADMIN') >= 0 ); | ||||
| }, | }, | ||||
| items() { | |||||
| let ret = [ | |||||
| { icon: 'mdi-history', text: '資訊資產群組', route: '/asset_group' }, | |||||
| { icon: 'mdi-history', text: '硬體', route: '/hardware' }, | |||||
| { icon: 'mdi-history', text: '軟體', route: '/software' }, | |||||
| { icon: 'mdi-history', text: '資料與文件', route: '/fileAndData' }, | |||||
| { icon: 'mdi-history', text: '人員', route: '/person' }, | |||||
| ]; | |||||
| // if (this.isAdmin) { | |||||
| // ret.push({ icon: 'mdi-account', text: '帳號權限管理', route: '/account' }); | |||||
| // ret.push({ icon: 'mdi-poll-box', text: '報表組態管理', route: '/report_conf' }); | |||||
| // ret.push({ icon: 'mdi-message', text: '通知信管理', route: '/notice' }); | |||||
| // ret.push({ icon: 'mdi-account-details', text: '收信人管理', route: '/receiver' }); | |||||
| // } | |||||
| return ret; | |||||
| } | |||||
| }, | |||||
| mounted() { | |||||
| this.getRoutes(); | |||||
| }, | }, | ||||
| methods: { | methods: { | ||||
| logout(){ | logout(){ | ||||
| this.$emit("authenticated", null); | this.$emit("authenticated", null); | ||||
| }, | }, | ||||
| async getRoutes() { | |||||
| this.$axios.get('/routes').then((resp) => { | |||||
| resp.data.data.forEach((item) => { | |||||
| let route = {'text': '', 'route': ''}; | |||||
| route.text = item.descript; | |||||
| route.route = `/inventory/${item.tablename}`; | |||||
| this.items.push(route); | |||||
| }); | |||||
| console.log(this.items); | |||||
| }); | |||||
| }, | |||||
| } | } | ||||
| } | } | ||||
| </script> | </script> | ||||
| @@ -0,0 +1,280 @@ | |||||
| <template> | |||||
| <div> | |||||
| <v-data-table class="pa-3 pt-5" :headers="headers" :items="items"> | |||||
| <template v-slot:top> | |||||
| <v-toolbar flat> | |||||
| <v-toolbar-title class="title font-weight-bold">{{title}}</v-toolbar-title> | |||||
| <v-divider | |||||
| class="mx-4" | |||||
| inset | |||||
| vertical | |||||
| /> | |||||
| <v-spacer /> | |||||
| <v-dialog | |||||
| v-model="dialogInsert" | |||||
| max-width="500px" | |||||
| @click:outside="close" | |||||
| > | |||||
| <template v-slot:activator="{ on, attrs }"> | |||||
| <v-btn | |||||
| color="white" | |||||
| class="primary" | |||||
| v-bind="attrs" | |||||
| v-on="on" | |||||
| icon | |||||
| > | |||||
| <v-icon>mdi-plus</v-icon> | |||||
| </v-btn> | |||||
| </template> | |||||
| <v-card> | |||||
| <v-card-title> | |||||
| <span class="headline font-weight-bold">新增</span> | |||||
| </v-card-title> | |||||
| <!-- <v-card-text>--> | |||||
| <!-- <v-container>--> | |||||
| <!-- <v-row>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.name"--> | |||||
| <!-- label="Dessert name"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.calories"--> | |||||
| <!-- label="Calories"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.fat"--> | |||||
| <!-- label="Fat (g)"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.carbs"--> | |||||
| <!-- label="Carbs (g)"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- <v-col--> | |||||
| <!-- cols="12"--> | |||||
| <!-- sm="6"--> | |||||
| <!-- md="4"--> | |||||
| <!-- >--> | |||||
| <!-- <v-text-field--> | |||||
| <!-- v-model="editedItem.protein"--> | |||||
| <!-- label="Protein (g)"--> | |||||
| <!-- ></v-text-field>--> | |||||
| <!-- </v-col>--> | |||||
| <!-- </v-row>--> | |||||
| <!-- </v-container>--> | |||||
| <!-- </v-card-text>--> | |||||
| <v-card-actions> | |||||
| <v-spacer></v-spacer> | |||||
| <v-btn | |||||
| color="blue darken-1" | |||||
| text | |||||
| @click="close" | |||||
| > | |||||
| 取消 | |||||
| </v-btn> | |||||
| <v-btn | |||||
| color="blue darken-1" | |||||
| text | |||||
| @click="insertOne" | |||||
| > | |||||
| 新增 | |||||
| </v-btn> | |||||
| </v-card-actions> | |||||
| </v-card> | |||||
| </v-dialog> | |||||
| </v-toolbar> | |||||
| </template> | |||||
| <template v-slot:item.actions="{ item }"> | |||||
| <v-dialog | |||||
| v-model="dialogModify" | |||||
| @click:outside="close" | |||||
| > | |||||
| <template v-slot:activator="{ on, attrs }"> | |||||
| <v-btn | |||||
| v-bind="attrs" | |||||
| v-on="on" | |||||
| icon | |||||
| @click="modifyItem = item;" | |||||
| > | |||||
| <v-icon>mdi-pencil</v-icon> | |||||
| </v-btn> | |||||
| </template> | |||||
| <v-card> | |||||
| <v-card-title> | |||||
| <span class="headline font-weight-bold">修改</span> | |||||
| </v-card-title> | |||||
| <v-card-text> | |||||
| <v-container> | |||||
| <v-row> | |||||
| <v-col | |||||
| v-for="(val, key, index) in modifyItem" | |||||
| :key="index" | |||||
| cols="12" | |||||
| sm="6" | |||||
| md="4" | |||||
| class="d-flex" | |||||
| > | |||||
| <v-text-field | |||||
| :label="headers[index].text" | |||||
| v-bind:value="val" | |||||
| v-on:input="oninput(key, $event)" | |||||
| ></v-text-field> | |||||
| </v-col> | |||||
| </v-row> | |||||
| </v-container> | |||||
| </v-card-text> | |||||
| <v-card-actions> | |||||
| <v-spacer></v-spacer> | |||||
| <v-btn | |||||
| color="blue darken-1" | |||||
| text | |||||
| @click="close" | |||||
| > | |||||
| 取消 | |||||
| </v-btn> | |||||
| <v-btn | |||||
| color="blue darken-1" | |||||
| text | |||||
| @click="modifyOne(item)" | |||||
| > | |||||
| 修改 | |||||
| </v-btn> | |||||
| </v-card-actions> | |||||
| </v-card> | |||||
| </v-dialog> | |||||
| <v-icon | |||||
| small | |||||
| @click="deleteOne(item)" | |||||
| > | |||||
| mdi-delete | |||||
| </v-icon> | |||||
| </template> | |||||
| </v-data-table> | |||||
| </div> | |||||
| </template> | |||||
| <script> | |||||
| export default { | |||||
| name: '', | |||||
| data() { | |||||
| return { | |||||
| dialogInsert: false, | |||||
| dialogModify: false, | |||||
| title: '', | |||||
| headers: [ | |||||
| ], | |||||
| items: [], | |||||
| modifyItem: {} | |||||
| } | |||||
| }, | |||||
| mounted() { | |||||
| this.getHeaders(); | |||||
| this.getInventories(); | |||||
| console.log(this.$route.params.tablename); | |||||
| }, | |||||
| computed: { | |||||
| tablename() { | |||||
| return this.$route.params.tablename; | |||||
| } | |||||
| }, | |||||
| watch: { | |||||
| tablename() { | |||||
| this.headers = []; | |||||
| this.headers = []; | |||||
| this.getHeaders(); | |||||
| this.items = []; | |||||
| this.getInventories(); | |||||
| this.title = ''; | |||||
| this.getTitle(); | |||||
| }, | |||||
| modifyItem() { | |||||
| // this.modifyItem.sort | |||||
| console.log(this.modifyItem); | |||||
| }, | |||||
| }, | |||||
| methods: { | |||||
| log() { | |||||
| alert('as'); | |||||
| }, | |||||
| oninput(key, val) { | |||||
| console.log(val); | |||||
| this.$set(this.modifyItem, key, val); | |||||
| console.log(this.modifyItem); | |||||
| }, | |||||
| async getTitle() { | |||||
| this.$axios.get(`/title?tablename=${this.tablename}`).then((resp) => { | |||||
| this.title = `${resp.data.data}類`; | |||||
| }); | |||||
| }, | |||||
| async getHeaders() { | |||||
| this.$axios.get(`/headers?tablename=${this.tablename}`).then((resp) => { | |||||
| resp.data.data.forEach((item) => { | |||||
| let header = {}; | |||||
| header.text = item.descript; | |||||
| header.value = item.colname; | |||||
| this.headers.push(header); | |||||
| }); | |||||
| this.headers.push({text: '', value: 'actions', sortable: false}); | |||||
| }); | |||||
| }, | |||||
| async getInventories() { | |||||
| this.$axios.get(`/inventory?tablename=${this.tablename}`).then((resp) => { | |||||
| console.log(resp); | |||||
| this.items = resp.data.data; | |||||
| }); | |||||
| }, | |||||
| async insertOne(item, prop) { | |||||
| console.log(item); | |||||
| console.log(prop); | |||||
| }, | |||||
| async close() { | |||||
| this.dialogInsert = false; | |||||
| this.dialogModify = false; | |||||
| }, | |||||
| async modifyOne(item) { | |||||
| item.tablename = this.tablename; | |||||
| console.log(item); | |||||
| this.$axios.put(`/inventory?`, item).then(() => { | |||||
| this.getInventories(); | |||||
| this.close(); | |||||
| } | |||||
| ); | |||||
| }, | |||||
| async deleteOne(item) { | |||||
| let yes = confirm('確定刪除'); | |||||
| if (yes) { | |||||
| alert('已刪除'); | |||||
| } | |||||
| console.log(item); | |||||
| }, | |||||
| } | |||||
| } | |||||
| </script> | |||||
| @@ -1,8 +0,0 @@ | |||||
| <template> | |||||
| <div></div> | |||||
| </template> | |||||
| <script> | |||||
| export default { | |||||
| name: '' | |||||
| } | |||||
| </script> | |||||
| @@ -1,8 +0,0 @@ | |||||
| <template> | |||||
| <div></div> | |||||
| </template> | |||||
| <script> | |||||
| export default { | |||||
| name: '' | |||||
| } | |||||
| </script> | |||||
| @@ -1,12 +1,9 @@ | |||||
| import Vue from 'vue' | import Vue from 'vue' | ||||
| import Router from 'vue-router' | import Router from 'vue-router' | ||||
| import Login from '@/components/Login' | import Login from '@/components/Login' | ||||
| import Home from "../components/Home"; | |||||
| import AssetGroup from "../components/AssetGroup"; | |||||
| import Hardware from "../components/Hardware"; | |||||
| import Software from "../components/Software"; | |||||
| import FileAndData from "../components/FileAndData"; | |||||
| import Person from "../components/Person"; | |||||
| import Home from '../components/Home'; | |||||
| import AssetGroup from '../components/AssetGroup'; | |||||
| import Inventory from '../components/Inventory'; | |||||
| Vue.use(Router); | Vue.use(Router); | ||||
| @@ -27,24 +24,9 @@ export const constantRoutes = [ | |||||
| component: AssetGroup | component: AssetGroup | ||||
| }, | }, | ||||
| { | { | ||||
| path: '/hardware', | |||||
| name: 'hardware', | |||||
| component: Hardware | |||||
| }, | |||||
| { | |||||
| path: '/software', | |||||
| name: 'software', | |||||
| component: Software | |||||
| }, | |||||
| { | |||||
| path: '/fileAndData', | |||||
| name: 'fileAndData', | |||||
| component: FileAndData | |||||
| }, | |||||
| { | |||||
| path: '/person', | |||||
| name: 'person', | |||||
| component: Person | |||||
| path: '/inventory/:tablename', | |||||
| name: 'inventory', | |||||
| component: Inventory | |||||
| }, | }, | ||||
| ] | ] | ||||
| } | } | ||||
| @@ -97,16 +97,6 @@ | |||||
| <optional>true</optional> | <optional>true</optional> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>org.slf4j</groupId> | |||||
| <artifactId>slf4j-api</artifactId> | |||||
| <version>1.7.30</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>org.slf4j</groupId> | |||||
| <artifactId>slf4j-simple</artifactId> | |||||
| <version>1.7.30</version> | |||||
| </dependency> | |||||
| </dependencies> | </dependencies> | ||||
| <build> | <build> | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.moze.rms.config; | package com.moze.rms.config; | ||||
| import com.moze.rms.dao.HardwareDAO; | |||||
| import com.moze.rms.dao.InventoryDAO; | |||||
| import com.moze.rms.dao.MappingColDAO; | |||||
| import com.moze.rms.dao.MappingTableDAO; | |||||
| import org.jdbi.v3.core.Jdbi; | import org.jdbi.v3.core.Jdbi; | ||||
| import org.jdbi.v3.core.statement.SqlLogger; | import org.jdbi.v3.core.statement.SqlLogger; | ||||
| import org.jdbi.v3.core.statement.StatementContext; | import org.jdbi.v3.core.statement.StatementContext; | ||||
| @@ -12,6 +14,7 @@ import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; | |||||
| import javax.sql.DataSource; | import javax.sql.DataSource; | ||||
| @Configuration | @Configuration | ||||
| public class JdbiFactory { | public class JdbiFactory { | ||||
| @@ -48,8 +51,19 @@ public class JdbiFactory { | |||||
| // return jdbi; | // return jdbi; | ||||
| // } | // } | ||||
| @Bean | |||||
| public MappingTableDAO mappingTableDAO(Jdbi jdbi) { | |||||
| return jdbi.onDemand(MappingTableDAO.class); | |||||
| } | |||||
| @Bean | |||||
| public MappingColDAO mappingColDAO(Jdbi jdbi) { | |||||
| return jdbi.onDemand(MappingColDAO.class); | |||||
| } | |||||
| @Bean | @Bean | ||||
| public HardwareDAO hardwareDAO(Jdbi jdbi) { | |||||
| return jdbi.onDemand(HardwareDAO.class); | |||||
| public InventoryDAO inventoryDAO(Jdbi jdbi) { | |||||
| return jdbi.onDemand(InventoryDAO.class); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,10 @@ | |||||
| package com.moze.rms.controller; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| @RestController | |||||
| @RequestMapping("/api/account") | |||||
| public class AccountController { | |||||
| } | |||||
| @@ -1,23 +0,0 @@ | |||||
| package com.moze.rms.controller; | |||||
| import com.moze.rms.dao.HardwareDAO; | |||||
| 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.RestController; | |||||
| @RestController | |||||
| @RequestMapping("/api/hardware") | |||||
| public class HardwareController { | |||||
| @Autowired | |||||
| HardwareDAO hardwareDAO; | |||||
| @GetMapping("/hardwares") | |||||
| public JsonResult getHardwares() { | |||||
| return new JsonResult(StatusCode.SUCCESS, hardwareDAO.findAll()); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,60 @@ | |||||
| package com.moze.rms.controller; | |||||
| import com.moze.rms.dao.InventoryDAO; | |||||
| import com.moze.rms.dao.MappingColDAO; | |||||
| import com.moze.rms.dao.MappingTableDAO; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("/api") | |||||
| public class InventoryController { | |||||
| @Autowired | |||||
| MappingTableDAO mappingTableDAO; | |||||
| @Autowired | |||||
| MappingColDAO mappingColDAO; | |||||
| @Autowired | |||||
| InventoryDAO inventoryDAO; | |||||
| @GetMapping("/routes") | |||||
| public JsonResult getRoutes() { | |||||
| return new JsonResult(StatusCode.SUCCESS, mappingTableDAO.findAll()); | |||||
| } | |||||
| @GetMapping("/title") | |||||
| public JsonResult getTitle(@RequestParam String tablename) { | |||||
| return new JsonResult(StatusCode.SUCCESS, mappingTableDAO.findTitle(tablename)); | |||||
| } | |||||
| @GetMapping("/headers") | |||||
| public JsonResult getHeaders(@RequestParam String tablename) { | |||||
| return new JsonResult(StatusCode.SUCCESS, mappingColDAO.findByTable(tablename)); | |||||
| } | |||||
| @GetMapping("/inventory") | |||||
| public JsonResult getInventorys(@RequestParam String tablename) { | |||||
| return new JsonResult(StatusCode.SUCCESS, inventoryDAO.getInventoryByTablename(tablename)); | |||||
| } | |||||
| @PutMapping("/inventory") | |||||
| public JsonResult modifyInventory(@RequestBody Map<String, Object> data) { | |||||
| try { | |||||
| inventoryDAO.modifyInventory(data); | |||||
| return new JsonResult(StatusCode.SUCCESS, null); | |||||
| } catch (Exception e) { | |||||
| return new JsonResult(StatusCode.SYS_ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,18 +0,0 @@ | |||||
| package com.moze.rms.dao; | |||||
| import com.moze.rms.entity.model.Hardware; | |||||
| import org.jdbi.v3.sqlobject.config.RegisterBeanMapper; | |||||
| import org.jdbi.v3.sqlobject.statement.SqlQuery; | |||||
| import org.springframework.stereotype.Repository; | |||||
| import java.util.List; | |||||
| @RegisterBeanMapper(Hardware.class) | |||||
| public interface HardwareDAO { | |||||
| @SqlQuery("select * from hardware;") | |||||
| List<Hardware> findAll(); | |||||
| } | |||||
| @@ -0,0 +1,35 @@ | |||||
| package com.moze.rms.dao; | |||||
| import org.jdbi.v3.core.Handle; | |||||
| import org.jdbi.v3.sqlobject.SqlObject; | |||||
| import org.jdbi.v3.sqlobject.config.RegisterBeanMapper; | |||||
| import org.jdbi.v3.sqlobject.statement.SqlQuery; | |||||
| import org.jdbi.v3.sqlobject.statement.SqlUpdate; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| public interface InventoryDAO extends SqlObject { | |||||
| @RegisterBeanMapper(Object.class) | |||||
| default List<Map<String, Object>> getInventoryByTablename(String tablename) { | |||||
| Handle handle = this.getHandle(); | |||||
| String sql = "select * from " + tablename; | |||||
| return handle.createQuery(sql).mapToMap().list(); | |||||
| } | |||||
| default void modifyInventory(Map<String, Object> data) { | |||||
| Handle handle = this.getHandle(); | |||||
| String sql = "update " + data.get("tablename") + " set "; | |||||
| for (Map.Entry<String, Object> entry : data.entrySet()) { | |||||
| if (!entry.getKey().equals("id") && !entry.getKey().equals("tablename")) | |||||
| sql += entry.getKey() + " = " + entry.getValue() + ","; | |||||
| } | |||||
| sql = sql.substring(0, sql.length()-1); | |||||
| sql += "where id = " + data.get("id"); | |||||
| handle.createUpdate(sql).execute(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.moze.rms.dao; | |||||
| import com.moze.rms.entity.model.MappingCol; | |||||
| import org.jdbi.v3.sqlobject.config.RegisterBeanMapper; | |||||
| import org.jdbi.v3.sqlobject.statement.SqlQuery; | |||||
| import java.util.List; | |||||
| @RegisterBeanMapper(MappingCol.class) | |||||
| public interface MappingColDAO { | |||||
| @SqlQuery("select * from mapping.mapping_col where tablename = ? order by index;") | |||||
| List<MappingCol> findByTable(String tablename); | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| package com.moze.rms.dao; | |||||
| import com.moze.rms.entity.model.MappingTable; | |||||
| import org.jdbi.v3.sqlobject.config.RegisterBeanMapper; | |||||
| import org.jdbi.v3.sqlobject.statement.SqlQuery; | |||||
| import java.util.List; | |||||
| @RegisterBeanMapper(MappingTable.class) | |||||
| public interface MappingTableDAO { | |||||
| @SqlQuery("select * from mapping.mapping_table;") | |||||
| List<MappingTable> findAll(); | |||||
| @SqlQuery("select descript from mapping.mapping_table where tablename = ?;") | |||||
| String findTitle(String tablename); | |||||
| } | |||||
| @@ -1,23 +0,0 @@ | |||||
| package com.moze.rms.entity.model; | |||||
| import lombok.Data; | |||||
| import lombok.NoArgsConstructor; | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| public class Hardware { | |||||
| private String hostname; | |||||
| private String type; | |||||
| private String descript; | |||||
| private String ip1; | |||||
| private String ip2; | |||||
| private String model; | |||||
| private String environment; | |||||
| private String position; | |||||
| private String position_number; | |||||
| private Integer amount; | |||||
| private String owner_department; | |||||
| private String keep_department; | |||||
| private String keeper; | |||||
| private String remark; | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.moze.rms.entity.model; | |||||
| import lombok.Data; | |||||
| import lombok.NoArgsConstructor; | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| public class MappingCol { | |||||
| private String tablename; | |||||
| private String colname; | |||||
| private Integer level; | |||||
| private String descript; | |||||
| private String type; | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| package com.moze.rms.entity.model; | |||||
| import lombok.Data; | |||||
| import lombok.NoArgsConstructor; | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| public class MappingTable { | |||||
| private String tablename; | |||||
| private String descript; | |||||
| } | |||||