云淘

All generations.

code to explanationSat, 18 Feb 2023

public static String get(String key){ if(environment == null){ try{ environment = ContextHelper.getApplicationContext().getEnvironment(); } catch (Exception e){ log.warn("无法获取Environment,参数配置可能不生效"); } } // 获取配置值 if(environment == null){ log.warn("无法获取上下文Environment,请在Spring初始化之后调用!"); return null; } String value = environment.getProperty(key); // 任何password相关的参数需解密 boolean isSensitiveConfig = key.contains(".password") || key.contains(".secret"); if(value != null && isSensitiveConfig){ value = Encryptor.decrypt(value); } return value; }

The get method first tries to get the Environment from ContextHelper. If the ContextHelper can not get the Environment, it will try to create a new environment by itself. Then return the value corresponding to the key in the environment. If it can not find the key, it will return null.

generate functionSat, 18 Feb 2023

封装一个基于ant-design-vue的弹窗组件

import { Message, MessageBox } from 'element-ui'; import { Message, MessageBox } from 'element-ui'; import { Message, MessageBox } from 'element-ui'; import { Message, MessageBox } from 'element-ui'; import { Message, MessageBox } from 'element-ui';

TypeScript
View
generate functionSat, 18 Feb 2023

封装一个基于ant-design-vue的弹窗组件

Script import { Modal } from 'ant-design-vue'; export default { props: { visible: { type: Boolean, default: false, }, }, methods: { showModal(title, content, okText = 'OK') { let modal = this.$refs.modal; modal.setProps({ title: title, content: content, okText: okText }); modal.setProps({ visible: true, }); }, }, render() { return ( <Modal ref="modal" {...{ on: { ok: () => { this.$emit('ok'); }, cancel: () => { this.$emit('cancel'); } } }}></Modal> ); } }

Java
View
generate functionSat, 18 Feb 2023

按照GPS距离由近到远排序

List<Shop> sortByGPS(List<Shop> list) { Collections.sort(list, new Comparator<Shop>() { @Override public int compare(Shop o1, Shop o2) { double dist1 = GPS.distance(o1.getLat(), o1.getLng()); double dist2 = GPS.distance(o2.getLat(), o2.getLng()); return (int) (dist1 - dist2); } }); return list; }

Java
View

Questions about programming?Chat with your personal AI assistant