Skip to content

Commit 75ec3cf

Browse files
committed
update FE app, add router, add BE webConfig
1 parent ea0d845 commit 75ec3cf

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package EmployeeSystem.demo.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7+
8+
// TODO : check if can merge below
9+
// 1) enable CORS 2) show swagger 2.x UI properly
10+
@Configuration
11+
public class WebConfig implements WebMvcConfigurer {
12+
@Override
13+
public void addCorsMappings(CorsRegistry registry) {
14+
registry.addMapping("/**")
15+
.allowedOriginPatterns("*") // SpringBoot2.4.0 [allowedOriginPatterns]代替[allowedOrigins]
16+
.allowedMethods("*")
17+
.maxAge(3600)
18+
.allowCredentials(true);
19+
}
20+
21+
@Bean
22+
public WebMvcConfigurer corsConfigurer() {
23+
return new WebMvcConfigurer() {
24+
@Override
25+
public void addCorsMappings(CorsRegistry registry) {
26+
registry.addMapping("/**")
27+
.allowedOrigins("*")
28+
.allowedMethods("GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS");
29+
}
30+
};
31+
}
32+
33+
}

springEmployeeSystem/frontend/employee-system-ui/src/App.vue

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,41 @@
44
<router-link to="/">Home</router-link> |
55
<router-link to="/about">About</router-link>
66
</nav>
7-
<router-view/>
7+
<router-view />
88
</div>
99
</template>
1010

11+
<script>
12+
var axios = require("axios");
13+
export default {
14+
data() {
15+
return {
16+
baseURL: "http://localhost:9998/",
17+
users: null,
18+
departments: null,
19+
key: 0,
20+
token: null,
21+
cartCount: 0,
22+
};
23+
},
24+
25+
methods: {
26+
async fetchData() {
27+
// get users
28+
await axios
29+
.get(this.baseURL + "users/")
30+
.then((res) => (this.users = res.users))
31+
.catch((err) => console.log(err));
32+
},
33+
34+
mounted() {
35+
this.fetchData();
36+
},
37+
},
38+
};
39+
</script>
40+
41+
1142
<style>
1243
#app {
1344
font-family: Avenir, Helvetica, Arial, sans-serif;

springEmployeeSystem/frontend/employee-system-ui/src/router/User/ListUsers.vue

Whitespace-only changes.

0 commit comments

Comments
 (0)