Spring boot+Layui编写完整后台管理系统

2 篇文章 0 订阅
1 篇文章 0 订阅

Spring boot+Layui编写完整后台管理系统

代码结构

在这里插入图片描述

运行截图

在这里插入图片描述在这里插入图片描述在这里插入图片描述

部分代码:

package com.example.ly.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.ly.VO.AdminVO;
import com.example.ly.VO.UserVO;
import com.example.ly.entity.Identype;
import com.example.ly.entity.User;
import com.example.ly.mapper.IdentypeMapper;
import com.example.ly.mapper.UserMapper;
import com.example.ly.service.Adminservice;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AdminserviceImpl implements Adminservice {

    @Autowired
    private UserMapper userMapper;//用户信息
    @Autowired
    private IdentypeMapper identypeMapper;//身份信息
    @Override
    public UserVO<AdminVO> findData() {

        UserVO userVO=new UserVO();
        userVO.setCode(0);
        userVO.setMsg("");
        userVO.setCount(userMapper.selectCount(null));//总条数

        List<User> userList=userMapper.selectList(null);//旧用户列表
        List<AdminVO> userVOList = new ArrayList<>();//新用户列表
        for (User user : userList) {//遍历userList
            AdminVO adminVO = new AdminVO();
            BeanUtils.copyProperties(user,adminVO);//用户列表信息映射

            QueryWrapper wrapper = new QueryWrapper();
            wrapper.eq("id",user.gettype());//gettype返回原用户信息中的type(应该返回的是type表中的id)
            Identype identype = identypeMapper.selectOne(wrapper);//根据id查type

            if(identype!=null){
                adminVO.setidentype(identype.getidtype());//设置adminvo中的type为查询后的type
            }
            userVOList.add(adminVO);//将userVO中的data数据添加到
        }
        userVO.setData(userVOList);//data数据
        return userVO;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值