Ver Fonte

Merge branch 'master' of http://121.40.98.15:3001/kym/charge-java

# Conflicts:
#	admin/src/main/java/com/kym/admin/controller/AdminUserController.java
skyline há 2 anos atrás
pai
commit
6b6ea5e9f5

+ 1 - 1
admin-web/.env.development

@@ -2,5 +2,5 @@
 ENV = development
 
 # 本地环境接口地址
-VITE_API_URL = http://localhost:8080/
+VITE_API_URL = http://localhost:8080/admin/
 VITE_FILE_URL = http://localhost:8080/file/download/

+ 0 - 2
admin-web/src/components/attach/Attach.vue

@@ -34,9 +34,7 @@
       </div>
       <template #content>
         <el-button-group>
-          <el-button size="small" type="primary" text v-if="!state.isImage"  @click="handlePreview">预览</el-button>
           <el-button size="small" type="success" text v-if="downable&&!readonly" @click="handleDownload"> 下载</el-button>
-          <el-button size="small" type="warning" text v-if="edit&&!readonly" @click="handleEdit"> 编辑</el-button>
           <el-button size="small" type="danger" text v-if="!readonly" @click="handleDelete"> 删除</el-button>
         </el-button-group>
 

+ 14 - 5
admin-web/src/utils/request.ts

@@ -5,11 +5,16 @@ import qs from 'qs';
 
 // @ts-ignore
 let loadingInstance: ElLoading = null;
+
+let url = import.meta.env.VITE_API_URL;
+if (!url) {
+    url = `${location.origin}/admin/`;
+}
 // 配置新建一个 axios 实例
 const service: AxiosInstance = axios.create({
-    baseURL: import.meta.env.VITE_API_URL,
+    baseURL: url,
     timeout: 50000,
-    headers: {'Content-Type': 'application/json', 'X-Client-Type': 1},
+    headers: {'Content-Type': 'application/json'},
 
     paramsSerializer: {
         serialize(params) {
@@ -41,7 +46,7 @@ service.interceptors.response.use(
         const res = response.data;
         if (res.code && res.code !== 0) {
             // `token` 过期或者账号已在别处登录
-            if (res.code === 401 || res.code === 4001 || res.code === 92305) {
+            if (res.code === 401) {
                 Session.clear(); // 清除浏览器全部临时缓存
                 ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
                     .then(() => {
@@ -68,8 +73,12 @@ service.interceptors.response.use(
         } else if (error.message == 'Network Error') {
             ElMessage.error('网络连接错误');
         } else {
-            if (error.response.data) ElMessage.error(error.response.statusText);
-            else ElMessage.error('接口路径找不到');
+            if (error.response.data) {
+                ElMessage.error(error.response.data.message || error.response.statusText);
+                return Promise.reject(error.response.data.message || error.response.statusText);
+            } else {
+                ElMessage.error('接口路径找不到');
+            }
         }
         return Promise.reject(error);
     }

+ 13 - 0
admin-web/src/views/admin/account/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
admin-web/src/views/admin/finance/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
admin-web/src/views/admin/marketing/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
admin-web/src/views/admin/ordering/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
admin-web/src/views/admin/station/endpoint/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
admin-web/src/views/admin/station/list/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
admin-web/src/views/admin/station/stat/index.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "index"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 11 - 41
admin-web/src/views/login/component/account.vue

@@ -1,7 +1,7 @@
 <template>
   <el-form size="large" class="login-content-form" :model="state.ruleForm" :rules="state.rules">
     <el-form-item class="login-animation1" prop="name">
-      <el-input text :placeholder="$t('message.account.accountPlaceholder1')"
+      <el-input text placeholder="请输入手机号、邮箱登录"
                 v-model="state.ruleForm.name" clearable autocomplete="off">
         <template #prefix>
           <el-icon class="el-input__icon">
@@ -12,7 +12,7 @@
     </el-form-item>
     <el-form-item class="login-animation2" prop="pwd">
       <el-input
-          :type="state.isShowPassword ? 'text' : 'password'"
+          type="password"
           :placeholder="$t('message.account.accountPlaceholder2')"
           v-model="state.ruleForm.pwd"
           autocomplete="off"
@@ -22,39 +22,16 @@
             <ele-Unlock/>
           </el-icon>
         </template>
-        <template #suffix>
+<!--        <template #suffix>
           <i
               class="iconfont el-input__icon login-content-password"
               :class="state.isShowPassword ? 'icon-yincangmima' : 'icon-xianshimima'"
               @click="state.isShowPassword = !state.isShowPassword"
           >
           </i>
-        </template>
+        </template>-->
       </el-input>
     </el-form-item>
-    <el-form-item class="login-animation3" prop="code">
-      <el-col :span="15">
-        <el-input
-            text
-            maxlength="4"
-            :placeholder="$t('message.account.accountPlaceholder3')"
-            v-model="state.ruleForm.code"
-            clearable
-            autocomplete="off"
-        >
-          <template #prefix>
-            <el-icon class="el-input__icon">
-              <ele-Position/>
-            </el-icon>
-          </template>
-        </el-input>
-      </el-col>
-      <el-col :span="1"></el-col>
-      <el-col :span="8">
-        <img @click="reloadVerifyCode" :src="state.verifySrc"/>
-        <!--				<el-button class="login-content-code" v-waves>1234</el-button>-->
-      </el-col>
-    </el-form-item>
     <el-form-item class="login-animation4">
       <el-button type="primary" class="login-content-submit" round v-waves @click="onSignIn" :loading="state.loading.signIn">
         <span>{{ $t('message.account.accountBtnText') }}</span>
@@ -115,17 +92,11 @@ const currentTime = computed(() => {
 });
 
 onMounted(() => {
-  reloadVerifyCode();
 });
 
-const reloadVerifyCode = () => {
-  $get("/user/loginVerifyCodeSign").then((res: any) => {
-    state.ruleForm.sign = res;
-    state.verifySrc = import.meta.env.VITE_API_URL + "user/loginVerifyCode?sign=" + res + "&r=" + Math.random();
-  });
-}
 
 const handleForgetPassword = () => {
+  // Message.alert(`请联系管理员400-1234567`)
   //forgetPasswordRef.open();
 }
 
@@ -143,7 +114,7 @@ const initData = () => {
     Session.set("dicts", res);
   });
 
-  $get("/user/profile").then((obj: any) => {
+  $get("/admin-user/profile").then((obj: any) => {
     if (obj) {
       let {user, permissionList} = obj;
       let userInfo = {...user, permList: permissionList}
@@ -162,14 +133,13 @@ const initData = () => {
   }).catch(err => {
     ElMessage.error("登录状态失效,请重新登录管理控制台");
     Session.clear();
-    reloadVerifyCode();
     state.loading.signIn = false;
   });
 }
 
 const refreshLogin = () => {
   setInterval(() => {
-    $get(`user/refresh`);
+    $get(`admin-user/refresh`);
   }, 1600 * 1000)
 }
 
@@ -177,10 +147,11 @@ const refreshLogin = () => {
 const onSignIn = async () => {
   state.loading.signIn = true;
   let temp = {
-    userName:state.ruleForm.name,
-    pwd:encryptData(state.ruleForm.pwd)
+    mobilePhone:state.ruleForm.name,
+    password:encryptData(state.ruleForm.pwd)
   }
-  $body(`/user/login?sign=${state.ruleForm.sign}&code=${state.ruleForm.code}`, temp).then((res: any) => {
+  $body(`/admin-user/login`, temp).then((res: any) => {
+    let {id,satoken} = res;
     console.log(res)
     if (res.token) {
       // 存储 token 到浏览器缓存
@@ -210,7 +181,6 @@ const onSignIn = async () => {
   }).catch(e => {
     state.loading.signIn = false;
     console.error(e)
-    reloadVerifyCode();
   });
 
 

+ 2 - 2
admin-web/src/views/login/index.vue

@@ -25,9 +25,9 @@
 								<el-tab-pane label="账号登录" name="account">
 									<Account />
 								</el-tab-pane>
-								<el-tab-pane label="AD域登录" name="mobile">
+<!--								<el-tab-pane label="AD域登录" name="mobile">
 									<Ldap />
-								</el-tab-pane>
+								</el-tab-pane>-->
 							</el-tabs>
 						</div>
 						<Scan v-if="state.isScan" />

+ 9 - 5
admin/src/main/java/com/kym/admin/controller/AdminUserController.java

@@ -4,11 +4,9 @@ import cn.dev33.satoken.stp.StpUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.kym.common.R;
 import com.kym.common.annotation.SysLog;
+import com.kym.common.controller.IController;
 import com.kym.service.admin.AdminUserService;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -20,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/admin-user")
-public class AdminUserController {
+public class AdminUserController extends IController {
 
     private final AdminUserService adminUserService;
 
@@ -41,4 +39,10 @@ public class AdminUserController {
         return R.success();
     }
 
+    @SysLog("账号信息读取")
+    @GetMapping("/profile")
+    R<?> profile() {
+        return resp(() -> adminUserService.profile());
+    }
+
 }

+ 4 - 0
admin/src/main/resources/application.yml

@@ -130,3 +130,7 @@ oss:
   keySecret:
   bucket: kym-static
   prefix: static.kuaiyuman.cn
+password:
+ privateKey: MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM1zhmu+TcTSZSQ7w0541g45o8ji4ugEC4O31GnS6tfvLTCru+9DPK2/DNdd4z1enz2PuDhktHuoEsEKPdA08fRJSMTXLL0pUEp2OQ+t7tZP6mVLvizasnP+HKAqIndXFr5nXm/okQfL/f/6L2Bben9sItoxC28Z6Y28NfAJPAg1AgMBAAECgYAKOdvQ9RHt4AMEwKzB9SXCY4AReamNntXr4nSCJ+tkgBUhvQqHqDMW+tFqztOGtHT8nXCv7eNF3GHClf3ppRj91utk8zAwZPVAVlRoNcWs60nyKRUO2uhwAV8AE+9UKDoVui7L7UaMcIkssKqQbFGIRXUjjSoPJu0yoHCdp5/3QQJBAOZTbfgmFXVgRSH4IMXJ3aZOqz+Wy3EmvNatYz8NYLBFgLJTWWXtR7URw82R7jL6F9ettfCityhAmXEZnZsEsokCQQDkWkYwFZlUYJ2ctdNEmipXw8tjpCrzQRaZnydXbjviwbSpOvOo5nrxSG5BtL9QDwiy9DL7YLBVJPykAkJm3m1NAkBn2SQTJ7CzLIXfLA4yv7LFYmEKGcZ+rRWlwaWm7zQyJhRB0xzSvSqAtJLRJEP/Dg4j+7m11te4OXA1s3QBShvpAkEAq50gpKCG5D/cE9seVK9b5SuTnmXRlZE0D+3pXi7NOOSFBq30UtosSUs6+YyCPwOdcQhPjFYlD0hFymicSL0e/QJBAOMQaABh/6BcVimWP284x/WxBQ83zzVhcl7fUyqcFvfAw1JeMmRxvm2CWYKQ9MIhQ/9ptFotRCSwMAdJTZceWys=
+ publicKey: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNc4Zrvk3E0mUkO8NOeNYOOaPI4uLoBAuDt9Rp0urX7y0wq7vvQzytvwzXXeM9Xp89j7g4ZLR7qBLBCj3QNPH0SUjE1yy9KVBKdjkPre7WT+plS74s2rJz/hygKiJ3Vxa+Z15v6JEHy/3/+i9gW3p/bCLaMQtvGemNvDXwCTwINQIDAQAB
+

+ 26 - 8
common/src/main/java/com/kym/common/config/WebContextConfig.java

@@ -4,19 +4,37 @@ import com.kym.common.filter.RequestLogFilter;
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-
-
-
-
-
-
-
-
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
 
 
 @Configuration
 public class WebContextConfig {
 
+
+    /**
+     * 跨域
+     */
+    @Bean
+    public CorsFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        // 1允许任何域名使用
+        corsConfiguration.addAllowedOrigin("*");
+//        corsConfiguration.setAllowedOrigins(Lists.newArrayList(crosOrigins.split(";")));
+        // 2允许任何头
+        corsConfiguration.addAllowedHeader("*");
+        // 3允许任何方法(post、get等)
+        corsConfiguration.addAllowedMethod("*");
+        source.registerCorsConfiguration("/**", corsConfiguration);
+        return new CorsFilter(source);
+    }
+
+    /**
+     * 请求日志过滤器
+     * @return
+     */
     @Bean
     public FilterRegistrationBean<RequestLogFilter> addFilters() {
         FilterRegistrationBean<RequestLogFilter> bean = new FilterRegistrationBean<>();

+ 1 - 0
service/src/main/java/com/kym/service/admin/AdminUserService.java

@@ -18,5 +18,6 @@ public interface AdminUserService extends IService<AdminUser> {
     R logout(Long id);
 
 
+    Object profile();
 
 }

+ 24 - 1
service/src/main/java/com/kym/service/admin/impl/AdminUserServiceImpl.java

@@ -1,6 +1,8 @@
 package com.kym.service.admin.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.crypto.asymmetric.KeyType;
+import cn.hutool.crypto.asymmetric.RSA;
 import cn.hutool.crypto.digest.DigestAlgorithm;
 import cn.hutool.crypto.digest.Digester;
 import com.baomidou.dynamic.datasource.annotation.DS;
@@ -12,8 +14,10 @@ import com.kym.mapper.admin.AdminUserMapper;
 import com.kym.service.admin.AdminUserService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.nio.charset.StandardCharsets;
 import java.time.LocalDateTime;
 import java.util.Map;
 
@@ -32,10 +36,20 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
     final static Digester MD5 = new Digester(DigestAlgorithm.MD5);
     private static final Logger LOGGER = LoggerFactory.getLogger(AdminUserServiceImpl.class);
 
+    @Value("${password.privateKey}")
+    private String privateKey;
+
+
+    @Value("${password.publicKey}")
+    private String publicKey;
+
+
     @Override
     public R login(String mobilePhone, String password) {
         var user = lambdaQuery().eq(AdminUser::getMobilePhone, mobilePhone).one();
-        var pwd = MD5.digestHex(password.concat(MD5.digestHex(mobilePhone).substring(0, 5)));
+        RSA rsa = new RSA(privateKey, publicKey);
+        password = rsa.decryptStr(password, KeyType.PrivateKey, StandardCharsets.UTF_8);
+        var pwd = MD5.digestHex(password);
         if (pwd.equals(user.getPassword())) {
             StpUtil.login(user.getId());
             // 用户名存入session,统一日志读取使用
@@ -55,4 +69,13 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
     public R logout(Long id) {
         return logout(id);
     }
+
+    /**
+     * 用户信息、权限、角色
+     * @return
+     */
+    @Override
+    public Object profile() {
+        return null;
+    }
 }