From 7a3105c4147216930b067a56614d5710c5a2c821 Mon Sep 17 00:00:00 2001 From: zhao_lei Date: Tue, 11 Jun 2019 21:23:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=89=8D=E7=AB=AF=E5=8A=A0?= =?UTF-8?q?=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.sh | 5 + pom.xml | 11 +- run.sh | 11 + .../alawn/bill/config/WebSecurityConfig.java | 13 +- .../bill/controller/BasicController.java | 6 +- .../net/alawn/bill/entity/po/Premission.java | 41 +++ .../net/alawn/bill/exception/RespMsg.java | 1 + .../bill/exception/RespMsgConstants.java | 17 +- .../net/alawn/bill/service/AuthService.java | 2 +- .../bill/service/impl/AuthServiceImpl.java | 29 +- .../net/alawn/bill/util/AesEncryptUtil.java | 128 +++++++++ src/main/vue/bill/.babelrc | 18 -- src/main/vue/bill/.editorconfig | 9 - src/main/vue/bill/.eslintignore | 5 - src/main/vue/bill/.eslintrc.js | 29 -- src/main/vue/bill/.gitignore | 17 -- src/main/vue/bill/.postcssrc.js | 10 - src/main/vue/bill/README.md | 51 ++-- src/main/vue/bill/babel.config.js | 5 + src/main/vue/bill/config/dev.env.js | 7 - src/main/vue/bill/config/index.js | 76 ------ src/main/vue/bill/config/prod.env.js | 4 - src/main/vue/bill/config/test.env.js | 7 - src/main/vue/bill/deploy.sh | 9 + src/main/vue/bill/index.html | 12 - src/main/vue/bill/package.json | 112 +++----- src/main/vue/bill/public/favicon.ico | Bin 0 -> 4286 bytes src/main/vue/bill/public/index.html | 17 ++ src/main/vue/bill/src/App.vue | 19 +- src/main/vue/bill/src/api/basic.js | 14 +- src/main/vue/bill/src/api/user.js | 2 +- src/main/vue/bill/src/axios/api.request.js | 2 +- src/main/vue/bill/src/axios/index.js | 17 +- .../vue/bill/src/components/HelloWorld.vue | 107 ++------ src/main/vue/bill/src/main.js | 73 ++++- src/main/vue/bill/src/router/index.js | 30 ++- src/main/vue/bill/src/utils/encoder.js | 50 ++++ src/main/vue/bill/src/views/Bill.vue | 254 ++++++++++++------ src/main/vue/bill/src/views/Login.vue | 54 ++-- src/main/vue/bill/src/views/Register.vue | 34 ++- .../e2e/custom-assertions/elementCount.js | 27 -- src/main/vue/bill/test/e2e/nightwatch.conf.js | 46 ---- src/main/vue/bill/test/e2e/runner.js | 48 ---- src/main/vue/bill/test/e2e/specs/test.js | 19 -- src/main/vue/bill/test/unit/.eslintrc | 7 - src/main/vue/bill/test/unit/jest.conf.js | 30 --- src/main/vue/bill/test/unit/setup.js | 3 - .../bill/test/unit/specs/HelloWorld.spec.js | 11 - stop.sh | 8 + 49 files changed, 769 insertions(+), 738 deletions(-) create mode 100755 deploy.sh create mode 100755 run.sh create mode 100644 src/main/java/net/alawn/bill/entity/po/Premission.java create mode 100644 src/main/java/net/alawn/bill/util/AesEncryptUtil.java delete mode 100644 src/main/vue/bill/.babelrc delete mode 100644 src/main/vue/bill/.editorconfig delete mode 100644 src/main/vue/bill/.eslintignore delete mode 100644 src/main/vue/bill/.eslintrc.js delete mode 100644 src/main/vue/bill/.gitignore delete mode 100644 src/main/vue/bill/.postcssrc.js create mode 100644 src/main/vue/bill/babel.config.js delete mode 100644 src/main/vue/bill/config/dev.env.js delete mode 100644 src/main/vue/bill/config/index.js delete mode 100644 src/main/vue/bill/config/prod.env.js delete mode 100644 src/main/vue/bill/config/test.env.js create mode 100755 src/main/vue/bill/deploy.sh delete mode 100644 src/main/vue/bill/index.html create mode 100644 src/main/vue/bill/public/favicon.ico create mode 100644 src/main/vue/bill/public/index.html create mode 100644 src/main/vue/bill/src/utils/encoder.js delete mode 100644 src/main/vue/bill/test/e2e/custom-assertions/elementCount.js delete mode 100644 src/main/vue/bill/test/e2e/nightwatch.conf.js delete mode 100644 src/main/vue/bill/test/e2e/runner.js delete mode 100644 src/main/vue/bill/test/e2e/specs/test.js delete mode 100644 src/main/vue/bill/test/unit/.eslintrc delete mode 100644 src/main/vue/bill/test/unit/jest.conf.js delete mode 100644 src/main/vue/bill/test/unit/setup.js delete mode 100644 src/main/vue/bill/test/unit/specs/HelloWorld.spec.js create mode 100755 stop.sh diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..9e0da4f --- /dev/null +++ b/deploy.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +cd target +scp bill-1.0.0-SNAPSHOT.jar gc:/tmp +ssh gc "sudo cp /tmp/bill-1.0.0-SNAPSHOT.jar /home/bill/service ; sudo . /home/bill/service/run.sh" diff --git a/pom.xml b/pom.xml index a877edb..00130ac 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 net.alawn bill - war + jar 1.0.0-SNAPSHOT bill @@ -34,6 +34,11 @@ + + commons-codec + commons-codec + 1.9 + io.jsonwebtoken jjwt-api @@ -201,6 +206,10 @@ + + org.springframework.boot + spring-boot-maven-plugin + diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..c71e418 --- /dev/null +++ b/run.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +pid=`ps -ef | grep bill| grep java | awk '{print $2}'` + +if [ $pid ]; then + echo $pid + kill -9 $pid +fi + +> nohup.out + +nohup java -jar target/bill-1.0.0-SNAPSHOT.jar 2>/dev/null & diff --git a/src/main/java/net/alawn/bill/config/WebSecurityConfig.java b/src/main/java/net/alawn/bill/config/WebSecurityConfig.java index b720b38..a9311a7 100644 --- a/src/main/java/net/alawn/bill/config/WebSecurityConfig.java +++ b/src/main/java/net/alawn/bill/config/WebSecurityConfig.java @@ -1,7 +1,9 @@ package net.alawn.bill.config; +import lombok.extern.slf4j.Slf4j; import net.alawn.bill.security.JwtAuthenticationEntryPoint; import net.alawn.bill.security.JwtAuthenticationTokenFilter; +import net.alawn.bill.util.AesEncryptUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; @@ -34,6 +36,8 @@ import java.util.Arrays; * @Description: * @Date: Create in 16:53 2019-05-17 */ + +@Slf4j @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) @@ -70,6 +74,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { /** 装载BCrypt密码编码器 */ @Bean public PasswordEncoder passwordEncoder() { + log.info("passwordEncoder()"); return new BCryptPasswordEncoder(); } @@ -154,12 +159,18 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { //对密码进行加密 @Override public String encode(CharSequence charSequence) { - System.out.println(charSequence.toString()); + log.info("encode password:" + charSequence.toString()); +// String password = AesEncryptUtil.decrypt(charSequence.toString()); +// return DigestUtils.md5DigestAsHex(password.getBytes()); return DigestUtils.md5DigestAsHex(charSequence.toString().getBytes()); } //对密码进行判断匹配 @Override public boolean matches(CharSequence charSequence, String s) { + log.info("matches passwordRaw :" + charSequence.toString()); + log.info("matches passwordDb:" + charSequence.toString()); +// String password = AesEncryptUtil.decrypt(charSequence.toString()); +// String encode = DigestUtils.md5DigestAsHex(password.getBytes()); String encode = DigestUtils.md5DigestAsHex(charSequence.toString().getBytes()); boolean res = s.equals( encode ); return res; diff --git a/src/main/java/net/alawn/bill/controller/BasicController.java b/src/main/java/net/alawn/bill/controller/BasicController.java index 225e2c6..f87f6c4 100644 --- a/src/main/java/net/alawn/bill/controller/BasicController.java +++ b/src/main/java/net/alawn/bill/controller/BasicController.java @@ -49,7 +49,7 @@ public class BasicController { @RequestMapping(value = "/posts",method = RequestMethod.POST) @ResponseBody - public ResponseEntity addPost(@RequestBody NewPost newPost, Principal principal) throws URISyntaxException { + public ResponseEntity addPost(@RequestBody NewPost newPost) { AuthUser authUser = (AuthUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); long userId = authUser.getId(); @@ -90,7 +90,7 @@ public class BasicController { @RequestMapping(value = "/merchants",method = RequestMethod.POST) @ResponseBody - public ResponseEntity addMerchant(@RequestBody NewMerchant newMerchant) throws URISyntaxException { + public ResponseEntity addMerchant(@RequestBody NewMerchant newMerchant) { /** 登记 Post */ Merchant merchant = merchantRepo.save(newMerchant.build()); merchantRepo.flush(); @@ -99,7 +99,7 @@ public class BasicController { @RequestMapping(value = "/merchants",method = RequestMethod.GET) @ResponseBody - public ResponseEntity> fetchMerchants() throws URISyntaxException { + public ResponseEntity> fetchMerchants() { List merchants = merchantRepo.findAll(); return ResponseEntity.ok(merchants); } diff --git a/src/main/java/net/alawn/bill/entity/po/Premission.java b/src/main/java/net/alawn/bill/entity/po/Premission.java new file mode 100644 index 0000000..4eb8839 --- /dev/null +++ b/src/main/java/net/alawn/bill/entity/po/Premission.java @@ -0,0 +1,41 @@ +package net.alawn.bill.entity.po; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.*; +import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; + +@Data +@Builder +@Entity +@Table(name = "t_bill_premission") +@ToString(exclude = {"user"}) +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true) +@DynamicUpdate +public class Premission extends EntityId{ + + @ManyToOne(fetch = FetchType.LAZY) + @NotFound(action = NotFoundAction.IGNORE) +// @JoinColumn(name = "userId", referencedColumnName = "id") + @JoinColumn(name = "userId", referencedColumnName = "id") +// @MapsId("username") + @MapsId("id") + private User user; + + @Override + public boolean equals(Object o) { + return this == o || o instanceof Premission + && id != null + && id.equals(((Premission) o).id); + } + + @Override + public int hashCode() { + return 31; + } +} diff --git a/src/main/java/net/alawn/bill/exception/RespMsg.java b/src/main/java/net/alawn/bill/exception/RespMsg.java index 8bb6f23..7b6b83c 100644 --- a/src/main/java/net/alawn/bill/exception/RespMsg.java +++ b/src/main/java/net/alawn/bill/exception/RespMsg.java @@ -24,6 +24,7 @@ public enum RespMsg { NO_DATA ( "200017", RespMsgConstants.NO_DATA ) , USER_ALREADY_EXIST ( "200018", RespMsgConstants.USER_ALREADY_EXIST ) , USER_NOT_EXIST_OR_PASSWORD_INCORRECT ( "200019", RespMsgConstants.USER_NOT_EXIST_OR_PASSWORD_INCORRECT ) , + USERNAME_OR_PASSWORD_IS_EMPTY ( "200020", RespMsgConstants.USERNAME_OR_PASSWORD_IS_EMPTY ) , SUCCESS ( "000000", RespMsgConstants.SUCCESS ) ; diff --git a/src/main/java/net/alawn/bill/exception/RespMsgConstants.java b/src/main/java/net/alawn/bill/exception/RespMsgConstants.java index ef5cd2e..ab32be6 100644 --- a/src/main/java/net/alawn/bill/exception/RespMsgConstants.java +++ b/src/main/java/net/alawn/bill/exception/RespMsgConstants.java @@ -7,22 +7,23 @@ package net.alawn.bill.exception; */ public final class RespMsgConstants { - public final static String NO_STORAGE_FOUND = "没有发现存储" ; + public final static String NO_STORAGE_FOUND = "没有发现存储" ; public final static String BLOB_DUPLICATE = "发现重复Blob" ; - public final static String BLOB_NOT_EXIST = "Blob对象不存在" ; - public final static String NO_BLOB_FOUND = "Blob对象不存在" ; + public final static String BLOB_NOT_EXIST = "Blob对象不存在" ; + public final static String NO_BLOB_FOUND = "Blob对象不存在" ; public final static String BUCKET_DUPLICATE = "发现重复Bucket" ; - public final static String FILE_HANDLING = "文件处理异常" ; - public final static String FILE_NOT_EXIST = "文件不存在" ; - public final static String FILE_OCCUPIED = "文件/文件夹已被占用" ; - public final static String NO_ACCESS_PERMISSION = "没有该访问权限" ; + public final static String FILE_HANDLING = "文件处理异常" ; + public final static String FILE_NOT_EXIST = "文件不存在" ; + public final static String FILE_OCCUPIED = "文件/文件夹已被占用" ; + public final static String NO_ACCESS_PERMISSION = "没有该访问权限" ; public final static String NO_BUCKET_FOUND = "没有找到Bucket" ; - public final static String NO_DEFAULT_BUCKET = "没有找到默认Bucket" ; + public final static String NO_DEFAULT_BUCKET = "没有找到默认Bucket" ; public final static String NO_DEFAULT_STORAGE = "没有找到默认存储设备" ; public final static String REQUEST_PARAMS = "请求参数有误" ; public final static String INTERNAL_ERROR = "内部错误" ; public final static String NO_DATA = "没有数据" ; public final static String USER_ALREADY_EXIST = "用户已存在" ; public final static String USER_NOT_EXIST_OR_PASSWORD_INCORRECT = "用户不存在或密码不正确" ; + public final static String USERNAME_OR_PASSWORD_IS_EMPTY = "用户名或密码不得为空" ; public final static String SUCCESS = "业务成功" ; } diff --git a/src/main/java/net/alawn/bill/service/AuthService.java b/src/main/java/net/alawn/bill/service/AuthService.java index 38e8f82..f7fbcef 100644 --- a/src/main/java/net/alawn/bill/service/AuthService.java +++ b/src/main/java/net/alawn/bill/service/AuthService.java @@ -11,6 +11,6 @@ import org.springframework.web.HttpRequestMethodNotSupportedException; */ public interface AuthService { NewUser register(NewUser userDTO) throws HttpRequestMethodNotSupportedException, AuthenticationException; - String login(String username, String password); + String login(String username, String password) throws AuthenticationException; String refresh(String oldToken); } diff --git a/src/main/java/net/alawn/bill/service/impl/AuthServiceImpl.java b/src/main/java/net/alawn/bill/service/impl/AuthServiceImpl.java index 301c36b..38b9d7d 100644 --- a/src/main/java/net/alawn/bill/service/impl/AuthServiceImpl.java +++ b/src/main/java/net/alawn/bill/service/impl/AuthServiceImpl.java @@ -1,5 +1,6 @@ package net.alawn.bill.service.impl; +import lombok.extern.slf4j.Slf4j; import net.alawn.bill.entity.dto.NewUser; import net.alawn.bill.entity.po.Authority; import net.alawn.bill.entity.po.AuthorityId; @@ -11,6 +12,7 @@ import net.alawn.bill.repository.UserRepo; import net.alawn.bill.security.AuthUser; import net.alawn.bill.security.JwtTokenUtil; import net.alawn.bill.service.AuthService; +import net.alawn.bill.util.AesEncryptUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -23,6 +25,7 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; /** @@ -31,6 +34,7 @@ import org.springframework.stereotype.Service; * @Date: Create in 15:59 2019-05-20 */ +@Slf4j @Service //@AllArgsConstructor(onConstructor = @__(@Autowired)) public class AuthServiceImpl implements AuthService { @@ -62,6 +66,8 @@ public class AuthServiceImpl implements AuthService { @Override public NewUser register(NewUser userDTO) throws AuthenticationException { + log.info("AuthServiceImpl.register start"); + log.info("userDTO:" + userDTO); final String username = userDTO.getUsername(); if(userRepo.findByUsername(username) != null) { @@ -69,10 +75,14 @@ public class AuthServiceImpl implements AuthService { } BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); - final String rawPassword = userDTO.getPassword(); + +// final String rawPassword = userDTO.getPassword(); + final String password = AesEncryptUtil.decrypt(userDTO.getPassword()); + User user = User.builder() .username(username) - .password(encoder.encode(rawPassword)).build(); + .password(encoder.encode(password)).build(); +// .password(userDTO.getPassword()).build(); User saved = userRepo.save(user); Authority savedAuth = authorityRepo.save( Authority.builder() @@ -90,11 +100,26 @@ public class AuthServiceImpl implements AuthService { @Override public String login(String username, String password) { +// public String login(String username, String passwordAES) { + + /** 为空检查*/ +// if(StringUtils.isEmpty(username) || StringUtils.isEmpty(passwordAES)) { +// throw new CommonException(RespMsg.USER_NOT_EXIST_OR_PASSWORD_INCORRECT); +// } + +// BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); + password = AesEncryptUtil.decrypt(password); + UsernamePasswordAuthenticationToken upToken = new UsernamePasswordAuthenticationToken(username, password); final Authentication authentication = authenticationManager.authenticate(upToken); SecurityContextHolder.getContext().setAuthentication(authentication); final UserDetails userDetails = userDetailsService.loadUserByUsername(username); + +// if(!encoder.matches(password,userDetails.getPassword())) { +// throw new CommonException(RespMsg.USER_NOT_EXIST_OR_PASSWORD_INCORRECT); +// } + final String token = jwtTokenUtil.generateToken(userDetails); return token; } diff --git a/src/main/java/net/alawn/bill/util/AesEncryptUtil.java b/src/main/java/net/alawn/bill/util/AesEncryptUtil.java new file mode 100644 index 0000000..18262cb --- /dev/null +++ b/src/main/java/net/alawn/bill/util/AesEncryptUtil.java @@ -0,0 +1,128 @@ +package net.alawn.bill.util; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 17:27 2019-06-11 + */ +public class AesEncryptUtil { + + private static String iv = "0123456789ABCDEF";//偏移量字符串必须是16位 当模式是CBC的时候必须设置偏移量 + private static String Algorithm = "AES"; + private static String AlgorithmProvider = "AES/CBC/PKCS5Padding"; //算法/模式/补码方式 + + public static byte[] generatorKey() throws NoSuchAlgorithmException { + KeyGenerator keyGenerator = KeyGenerator.getInstance(Algorithm); + keyGenerator.init(256);//默认128,获得无政策权限后可为192或256 + SecretKey secretKey = keyGenerator.generateKey(); + return secretKey.getEncoded(); + } + + public static IvParameterSpec getIv() throws UnsupportedEncodingException { + IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes("utf-8")); + return ivParameterSpec; + } + + /** + * 加密 + * @param src + * @param key + * @return + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws IllegalBlockSizeException + * @throws BadPaddingException + * @throws UnsupportedEncodingException + * @throws InvalidAlgorithmParameterException + */ + public static byte[] encrypt(String src, byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException, InvalidAlgorithmParameterException { + SecretKey secretKey = new SecretKeySpec(key, Algorithm); + IvParameterSpec ivParameterSpec = getIv(); + Cipher cipher = Cipher.getInstance(AlgorithmProvider); + cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec); + byte[] cipherBytes = cipher.doFinal(src.getBytes(Charset.forName("utf-8"))); + return cipherBytes; + } + + /** + * 解密 + * @param src 原密码 + * @param key 解密后的byte数组 + * @return + * @throws Exception + */ + public static byte[] decrypt(String src, byte[] key) throws Exception { + SecretKey secretKey = new SecretKeySpec(key, Algorithm); + + IvParameterSpec ivParameterSpec = getIv(); + Cipher cipher = Cipher.getInstance(AlgorithmProvider); + cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec); + byte[] hexBytes = hexStringToBytes(src); + byte[] plainBytes = cipher.doFinal(hexBytes); + return plainBytes; + } + + /** + * 将byte转换为16进制字符串 + * @param src + * @return + */ + public static String byteToHexString(byte[] src) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < src.length; i++) { + int v = src[i] & 0xff; + String hv = Integer.toHexString(v); + if (hv.length() < 2) { + sb.append("0"); + } + sb.append(hv); + } + return sb.toString(); + } + + /** + * 将16进制字符串装换为byte数组 + * @param hexString + * @return + */ + public static byte[] hexStringToBytes(String hexString) { + hexString = hexString.toUpperCase(); + int length = hexString.length() / 2; + char[] hexChars = hexString.toCharArray(); + byte[] b = new byte[length]; + for (int i = 0; i < length; i++) { + int pos = i * 2; + b[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); + } + return b; + } + + private static byte charToByte(char c) { + return (byte) "0123456789ABCDEF".indexOf(c); + } + + /** + * 直接传入psd然后解码进行验证使用 + * @param psd 前台传过来的String 加密后的数组 + * @return + */ + public static String decrypt(String psd) { + try { + byte key[] = "1234567890ABCDEF1234567890ABCDEf".getBytes("utf-8"); + return new String(decrypt(psd, key)); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/vue/bill/.babelrc b/src/main/vue/bill/.babelrc deleted file mode 100644 index 9390d16..0000000 --- a/src/main/vue/bill/.babelrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "presets": [ - ["env", { - "modules": false, - "targets": { - "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] - } - }], - "stage-2" - ], - "plugins": ["transform-vue-jsx", "transform-runtime"], - "env": { - "test": { - "presets": ["env", "stage-2"], - "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] - } - } -} diff --git a/src/main/vue/bill/.editorconfig b/src/main/vue/bill/.editorconfig deleted file mode 100644 index 9d08a1a..0000000 --- a/src/main/vue/bill/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true diff --git a/src/main/vue/bill/.eslintignore b/src/main/vue/bill/.eslintignore deleted file mode 100644 index e2192c5..0000000 --- a/src/main/vue/bill/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -/build/ -/config/ -/dist/ -/*.js -/test/unit/coverage/ diff --git a/src/main/vue/bill/.eslintrc.js b/src/main/vue/bill/.eslintrc.js deleted file mode 100644 index 22fdce8..0000000 --- a/src/main/vue/bill/.eslintrc.js +++ /dev/null @@ -1,29 +0,0 @@ -// https://eslint.org/docs/user-guide/configuring - -module.exports = { - root: true, - parserOptions: { - parser: 'babel-eslint' - }, - env: { - browser: true, - }, - extends: [ - // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention - // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. - 'plugin:vue/essential', - // https://github.com/standard/standard/blob/master/docs/RULES-en.md - 'standard' - ], - // required to lint *.vue files - plugins: [ - 'vue' - ], - // add your custom rules here - rules: { - // allow async-await - 'generator-star-spacing': 'off', - // allow debugger during development - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' - } -} diff --git a/src/main/vue/bill/.gitignore b/src/main/vue/bill/.gitignore deleted file mode 100644 index dfb4167..0000000 --- a/src/main/vue/bill/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -.DS_Store -node_modules/ -/dist/ -npm-debug.log* -yarn-debug.log* -yarn-error.log* -/test/unit/coverage/ -/test/e2e/reports/ -selenium-debug.log - -# Editor directories and files -.idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln diff --git a/src/main/vue/bill/.postcssrc.js b/src/main/vue/bill/.postcssrc.js deleted file mode 100644 index eee3e92..0000000 --- a/src/main/vue/bill/.postcssrc.js +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/michael-ciniawsky/postcss-load-config - -module.exports = { - "plugins": { - "postcss-import": {}, - "postcss-url": {}, - // to edit target browsers: use "browserslist" field in package.json - "autoprefixer": {} - } -} diff --git a/src/main/vue/bill/README.md b/src/main/vue/bill/README.md index cf0dc63..1691f02 100644 --- a/src/main/vue/bill/README.md +++ b/src/main/vue/bill/README.md @@ -1,30 +1,29 @@ # bill -> bill - -## Build Setup - -``` bash -# install dependencies -npm install - -# serve with hot reload at localhost:8080 -npm run dev - -# build for production with minification -npm run build - -# build for production and view the bundle analyzer report -npm run build --report - -# run unit tests -npm run unit - -# run e2e tests -npm run e2e - -# run all tests -npm test +## Project setup +``` +yarn install ``` -For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). +### Compiles and hot-reloads for development +``` +yarn run serve +``` + +### Compiles and minifies for production +``` +yarn run build +``` + +### Run your tests +``` +yarn run test +``` + +### Lints and fixes files +``` +yarn run lint +``` + +### Customize configuration +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/src/main/vue/bill/babel.config.js b/src/main/vue/bill/babel.config.js new file mode 100644 index 0000000..ba17966 --- /dev/null +++ b/src/main/vue/bill/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/app' + ] +} diff --git a/src/main/vue/bill/config/dev.env.js b/src/main/vue/bill/config/dev.env.js deleted file mode 100644 index 1e22973..0000000 --- a/src/main/vue/bill/config/dev.env.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' -const merge = require('webpack-merge') -const prodEnv = require('./prod.env') - -module.exports = merge(prodEnv, { - NODE_ENV: '"development"' -}) diff --git a/src/main/vue/bill/config/index.js b/src/main/vue/bill/config/index.js deleted file mode 100644 index 926ab36..0000000 --- a/src/main/vue/bill/config/index.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict' -// Template version: 1.3.1 -// see http://vuejs-templates.github.io/webpack for documentation. - -const path = require('path') - -module.exports = { - dev: { - - // Paths - assetsSubDirectory: 'static', - assetsPublicPath: '/', - proxyTable: {}, - - // Various Dev Server settings - host: 'localhost', // can be overwritten by process.env.HOST - port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined - autoOpenBrowser: false, - errorOverlay: true, - notifyOnErrors: true, - poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- - - // Use Eslint Loader? - // If true, your code will be linted during bundling and - // linting errors and warnings will be shown in the console. - useEslint: true, - // If true, eslint errors and warnings will also be shown in the error overlay - // in the browser. - showEslintErrorsInOverlay: false, - - /** - * Source Maps - */ - - // https://webpack.js.org/configuration/devtool/#development - devtool: 'cheap-module-eval-source-map', - - // If you have problems debugging vue-files in devtools, - // set this to false - it *may* help - // https://vue-loader.vuejs.org/en/options.html#cachebusting - cacheBusting: true, - - cssSourceMap: true - }, - - build: { - // Template for index.html - index: path.resolve(__dirname, '../dist/index.html'), - - // Paths - assetsRoot: path.resolve(__dirname, '../dist'), - assetsSubDirectory: 'static', - assetsPublicPath: '/', - - /** - * Source Maps - */ - - productionSourceMap: true, - // https://webpack.js.org/configuration/devtool/#production - devtool: '#source-map', - - // Gzip off by default as many popular static hosts such as - // Surge or Netlify already gzip all static assets for you. - // Before setting to `true`, make sure to: - // npm install --save-dev compression-webpack-plugin - productionGzip: false, - productionGzipExtensions: ['js', 'css'], - - // Run the build command with an extra argument to - // View the bundle analyzer report after build finishes: - // `npm run build --report` - // Set to `true` or `false` to always turn it on or off - bundleAnalyzerReport: process.env.npm_config_report - } -} diff --git a/src/main/vue/bill/config/prod.env.js b/src/main/vue/bill/config/prod.env.js deleted file mode 100644 index a6f9976..0000000 --- a/src/main/vue/bill/config/prod.env.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' -module.exports = { - NODE_ENV: '"production"' -} diff --git a/src/main/vue/bill/config/test.env.js b/src/main/vue/bill/config/test.env.js deleted file mode 100644 index c2824a3..0000000 --- a/src/main/vue/bill/config/test.env.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' -const merge = require('webpack-merge') -const devEnv = require('./dev.env') - -module.exports = merge(devEnv, { - NODE_ENV: '"testing"' -}) diff --git a/src/main/vue/bill/deploy.sh b/src/main/vue/bill/deploy.sh new file mode 100755 index 0000000..c185ebd --- /dev/null +++ b/src/main/vue/bill/deploy.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +cd dist +tar czvf ../dist.tar.gz * +cd .. +scp dist.tar.gz gc:/tmp/ +ssh gc "sudo tar xzvf /tmp/dist.tar.gz -C /home/bill/www;sudo systemctl reload nginx" + + + diff --git a/src/main/vue/bill/index.html b/src/main/vue/bill/index.html deleted file mode 100644 index d118dc2..0000000 --- a/src/main/vue/bill/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - bill - - -
- - - diff --git a/src/main/vue/bill/package.json b/src/main/vue/bill/package.json index e020875..5daf6a8 100644 --- a/src/main/vue/bill/package.json +++ b/src/main/vue/bill/package.json @@ -1,92 +1,52 @@ { "name": "bill", - "version": "1.0.0", - "description": "bill", - "author": "alawn.cn@gmail.com", + "version": "0.1.0", "private": true, "scripts": { - "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", - "start": "npm run dev", - "unit": "jest --config test/unit/jest.conf.js --coverage", - "e2e": "node test/e2e/runner.js", - "test": "npm run unit && npm run e2e", - "lint": "eslint --ext .js,.vue src test/unit test/e2e/specs", - "build": "node build/build.js" + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint" }, "dependencies": { - "axios": "^0.18.0", - "element-ui": "^2.8.2", - "file-saver": "^2.0.2", + "axios": "^0.19.0", + "core-js": "^2.6.5", + "crypto-js": "^3.1.9-1", + "element-ui": "^2.9.1", "moment": "^2.24.0", - "vue": "^2.5.2", + "vue": "^2.6.10", "vue-json-excel": "^0.2.98", - "vue-router": "^3.0.1" + "vue-router": "^3.0.6" }, "devDependencies": { - "autoprefixer": "^7.1.2", - "babel-core": "^6.22.1", - "babel-eslint": "^8.2.1", - "babel-helper-vue-jsx-merge-props": "^2.0.3", - "babel-jest": "^24.8.0", - "babel-loader": "^7.1.1", - "babel-plugin-dynamic-import-node": "^1.2.0", - "babel-plugin-syntax-jsx": "^6.18.0", - "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", - "babel-plugin-transform-runtime": "^6.22.0", - "babel-plugin-transform-vue-jsx": "^3.5.0", - "babel-preset-env": "^1.3.2", - "babel-preset-stage-2": "^6.22.0", - "babel-register": "^6.22.0", - "chalk": "^2.0.1", - "chromedriver": "^2.27.2", - "copy-webpack-plugin": "^4.0.1", - "cross-spawn": "^5.0.1", - "css-loader": "^2.1.1", - "eslint": "^4.15.0", - "eslint-config-standard": "^10.2.1", - "eslint-friendly-formatter": "^3.0.0", - "eslint-loader": "^1.7.1", - "eslint-plugin-import": "^2.7.0", - "eslint-plugin-node": "^5.2.0", - "eslint-plugin-promise": "^3.4.0", - "eslint-plugin-standard": "^3.0.1", - "eslint-plugin-vue": "^4.0.0", - "extract-text-webpack-plugin": "^3.0.0", - "file-loader": "^1.1.4", - "friendly-errors-webpack-plugin": "^1.6.1", - "html-webpack-plugin": "^2.30.1", - "jest": "^24.8.0", - "jest-serializer-vue": "^0.3.0", - "nightwatch": "^1.1.11", - "node-notifier": "^5.1.2", - "optimize-css-assets-webpack-plugin": "^5.0.1", - "ora": "^1.2.0", - "portfinder": "^1.0.13", - "postcss-import": "^11.0.0", - "postcss-loader": "^2.0.8", - "postcss-url": "^7.2.1", - "rimraf": "^2.6.0", - "selenium-server": "^3.0.1", - "semver": "^5.3.0", - "shelljs": "^0.7.6", - "uglifyjs-webpack-plugin": "^1.1.1", - "url-loader": "^1.1.2", - "vue-jest": "^1.0.2", - "vue-loader": "^13.3.0", - "vue-style-loader": "^3.0.1", - "vue-template-compiler": "^2.5.2", - "webpack": "^3.6.0", - "webpack-bundle-analyzer": "^3.3.2", - "webpack-dev-server": "^2.9.1", - "webpack-merge": "^4.1.0" + "@vue/cli-plugin-babel": "^3.8.0", + "@vue/cli-plugin-eslint": "^3.8.0", + "@vue/cli-service": "^3.8.0", + "babel-eslint": "^10.0.1", + "eslint": "^5.16.0", + "eslint-plugin-vue": "^5.0.0", + "vue-template-compiler": "^2.6.10" }, - "engines": { - "node": ">= 6.0.0", - "npm": ">= 3.0.0" + "eslintConfig": { + "root": true, + "env": { + "node": true + }, + "extends": [ + "plugin:vue/essential", + "eslint:recommended" + ], + "rules": {}, + "parserOptions": { + "parser": "babel-eslint" + } + }, + "postcss": { + "plugins": { + "autoprefixer": {} + } }, "browserslist": [ "> 1%", - "last 2 versions", - "not ie <= 8" + "last 2 versions" ] } diff --git a/src/main/vue/bill/public/favicon.ico b/src/main/vue/bill/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/src/main/vue/bill/public/index.html b/src/main/vue/bill/public/index.html new file mode 100644 index 0000000..2092dce --- /dev/null +++ b/src/main/vue/bill/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + bill + + + +
+ + + diff --git a/src/main/vue/bill/src/App.vue b/src/main/vue/bill/src/App.vue index 4c8c7fc..9942bda 100644 --- a/src/main/vue/bill/src/App.vue +++ b/src/main/vue/bill/src/App.vue @@ -1,13 +1,28 @@ diff --git a/src/main/vue/bill/src/api/basic.js b/src/main/vue/bill/src/api/basic.js index 05c0352..2ba72d5 100644 --- a/src/main/vue/bill/src/api/basic.js +++ b/src/main/vue/bill/src/api/basic.js @@ -1,6 +1,6 @@ import HttpRequest from '@/axios/api.request' -export const addMerchant = (merc) => { +export const newMerchant = (merc) => { return HttpRequest.request({ url: 'basic/merchants', method: 'post', @@ -20,6 +20,14 @@ export const fetchTitles = () => { method: 'get' }) } + +export const addTitle = (title) => { + return HttpRequest.request({ + url: 'basic/titles', + method: 'post', + data: title + }) +} export const getMerchant = (id) => { return HttpRequest.request({ url: 'basic/merchants/' + id, @@ -28,11 +36,11 @@ export const getMerchant = (id) => { } -export const addPost = (merc) => { +export const addPost = (post) => { return HttpRequest.request({ url: 'basic/posts', method: 'post', - data: merc + data: post }) } diff --git a/src/main/vue/bill/src/api/user.js b/src/main/vue/bill/src/api/user.js index 0f186d4..a270f7f 100644 --- a/src/main/vue/bill/src/api/user.js +++ b/src/main/vue/bill/src/api/user.js @@ -1,6 +1,6 @@ import HttpRequest from '@/axios/api.request' -export const UserLoginAction = (ruleForm) => { +export const login = (ruleForm) => { return HttpRequest.request({ url: 'auth', method: 'post', diff --git a/src/main/vue/bill/src/axios/api.request.js b/src/main/vue/bill/src/axios/api.request.js index 90e18c1..4bf444e 100644 --- a/src/main/vue/bill/src/axios/api.request.js +++ b/src/main/vue/bill/src/axios/api.request.js @@ -6,6 +6,6 @@ const HttpRequest = axios.create({ // api的base_url baseURL: baseUrl, // 请求超时时间 - timeout: 5000 + timeout: 10000 }) export default HttpRequest diff --git a/src/main/vue/bill/src/axios/index.js b/src/main/vue/bill/src/axios/index.js index 2b0094b..c6f8e79 100644 --- a/src/main/vue/bill/src/axios/index.js +++ b/src/main/vue/bill/src/axios/index.js @@ -1,10 +1,9 @@ export default { - /** - * @description api请求基础路径 - */ - baseUrl: { - dev: 'http://localhost:30000/', - pro: 'http://localhost:30000/' - // pro: 'http://101.132.124.171:8080/demo-1.0/api/' - } -} + /** + * @description api请求基础路径 + */ + baseUrl: { + dev: 'http://localhost:30000', + pro: 'https://bill.fairy8.cn/api' + } +}; diff --git a/src/main/vue/bill/src/components/HelloWorld.vue b/src/main/vue/bill/src/components/HelloWorld.vue index 1c19f2a..879051a 100644 --- a/src/main/vue/bill/src/components/HelloWorld.vue +++ b/src/main/vue/bill/src/components/HelloWorld.vue @@ -1,84 +1,31 @@ @@ -86,18 +33,16 @@