This commit is contained in:
tangzh 2025-07-31 13:30:54 +08:00
parent b35335619c
commit 6d1481333f
14 changed files with 641 additions and 28 deletions

View File

@ -0,0 +1,19 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/busCarousel',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/busCarousel/',
method: 'delete',
data: ids
})
}
export default { add, del }

View File

@ -0,0 +1,155 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<!--表单组件-->
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
<el-form ref="form" :model="form" size="small" label-width="80px">
<el-form-item label="排序">
<el-input-number :min="1" v-model="form.sort" style="width: 370px;" />
</el-form-item>
<!-- 上传文件 -->
<el-form-item label="轮播图">
<el-upload
ref="upload"
:limit="1"
:before-upload="beforeUpload"
:auto-upload="false"
:headers="headers"
:on-success="handleSuccess"
:on-error="handleError"
:action="baseApi + '/api/busCarousel/pictures?sort=' + form.sort"
>
<div class="eladmin-upload"><i class="el-icon-upload" /> 添加文件</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="loading" type="primary" @click="upload">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column prop="id" label="编号" />
<el-table-column prop="path" label="轮播图" >
<template slot-scope="{row}">
<el-image
:src=" baseApi + row.path"
:preview-src-list="[baseApi + row.path]"
fit="contain"
lazy
class="el-avatar"
>
<div slot="error">
<i class="el-icon-document" />
</div>
</el-image>
</template>
</el-table-column>
<el-table-column prop="sort" label="排序" />
<el-table-column v-if="checkPer(['admin','busCarousel:del'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
/>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import crudBusCarousel from '@/api/bus/busCarousel/busCarousel'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { mapGetters } from 'vuex'
import { getToken } from "@/utils/auth";
const defaultForm = { id: null, name: null, path: null, sort: null }
export default {
name: 'Carousel',
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({ title: '', url: 'api/busCarousel', idField: 'id', sort: 'sort,asc', crudMethod: { ...crudBusCarousel }})
},
data() {
return {
permission: {
add: ['admin', 'busCarousel:add'],
edit: ['-1', 'busCarousel:edit'],
del: ['admin', 'busCarousel:del']
},
rules: {
path: [
{ required: true, message: '图片不能为空', trigger: 'blur' }
]
},
loading: false,
headers: { 'Authorization': getToken() },
}
},
created() {
this.crud.optShow = { add: true, del: true }
},
computed: {
...mapGetters([
'baseApi',
'fileUploadApi'
])
},
methods: {
// false
[CRUD.HOOK.beforeRefresh]() {
return true
},
//
upload() {
this.$refs.upload.submit()
},
beforeUpload(file) {
let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100
if (!isLt2M) {
this.loading = false
this.$message.error('上传文件大小不能超过 100MB!')
}
this.form.name = file.name
return isLt2M
},
handleSuccess(response, file, fileList) {
this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.$refs.upload.clearFiles()
this.crud.status.add = CRUD.STATUS.NORMAL
this.crud.resetForm()
this.crud.toQuery()
},
//
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
})
this.loading = false
}
}
}
</script>
<style scoped>
</style>

View File

@ -8,10 +8,6 @@
<el-input v-model="query.deviceSn" size="small" placeholder="输入设备号" style="width: 180px;" class="filter-item" @keyup.enter.native="crud.toQuery"/>
<el-input v-model="query.model" size="small" placeholder="输入型号" style="width: 180px;" class="filter-item" @keyup.enter.native="crud.toQuery"/>
<el-input v-model="query.brand" size="small" placeholder="输入品牌" style="width: 180px;" class="filter-item" @keyup.enter.native="crud.toQuery"/>
<el-select v-model="query.type" size="small" placeholder="选择类型" class="filter-item" style="width: 180px" @change="crud.toQuery">
<el-option key="" label="全部" value=""/>
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
<rrOperation/>
</div>
@ -93,7 +89,7 @@
<pagination />
<!-- 子窗口模态框组件 -->
<commandPage :visible.sync="showCommandData" :data="deviceId" @close="closeCommandPage" />
<!-- <commandPage :visible.sync="showCommandData" :data="deviceId" @close="closeCommandPage" /> -->
</div>
</div>
@ -106,7 +102,7 @@ import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import {mapGetters} from "vuex";
import { mapGetters } from 'vuex'
const defaultForm = { id: null, deviceSn: null, model: null, brand: null, firmwareVersion: null, location: null, status: null, onlineTime: null, offlineTime: null, totalPrintTime: null, remark: null, type: null, createBy: null, updateBy: null, createTime: null, updateTime: null }
export default {

View File

@ -17,6 +17,7 @@ package me.zhengjie.service.impl;
import cn.hutool.core.lang.Dict;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -123,6 +124,10 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
if (args[i] instanceof HttpServletRequest) {
continue;
}
// 过滤掉 JSONArray
if (args[i] instanceof JSONArray) {
continue;
}
// 将RequestBody注解修饰的参数作为请求参数
RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
if (requestBody != null) {

View File

@ -37,25 +37,6 @@
<artifactId>jjwt-jackson</artifactId>
<version>${jjwt.version}</version>
</dependency>
<!-- &lt;!&ndash; linux的管理 &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>ch.ethz.ganymed</groupId>-->
<!-- <artifactId>ganymed-ssh2</artifactId>-->
<!-- <version>build210</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.jcraft</groupId>-->
<!-- <artifactId>jsch</artifactId>-->
<!-- <version>0.1.55</version>-->
<!-- </dependency>-->
<!-- 获取系统信息 -->
<!-- <dependency>-->
<!-- <groupId>com.github.oshi</groupId>-->
<!-- <artifactId>oshi-core</artifactId>-->
<!-- <version>6.6.5</version>-->
<!-- </dependency>-->
</dependencies>
<!-- 打包 -->

View File

@ -0,0 +1,49 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.front.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.system.domain.BusCarousel;
import me.zhengjie.modules.system.domain.dto.BusCarouselQueryCriteria;
import me.zhengjie.modules.system.service.BusCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@RestController("CarouselController")
@RequestMapping("api/front/carousel")
@Api(tags = "微信:轮播图")
public class BusCarouselController {
@Autowired BusCarouselService busCarouselService;
@Log("轮播图")
@ApiOperation(value = "轮播图")
@GetMapping()
public ResponseEntity<List<String>> queryBusCarousel(){
List<BusCarousel> busCarousels = busCarouselService.queryAll(new BusCarouselQueryCriteria());
List<String> list = busCarousels.stream().map(BusCarousel::getPath).collect(Collectors.toList());
return new ResponseEntity<>(list,HttpStatus.OK);
}
}

View File

@ -65,9 +65,9 @@ public class WeChatServiceImpl implements WeChatService {
@Override
public LoginVo authorizeLogin(String code, HttpServletRequest request) {
LoginVo loginVo = new LoginVo();
WeChatMiniAuthorizeVo response = miniAuthCode(code);
// WeChatMiniAuthorizeVo response = new WeChatMiniAuthorizeVo();
// response.setOpenId("123456");
// WeChatMiniAuthorizeVo response = miniAuthCode(code);
WeChatMiniAuthorizeVo response = new WeChatMiniAuthorizeVo();
response.setOpenId("123456");
String openId = response.getOpenId();
String type = "login";
BusUser busUser = BusUserMapper.getUserByOpenId(openId);

View File

@ -0,0 +1,53 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* @description /
* @author tangz
* @date 2025-07-30
**/
@Data
@TableName("bus_carousel")
public class BusCarousel implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "路径")
private String path;
@ApiModelProperty(value = "排行")
private Integer sort;
public void copy(BusCarousel source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,33 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain.dto;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
/**
* @author tangz
* @date 2025-07-30
**/
@Data
public class BusCarouselQueryCriteria{
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.mapper;
import java.util.List;
import me.zhengjie.modules.system.domain.BusCarousel;
import me.zhengjie.modules.system.domain.dto.BusCarouselQueryCriteria;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* @author tangz
* @date 2025-07-30
**/
@Mapper
public interface BusCarouselMapper extends BaseMapper<BusCarousel> {
IPage<BusCarousel> findAll(@Param("criteria") BusCarouselQueryCriteria criteria, Page<Object> page);
List<BusCarousel> findAll(@Param("criteria") BusCarouselQueryCriteria criteria);
}

View File

@ -0,0 +1,97 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest;
import cn.hutool.core.util.ObjectUtil;
import me.zhengjie.annotation.Log;
import me.zhengjie.config.properties.FileProperties;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.BusCarousel;
import me.zhengjie.modules.system.domain.dto.BusCarouselQueryCriteria;
import me.zhengjie.modules.system.service.BusCarouselService;
import lombok.RequiredArgsConstructor;
import java.io.File;
import java.util.ArrayList;
import java.util.Set;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;
import org.springframework.web.multipart.MultipartFile;
/**
* @author tangz
* @date 2025-07-30
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统:轮播图")
@RequestMapping("/api/busCarousel")
public class BusCarouselController {
private final BusCarouselService busCarouselService;
private final FileProperties fileProperties;
@GetMapping
@ApiOperation("查询carousel")
@PreAuthorize("@el.check('busCarousel:list')")
public ResponseEntity<PageResult<BusCarousel>> queryBusCarousel(BusCarouselQueryCriteria criteria){
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
return new ResponseEntity<>(busCarouselService.queryAll(criteria,page),HttpStatus.OK);
}
@DeleteMapping
@Log("删除carousel")
@ApiOperation("删除用户")
@PreAuthorize("@el.check('busCarousel:del')")
public ResponseEntity<Object> deleteBusCarousel(@RequestBody Set<Long> ids){
for (Long id : ids) {
busCarouselService.deleteAll(new ArrayList(){{ add(id); }});
}
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("新增carousel")
@ApiOperation("上传轮播图")
@PostMapping("/pictures")
public ResponseEntity<String> uploadPicture(@RequestParam String sort, @RequestParam MultipartFile file){
// 判断文件是否为图片
String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){
throw new BadRequestException("只能上传图片");
}
String type = FileUtil.getFileType(suffix);
String path = fileProperties.getPath().getAvatar();
File uploadFile = FileUtil.upload(file, path + type + File.separator);
if(ObjectUtil.isNull(uploadFile)){
throw new BadRequestException("上传失败");
}
String[] split = path.split("/");
String imgUrl = "/" + split[split.length - 1] + "/" + type + "/" + uploadFile.getName();
BusCarousel resources = new BusCarousel();
resources.setSort(StringUtils.isEmpty(sort) ? null : Integer.parseInt(sort));
resources.setPath(imgUrl);
busCarouselService.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import me.zhengjie.modules.system.domain.BusCarousel;
import me.zhengjie.modules.system.domain.dto.BusCarouselQueryCriteria;
import me.zhengjie.utils.PageResult;
/**
* @description 服务接口
* @author tangz
* @date 2025-07-30
**/
public interface BusCarouselService extends IService<BusCarousel> {
/**
* 查询数据分页
* @param criteria 条件
* @param page 分页参数
* @return PageResult
*/
PageResult<BusCarousel> queryAll(BusCarouselQueryCriteria criteria, Page<Object> page);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<BusCarouselDto>
*/
List<BusCarousel> queryAll(BusCarouselQueryCriteria criteria);
/**
* 创建
* @param resources /
*/
void create(BusCarousel resources);
/**
* 编辑
* @param resources /
*/
void update(BusCarousel resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(List<Integer> ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<BusCarousel> all, HttpServletResponse response) throws IOException;
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2019-2025 Tz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service.impl;
import me.zhengjie.modules.system.domain.BusCarousel;
import me.zhengjie.modules.system.domain.dto.BusCarouselQueryCriteria;
import me.zhengjie.modules.system.mapper.BusCarouselMapper;
import me.zhengjie.modules.system.service.BusCarouselService;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import me.zhengjie.utils.PageUtil;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import me.zhengjie.utils.PageResult;
/**
* @description 服务实现
* @author tangz
* @date 2025-07-30
**/
@Service
@RequiredArgsConstructor
public class BusCarouselServiceImpl extends ServiceImpl<BusCarouselMapper, BusCarousel> implements BusCarouselService {
private final BusCarouselMapper busCarouselMapper;
@Override
public PageResult<BusCarousel> queryAll(BusCarouselQueryCriteria criteria, Page<Object> page){
return PageUtil.toPage(busCarouselMapper.findAll(criteria, page));
}
@Override
public List<BusCarousel> queryAll(BusCarouselQueryCriteria criteria){
return busCarouselMapper.findAll(criteria);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(BusCarousel resources) {
busCarouselMapper.insert(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(BusCarousel resources) {
BusCarousel busCarousel = getById(resources.getId());
busCarousel.copy(resources);
busCarouselMapper.updateById(busCarousel);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(List<Integer> ids) {
busCarouselMapper.deleteBatchIds(ids);
}
@Override
public void download(List<BusCarousel> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (BusCarousel busCarousel : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("名称", busCarousel.getName());
map.put("路径", busCarousel.getPath());
map.put("排行", busCarousel.getSort());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="me.zhengjie.modules.system.mapper.BusCarouselMapper">
<resultMap id="BaseResultMap" type="me.zhengjie.modules.system.domain.BusCarousel">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="path" property="path"/>
<result column="sort" property="sort"/>
</resultMap>
<sql id="Base_Column_List">
id, name, path, sort
</sql>
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_carousel
<where>
</where>
order by sort asc
</select>
</mapper>