ylb-接口14购买理财产品

news2024/9/22 1:27:42

总览:
在这里插入图片描述
在api模块service包,Invest类下添加(投资理财产品, int 是投资的结果 , 1 投资成功):

package com.bjpowernode.api.service;

import com.bjpowernode.api.pojo.BidInfoProduct;

import java.math.BigDecimal;
import java.util.List;

public interface InvestService {

    /** 查询某个产品的投资记录 */
    List<BidInfoProduct> queryBidListByProductId(Integer productId,
                                                 Integer pageNo,
                                                 Integer pageSize);

    /*投资理财产品, int 是投资的结果 , 1 投资成功*/
    int investProduct(Integer uid, Integer productId, BigDecimal money);
}

实现这个接口方法,在dataservice模块service包下,补充InvestServiceImpl,(投资理财产品, int 是投资的结果 , 1 投资成功):
1、参数检查(用户ID是否存在,产品ID是否存在,金钱是否存在且购买金额大于100和100整数倍)
2、查询账号金额(accountMapper.selectByUidForUpdate(uid)),比较资金(ge),是否满足购买要求
3、检查产品是否可以购买(产品不能为空且还有卖;比较ge:产品剩余可投资总金额大于要投的钱,要投的钱在最小和最大一个人可以投资金额之间)
4、可以购买了,扣除账号资金(更新资金accountMapper.updateAvailableMoneyByInvest(uid, money))
5、扣除产品剩余可投资金额(productInfoMapper.updateLeftProductMoney(productId, money))
6、创建投资记录(bidInfoMapper.insertSelective(bidInfo))
7、判断产品是否卖完(判断产品剩余可卖金额是否为0),更新产品是满标状态(productInfoMapper.updateSelled(productId))

package com.bjpowernode.dataservice.service;

import com.bjpowernode.api.model.BidInfo;
import com.bjpowernode.api.model.FinanceAccount;
import com.bjpowernode.api.model.ProductInfo;
import com.bjpowernode.api.pojo.BidInfoProduct;
import com.bjpowernode.api.service.InvestService;
import com.bjpowernode.common.constants.YLBConstant;
import com.bjpowernode.common.util.CommonUtil;
import com.bjpowernode.dataservice.mapper.BidInfoMapper;
import com.bjpowernode.dataservice.mapper.FinanceAccountMapper;
import com.bjpowernode.dataservice.mapper.ProductInfoMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@DubboService(interfaceClass = InvestService.class, version = "1.0")
public class InvestServiceImpl implements InvestService {

    @Resource
    private BidInfoMapper bidInfoMapper;

    @Resource
    private FinanceAccountMapper accountMapper;

    @Resource
    private ProductInfoMapper productInfoMapper;

    /**
     * 查询某个产品的投资记录
     */
    @Override
    public List<BidInfoProduct> queryBidListByProductId(Integer productId,
                                                        Integer pageNo,
                                                        Integer pageSize) {
        List<BidInfoProduct> bidList = new ArrayList<>();
        if (productId != null && productId > 0) {
            pageNo = CommonUtil.defaultPageNo(pageNo);
            pageSize = CommonUtil.defaultPageSize(pageSize);
            int offset = (pageNo - 1) * pageSize;
            bidList = bidInfoMapper.selectByProductId(productId, offset, pageSize);
        }
        return bidList;
    }

    /*投资理财产品, int 是投资的结果 , 1 投资成功*/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int investProduct(Integer uid, Integer productId, BigDecimal money) {
        int result = 0;//默认,参数不正确
        int rows = 0;
        //1参数检查
        if ((uid != null && uid > 0) && (productId != null && productId > 0)
                && (money != null && money.intValue() % 100 == 0 && money.intValue() >= 100)) {
            //2.查询账号金额
            FinanceAccount account = accountMapper.selectByUidForUpdate(uid);
            if (account != null) {
                if (CommonUtil.ge(account.getAvailableMoney(), money)) {
                    //资金满足购买要求
                    //3.检查产品是否可以购买
                    ProductInfo productInfo = productInfoMapper.selectByPrimaryKey(productId);
                    if (productInfo != null
                            && productInfo.getProductStatus() == YLBConstant.PRODUCT_STATUS_SELLING) {
                        if (CommonUtil.ge(productInfo.getLeftProductMoney(), money) &&
                                CommonUtil.ge(money, productInfo.getBidMinLimit()) &&
                                CommonUtil.ge(productInfo.getBidMaxLimit(), money)) {
                            //可以购买了 4. 扣除账号资金
                            rows = accountMapper.updateAvailableMoneyByInvest(uid, money);
                            if (rows < 1) {
                                throw new RuntimeException("投资更新账号资金失败");
                            }
                            //5.扣除产品剩余可投资金额
                            rows = productInfoMapper.updateLeftProductMoney(productId, money);
                            if (rows < 1) {
                                throw new RuntimeException("投资更新产品剩余金额失败");
                            }

                            //6.创建投资记录
                            BidInfo bidInfo = new BidInfo();
                            bidInfo.setBidMoney(money);
                            bidInfo.setBidStatus(YLBConstant.INVEST_STATUS_SUCC);
                            bidInfo.setBidTime(new Date());
                            bidInfo.setProdId(productId);
                            bidInfo.setUid(uid);
                            bidInfoMapper.insertSelective(bidInfo);

                            //7.判断产品是否卖完,更新产品是满标状态
                            ProductInfo dbProductInfo = productInfoMapper.selectByPrimaryKey(productId);
                            if( dbProductInfo.getLeftProductMoney().compareTo(new BigDecimal("0")) == 0 ){
                                rows  = productInfoMapper.updateSelled(productId);
                                if( rows < 1 ){
                                    throw new RuntimeException("投资更新产品满标失败");
                                }
                            }
                            //8.最后这是投资成功
                            result = 1;
                        }
                    } else {
                        result = 4;//理财产品不存在
                    }
                } else {
                    result = 3;//资金不足
                }
            } else {
                result = 2;//资金账号不存在
            }
        }
        return result;
    }
}

其中:
1、给uid的记录上锁(需要在dataservice模块mapper包下的FinanceAccountMapper接口添加方法,并在resources/mappers/FinanceAccountMapper.xml编写SQL语句):

    /*给uid的记录上锁*/
    FinanceAccount selectByUidForUpdate(@Param("uid") Integer uid);
  <!--/*给uid的记录上锁*/-->
  <select id="selectByUidForUpdate" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />
    from u_finance_account
    where uid = #{uid}
    for update
  </select>

2、在common模块util包下,CommonUtil类添加一个方法比较金额(比较BigDecimal:ge),是否可以购买:

package com.bjpowernode.common.util;

import java.math.BigDecimal;
import java.util.regex.Pattern;

public class CommonUtil {

    /*处理pageNo*/
    public static int defaultPageNo(Integer pageNo) {
        int pNo = pageNo;
        if (pageNo == null || pageNo < 1) {
            pNo = 1;
        }
        return pNo;
    }

    /*处理pageSize*/
    public static int defaultPageSize(Integer pageSize) {
        int pSize = pageSize;
        if (pageSize == null || pageSize < 1) {
            pSize = 1;
        }
        return pSize;
    }

    /*手机号脱敏*/
    public static String tuoMinPhone(String phone) {
        String result = "***********";
        if (phone != null && phone.trim().length() == 11) {
            result = phone.substring(0,3) + "******" + phone.substring(9,11);
        }
        return result;
    }


    /*手机号格式 true:格式正确;false不正确*/
    public static boolean checkPhone(String phone){
        boolean flag = false;
        if( phone != null && phone.length() == 11 ){
            //^1[1-9]\\d{9}$
            flag = Pattern.matches("^1[1-9]\\d{9}$",phone);
        }
        return flag;


    }

    /*比较BigDecimal  n1 >=n2 :true ,false*/
    public static boolean ge(BigDecimal n1, BigDecimal n2){
        if( n1 == null || n2 == null){
            throw new RuntimeException("参数BigDecimal是null");
        }
        return  n1.compareTo(n2) >= 0;
    }
}

3、更新资金(需要在dataservice模块mapper包下的FinanceAccountMapper接口添加方法,并在resources/mappers/FinanceAccountMapper.xml编写SQL语句):

    /*更新资金*/
    int updateAvailableMoneyByInvest(@Param("uid") Integer uid, @Param("money") BigDecimal money);
  <!--更新资金-->
  <update id="updateAvailableMoneyByInvest">
    update   u_finance_account set available_money = available_money - #{money}
    where uid = #{uid} and ( available_money - #{money} >=0 )
  </update>

4、扣除产品剩余可投资金额(需要在dataservice模块mapper包下的ProductInfoMapper接口添加方法,并在resources/mappers/ProductInfoMapper.xml编写SQL语句):

    /*扣除产品剩余可投资金额*/
    int updateLeftProductMoney(@Param("id") Integer productId, @Param("money") BigDecimal money);
  <!--扣除产品剩余可投资金额-->
  <update id="updateLeftProductMoney">
    update b_product_info set left_product_money = left_product_money - #{money}
    where id = #{id} and ( left_product_money - #{money} >=0 )
  </update>

5、更新产品为满标(需要在dataservice模块mapper包下的ProductInfoMapper接口添加方法,并在resources/mappers/ProductInfoMapper.xml编写SQL语句):

    /*更新产品为满标*/
    int updateSelled(@Param("id") Integer productId);
  <!--*更新产品为满标-->
  <update id="updateSelled">
    update  b_product_info set product_status = 1 ,  product_full_time = now()
    where id = #{id}
  </update>

在web模块controller包,InvestController类下添加(购买理财产品, 更新投资排行榜):
1、检查基本参数(用户ID是否存在,产品ID是否存在,金钱是否存在且购买金额大于100和100整数倍)
2、根据investResult结果判断
3、更新投资排行榜(modifyInvestRank(uid,money))

package com.bjpowernode.front.controller;

import com.bjpowernode.api.model.User;
import com.bjpowernode.common.constants.RedisKey;
import com.bjpowernode.common.util.CommonUtil;
import com.bjpowernode.front.view.RespResult;
import com.bjpowernode.front.view.invest.RankView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * 有关投资功能
 */

@Api(tags = "投资理财产品")
@RestController
public class InvestController extends BaseController {

    /*投资排行榜*/
    @ApiOperation(value = "投资排行榜", notes = "显式投资金额最高的3位用户信息")
    @GetMapping("/v1/invest/rank")
    public RespResult showInvestRank() {
        //从redis查询数据
        Set<ZSetOperations.TypedTuple<String>> sets = stringRedisTemplate
                .boundZSetOps(RedisKey.KEY_INVEST_RANK).reverseRangeWithScores(0, 2);

        List<RankView> rankList = new ArrayList<>();
        //遍历set集合
        sets.forEach(tuple -> {
            //tuple.getValue();//手机号
            //tuple.getScore();//投资金额
            rankList.add(new RankView(CommonUtil.tuoMinPhone(tuple.getValue()), tuple.getScore()));
        });

        RespResult result = RespResult.ok();
        result.setList(rankList);
        return result;
    }



    /*购买理财产品, 更新投资排行榜*/
    @ApiOperation(value = "投资理财产品")
    @PostMapping("/v1/invest/product")
    public RespResult investProduct(
            @RequestHeader("uid") Integer uid,
            @RequestParam("productId") Integer productId,
            @RequestParam("money") BigDecimal money){
        RespResult result = RespResult.fail();
        //1.检查基本参数
        if( (uid != null && uid > 0) && (productId != null && productId > 0)
           &&( money != null && money.intValue() % 100 == 0 && money.intValue() >= 100)){
            int investResult = investService.investProduct(uid,productId,money);
            switch (investResult){
                case 0:
                    result.setMsg("投资数据不正确");
                    break;
                case 1:
                    result = RespResult.ok();
                    modifyInvestRank(uid,money);
                    break;
                case 2:
                    result.setMsg("资金账号不存在");
                    break;
                case 3:
                    result.setMsg("资金不足");
                    break;
                case 4:
                    result.setMsg("理财产品不存在");
                    break;
            }
        }
        return result;
    }

    /*更新投资排行榜*/
    private void modifyInvestRank(Integer uid,BigDecimal money){
        User user  = userService.queryById(uid);
        if(user != null){
            //更新redis中的投资排行榜
            String key = RedisKey.KEY_INVEST_RANK;
            stringRedisTemplate.boundZSetOps(key).incrementScore(
                              user.getPhone(),money.doubleValue());
        }
    }
}

其中:
1、在web模块controller包,InvestController内添加一个方法,更新redis中的投资排行榜(更新投资排行榜modifyInvestRank):
2、在api模块service包,UserService添加查询用户方法(userService.queryById(uid))

package com.bjpowernode.api.service;

import com.bjpowernode.api.model.User;
import com.bjpowernode.api.pojo.UserAccountInfo;

public interface UserService {

    /**
     * 根据手机号查询数据
     */
    User queryByPhone(String phone);

    /*用户注册*/
    int userRegister(String phone, String password);

    /*登录*/
    User userLogin(String phone, String pword);

    /*更新实名认证信息*/
    boolean modifyRealname(String phone, String name, String idCard);

    /*获取用户和资金信息*/
    UserAccountInfo queryUserAllInfo(Integer uid);

    /*查询用户*/
    User queryById(Integer uid);
}

3、在dataservice模块service包,UserService实现这个接口方法

package com.bjpowernode.dataservice.service;

import com.bjpowernode.api.model.FinanceAccount;
import com.bjpowernode.api.model.User;
import com.bjpowernode.api.pojo.UserAccountInfo;
import com.bjpowernode.api.service.UserService;
import com.bjpowernode.common.util.CommonUtil;
import com.bjpowernode.dataservice.mapper.FinanceAccountMapper;
import com.bjpowernode.dataservice.mapper.UserMapper;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;

@DubboService(interfaceClass = UserService.class,version = "1.0")
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Resource
    private FinanceAccountMapper financeAccountMapper;

    @Value("${ylb.config.password-salt}")
    private String passwordSalt;

    @Override
    public User queryByPhone(String phone) {
        User user = null;
        if(CommonUtil.checkPhone(phone)){
            user = userMapper.selectByPhone(phone);
        }
        return user;
    }

    /*用户注册*/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public synchronized int userRegister(String phone, String password) {
        int result = 0;//默认参数不正确
        if( CommonUtil.checkPhone(phone)
                && (password != null && password.length()==32)){

            //判断手机号在库中是否存在
            User queryUser = userMapper.selectByPhone(phone);
            if(queryUser == null){
                //注册密码的md5二次加密。 给原始的密码加盐(salt)
                String newPassword = DigestUtils.md5Hex( password + passwordSalt);

                //注册u_user
                User user = new User();
                user.setPhone(phone);
                user.setLoginPassword(newPassword);
                user.setAddTime(new Date());
                userMapper.insertReturnPrimaryKey(user);

                //获取主键user.getId()
                FinanceAccount account = new FinanceAccount();
                account.setUid(user.getId());
                account.setAvailableMoney(new BigDecimal("0"));
                financeAccountMapper.insertSelective(account);

                //成功result = 1
                result = 1;
            } else {
                //手机号存在
                result = 2;
            }
        }
        return result;
    }

    /*登录*/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public User userLogin(String phone, String password) {

        User user = null;
        if( CommonUtil.checkPhone(phone) && (password != null && password.length() == 32)) {
            String newPassword = DigestUtils.md5Hex( password + passwordSalt);
            user = userMapper.selectLogin(phone,newPassword);
            //更新最后登录时间
            if( user != null){
                user.setLastLoginTime(new Date());
                userMapper.updateByPrimaryKeySelective(user);
            }
        }
        return user;
    }

    /*更新实名认证信息*/
    @Override
    public boolean modifyRealname(String phone, String name, String idCard) {
        int rows = 0;
        if(!StringUtils.isAnyBlank(phone,name,idCard)){
             rows  = userMapper.updateRealname(phone,name,idCard);
        }
        return rows > 0 ;
    }

    /*获取用户和资金信息*/
    @Override
    public UserAccountInfo queryUserAllInfo(Integer uid) {
        UserAccountInfo info = null;
        if( uid != null && uid > 0 ) {
            info  = userMapper.selectUserAccountById(uid);
        }
        return info ;
    }

    /*查询用户*/
    @Override
    public User queryById(Integer uid) {
        User user = null;
        if( uid != null && uid > 0 ){
            user = userMapper.selectByPrimaryKey(uid);
        }
        return user;
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/759558.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

go mod vendor简明介绍

Go 语言在 go 1.6 版本以后编译 go 代码会优先从 vendor 目录先寻找依赖包&#xff0c;它具有以下优点&#xff1a; 复制依赖&#xff1a;go mod vendor 会把程序所依赖的所有包复制到项目目录下的vendor 文件夹中&#xff0c;所以即使这些依赖包在外部源&#xff08;如 GitHu…

MySQL 约束、聚合查询和联合查询练习

1. 数据库约束 设置一个考勤系统, 包含员工表&#xff0c;考勤记录表 首先要明白, 员工表对考勤记录表是一对多 员工表中起码包含 id , name 考勤记录表则包含 id, 日期, 考勤记录 考勤记录表为子表, id 则为外键约束 员工表为父键, id则为主键约束 搞明白这些, 接下来就…

【C语言】矩阵相乘

#include <stdio.h>#define M 3 #define N 4 #define P 3void fun(int a[M][N], int b[N][P], int m, int p, int n)//定义函数fun {printf("m: %d, p: %d, n: %d\n", m, p, n);int c[M][P]{0};int i, j, k;for(i 0; i < m; i){for(j 0; j < n; j){fo…

【数据结构】朴素模式匹配 KMP算法

&#x1f387;【数据结构】朴素模式匹配 & KMP 算法&#x1f387; &#x1f308; 自在飞花轻似梦,无边丝雨细如愁 &#x1f308; &#x1f31f; 正式开始学习数据结构啦~此专栏作为学习过程中的记录&#x1f31f; 文章目录 &#x1f387;【数据结构】朴素模式匹配 & K…

IDEA中设置鼠标滚轮修改字体大小

IDEA中设置鼠标滚轮修改字体大小&#xff1f; 选择File--Settings--Editor--General&#xff0c;把 Mouse Control 前的对勾勾选 后点击 OK 即可。 勾选此设置后&#xff0c;增加 Ctrl 鼠标滚轮 快捷键来控制代码字体大小显 示。字体随时可以放大缩小~~可真好用呢~

IDEA运行TOMCAT出现404

就这种问题&#xff0c;每个人的原因都不一定一样&#xff0c;我出现这种问题的解决方法在这里记录一下。顺便把我的配置记录一下。 除了本文的问题&#xff0c;还有可能是默认打开的文件名错了&#xff0c;或者端口被占用。 软件版本IDEA2023 TOMCAT9 亲测&#xff1a;IDE…

❤️创意网页:如何使用HTML制作漂亮的搜索框

✨博主&#xff1a;命运之光 &#x1f338;专栏&#xff1a;Python星辰秘典 &#x1f433;专栏&#xff1a;web开发&#xff08;简单好用又好看&#xff09; ❤️专栏&#xff1a;Java经典程序设计 ☀️博主的其他文章&#xff1a;点击进入博主的主页 前言&#xff1a;欢迎踏入…

pycharm python 函数添加注释 快捷键

写完函数定义后,在函数名下面点击,并按下敲入""",完后回车,这会自动生成函数的文档注释格式 完后找我要插件,会阅读函数的内容,自动生成注释的内容.

RootThis靶机复盘

RootThis靶机复盘 在这个靶机中收获良多&#xff0c;首先学会了一个新的交互方式&#xff0c;不需要用python了&#xff0c;同时知道了什么是静态链接文件&#xff0c;还有就是学会了遇到数据库文件应该怎么解决。 /usr/bin/script -qc /bin/bash /dev/null 静态链接版本的程…

openpnp - 相机图像亮度太高的解决方法

文章目录 openpnp - 相机图像亮度太高的解决方法概述笔记设置相机的合适参数白平衡END openpnp - 相机图像亮度太高的解决方法 概述 看到同学在群里讨论问题, 说相机补光灯亮度太高了, 导致openpnp图像惨白惨白的, 根本不能用. 能根本解决问题的方法, 就是群里同学说的, 用恒…

Linux —— 进程状态

目录 一&#xff0c;进程状态分类 二&#xff0c;僵尸进程 三&#xff0c;孤儿进程 一&#xff0c;进程状态分类 进程状态反应进程执行过程中的变化&#xff0c;状态会随外界条件的变化而转换&#xff1b; 三态模型&#xff0c;运行态、就绪态、阻塞态&#xff1b;五态模型…

PyTorch: 权值初始化

文章和代码已经归档至【Github仓库&#xff1a;https://github.com/timerring/dive-into-AI 】或者公众号【AIShareLab】回复 pytorch教程 也可获取。 文章目录 Pytorch&#xff1a;权值初始化梯度消失与梯度爆炸 Xavier 方法与 Kaiming 方法Xavier 方法nn.init.calculate_gain…

Spark3新特性

Spark AQE 自适应查询优化&#xff1a; 实现运行时优化&#xff0c;纠正因统计信息不准确导致生成的逻辑计划不完善或有误的问题 动态调整JOIN策略&#xff1a;类似于mapjoin优化&#xff0c;将sortMergejoin转换成broadcasthashjoin&#xff0c;也就是将小表当作广播变量分发…

基于深度学习的高精度线路板瑕疵目标检测系统(PyTorch+Pyside6+YOLOv5模型)

摘要&#xff1a;基于深度学习的高精度线路板瑕疵目标检测系统可用于日常生活中来检测与定位线路板瑕疵目标&#xff0c;利用深度学习算法可实现图片、视频、摄像头等方式的线路板瑕疵目标检测识别&#xff0c;另外支持结果可视化与图片或视频检测结果的导出。本系统采用YOLOv5…

SpringBoot+Vue实现的高校图书馆管理系统

项目描述&#xff1a;这是一个基于SpringBootVue框架开发的高校图书馆管理系统。首先&#xff0c;这是一个前后端分离的项目&#xff0c;代码简洁规范&#xff0c;注释说明详细&#xff0c;易于理解和学习。其次&#xff0c;这项目功能丰富&#xff0c;具有一个高校图书馆管理系…

外包软件定制开发中知识保护和安全性问题及解决方案

引言 外包软件定制开发在当今的商业环境中越来越普遍&#xff0c;它为企业提供了灵活性和成本效益。然而&#xff0c;与外包合作也带来了一些风险&#xff0c;其中最重要的就是知识保护和安全性问题。在外包软件定制开发过程中&#xff0c;共享敏感信息和知识产权是不可避免的…

redis基本操作

string数据类型的命令操作 设置键值 使用append 命令设置键值&#xff0c;后面跟键的名字&#xff0c;可以先判断该建是否存在&#xff0c;存在将值追加在后面&#xff0c;不存在自动添加该建 append mykey hello读取键值 get mykey数值类型自减1 数值类型自加1 查看值的…

记录C#知识点(二)21-40

目录 21.性能优化 22.动态dynamic使用 23.中文乱码 24.启动项目之前&#xff0c;执行文件 25.深拷贝-反射实现 26.丢弃运算符 _ 27.winform程序使用管理员运行 28.wpf程序使用管理员运行 21.性能优化 1.检查空字符串&#xff1a;使用string.Empty 2.更改类型转换&…

Java设计模式之行为型-访问者模式(UML类图+案例分析)

目录 一、基础概念 二、UML类图 三、角色设计 四、案例分析 五、总结 一、基础概念 访问者模式是一种对象行为型设计模式&#xff0c;它能够在不修改已有对象结构的前提下&#xff0c;为对象结构中的每个对象提供新的操作。 访问者模式的主要作用是把对元素对象的操作抽…