zzw-one #5

Merged
root merged 6 commits from zzw-one into master 2024-08-20 15:20:02 +08:00
11 changed files with 583 additions and 0 deletions
Showing only changes of commit b3850a58c5 - Show all commits

View File

@ -0,0 +1,40 @@
import request from '@/config/axios'
export interface ArticleVO {
id: number
title: string
collectionQuantity: string
pageView: string
introduction: string
inputarr: string[]
}
// 查询文章管理列表
export const selectDynamicData = async () => {
return await request.get({ url: `/intelligentForm/selectDynamicData` })
}
// // 查询文章管理详情
// export const saveDynamicData = async (id: number) => {
// return await request.get({ url: `/promotion/article/get?id=` + id })
// }
// 新增文章管理
export const saveDynamicData = async (data: ArticleVO) => {
return await request.post({ url: `/intelligentForm/saveDynamicData`, data })
}
// 查询文章管理列表
export const collectDataList = async (query: any) => {
return await request.get({ url: `/intelligentForm/collectDataList`, query })
}
// // 修改文章管理
// export const updateArticle = async (data: ArticleVO) => {
// return await request.put({ url: `/promotion/article/update`, data })
// }
// // 删除文章管理
// export const deleteArticle = async (id: number) => {
// return await request.delete({ url: `/promotion/article/delete?id=` + id })
// }

View File

@ -0,0 +1,280 @@
<template>
<div class="app-container" style="display: flex;flex-wrap: wrap">
<!-- <el-col :span="8" v-for="(o, index) in 1" :key="o" :offset="index > 0 ? 2 : 0">-->
<el-card class="box-card">
<div class="container">
<el-button type="primary" plain @click="handleAdd" style="border: none;">
+ 新建表单
</el-button>
</div>
</el-card>
<el-card class="box-card" v-for="o in cardList" :key="o" >
<div slot="header" class="clearfix">
<span style="font-size: 23px;
color: #000000;
background-color:#ffffff;
border-color: #fdfdff;">{{o.title}}</span>
<el-button style="float: right; padding: 3px 0" type="text" @click="handelExtend(o.id)">推广</el-button>
</div>
<div style="display: flex;justify-content: space-between">
<!-- <div style="width: 30%">-->
<!-- <div>采购员</div>-->
<!-- <p style="font-size: 25px">1</p>-->
<!-- </div>-->
<div style="width: 30%">
<div style="font-size: 18px;
color: #999595;
background-color:#ffffff;
border-color: #fdfdff;">总浏览量</div>
<p style="font-size: 25px">{{o.pageView}}</p>
</div>
<div style="width: 30%">
<el-link style="font-size: 18px;
color: #999595;
background-color:#ffffff;
border-color: #fdfdff;"
@click="extendList(o.id)">采集数量</el-link>
<p style="font-size: 25px" @click="extendList(o.id)">{{o.collectionQuantity}}</p>
</div>
</div>
<div style="display: flex;justify-content: space-between">
<div>
<span style="font-size: 16px;
color: #999595;
background-color:#ffffff;
border-color: #fdfdff;">创建人{{o.createPeople}}</span>
</div>
<div style="font-size: 16px;
color: #999595;
background-color:#ffffff;
border-color: #fdfdff;">创建时间{{o.createTime}}</div>
</div>
</el-card>
<!-- </el-col>-->
<!-- 添加表单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<div style="text-align: center">
<!-- <el-form-item label="表单标题">-->
<div><span>标题</span> <el-input style="border-bottom: 1px solid skyblue;margin-bottom: 10px" v-model="addParams.title" placeholder="请输入表单标题" />
</div>
<!-- </el-form-item>-->
<!-- <el-form-item label="字段名称">-->
<div v-for="(item,index) in inputarr" key="index" style="margin-bottom: 10px;">
<span>字段</span> <el-input style="border: 1px solid #DCDFE6;border-radius: 3px; " v-model="inputarr[index]" placeholder="请输入字段"></el-input>
</div>
<div>
<el-button @click="adinput" style="text-align: center;width: 90%;background-color: rgb(232,244,255);color:#1890ff">添加字段</el-button>
</div>
<!-- </el-form-item>-->
</div>
<br>
<div class="el-input-foot">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 推广链接对话框-->
<el-dialog :title="extendTitle" :visible.sync="extendOpen" width="500px" append-to-body>
<el-input v-model="extendLink" placeholder="请输入内容" :disabled="true"></el-input>
<el-button @click="copyAddress">复制</el-button>
</el-dialog>
<!-- 采集数据列表 -->
<el-dialog :title="collectTitle" :visible.sync="collectOpen" append-to-body>
<el-table border v-loading="loading" :data="collectLink" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<div >
</div>
<!-- <el-table-column label="编号" align="center" prop="id" />-->
<!-- <el-table-column label="id" align="center" prop="dynamicDataId" />-->
<!-- <el-table-column v-for="item in collectLink" :label="item.map" align="center" :prop="item" />-->
<template v-for="item in Object.keys(collectLink[0])">
<el-table-column :label="item">
<template #default="scope">
<span>{{scope.row[item]}}</span>
</template>
</el-table-column>
</template>
</el-table>
</el-dialog>
</div>
</template>
<script>
import * as ArticleCategoryApi from "@/api/mall/promotion/intelligent";
export default {
name: "Business",
dicts: ['stage_type', 'sales_stage'],
data() {
return {
id: '',
inputarr:[''],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
title: "",
//广
extendTitle: "",
//
collectTitle: "",
//
open: false,
// 广
extendOpen: false,
//
collectOpen: false,
//广
extendLink: '',
//
collectLink: [{}],
//
customerList: [],
//
cardList: [],
addParams: {
title:'',
pageView:'',
collectionQuantity:'',
inputarr: []
}
};
},
created() {
this.getIntelligentList();
},
methods: {
//
adinput(){
this.inputarr.push('')
console.log(this.inputarr)
},
getIntelligentList() {
this.loading = true;
ArticleCategoryApi.selectDynamicData().then(response => {
this.cardList = response.data;
// this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
},
//
submitForm(){
this.addParams.inputarr = this.inputarr
this.addParams.pageView = '0'
this.addParams.collectionQuantity = '0'
ArticleCategoryApi.saveDynamicData(this.addParams).then(response => {
// this.cardList = response.data;
// this.total = response.total;
this.loading = false;
this.open = false;
this.getIntelligentList();
});
},
/** 新增按钮操作 */
handleAdd() {
this.inputarr = []
this.addParams = {
title:'',
inputarr: []
}
this.open = true;
this.title = "添加表单";
},
//广
handelExtend(id) {
this.extendLink = 'http://101.43.112.107/form/extendLink/form?id='+id
this.extendOpen = true;
this.extendTitle = "推广链接";
},
//
copyAddress() {
const input = document.createElement('input');
input.value = this.extendLink;
document.body.appendChild(input);
input.select();
document.execCommand('copy');
document.body.removeChild(input);
alert('已复制到剪贴板');
},
//
extendList(id){
this.collectLink = null;
this.id = id
this.collectOpen = true;
this.collectTitle = "采集数据";
ArticleCategoryApi.collectDataList(this.id).then(response => {
this.collectLink = response.data
});
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
},
};
</script>
<style scoped>
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
.box-card {
width:32%;
margin-bottom: 10px;
margin-right:10px;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100px; /* 可根据需要调整高度 */
color: #ccc; /* 灰白色 */
}
.el-input-foot{
padding: 20px;
padding-top: 10px;
text-align: center;
box-sizing: border-box;
}
::v-deep.el-input--medium{
width: 80%;
}
::v-deep.el-input--medium .el-input__inner{
border: none;
/* border-bottom:1px solid blue; */
}
</style>

View File

@ -73,6 +73,12 @@
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId> <artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency> </dependency>
<!--MongoDB依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.promotion.controller.admin.dynamic;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm;
import cn.iocoder.yudao.module.promotion.service.dynamic.DynamicDataService;
import cn.iocoder.yudao.module.promotion.service.dynamic.DynamicFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 智能表单模块
*/
@RestController
@RequestMapping("/intelligentForm")
public class DynamicDataController {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private DynamicDataService dynamicDataService;
@Autowired
private DynamicFormService dynamicFormService;
//保存数据
@PostMapping("/saveDynamicData")
public CommonResult<String> saveDynamicData(@RequestBody Map<String, Object> requestData, HttpServletRequest httpServletRequest) {
dynamicDataService.doSaveDynamicData(requestData,httpServletRequest);
return success("保存成功");
}
//查询全部数据
@GetMapping("/selectDynamicData")
public CommonResult<List<DynamicData>> selectDynamicData(HttpServletRequest httpServletRequest) {
return success(dynamicDataService.doSelectDynamicData(httpServletRequest));
}
//根据id查询数据
@GetMapping("/selectDynamicDataById")
public CommonResult<DynamicData> selectDynamicDataById(String id){
return success(dynamicDataService.doSelectDynamicDataById(id));
}
//采集数据
@PostMapping("/collectData")
public CommonResult<String> collectData(@RequestBody DynamicForm dynamicForm){
dynamicFormService.doCollectData(dynamicForm);
return success("保存成功");
}
//根据卡片id查询对应采集数据的列表
@GetMapping("/collectDataList")
public CommonResult<ArrayList<Object>> collectDataList(String id){
return success(dynamicFormService.doCollectDataList(id));
}
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Map;
@Document(collection = "dynamicData")
@Data
public class DynamicData {
@Id
private String id;
private String title;
//总浏览量
private String pageView;
//采集数量
private String collectionQuantity;
//创建者
private String createPeople;
//创建时间
private String createTime;
//租户名称
private String tenantName;
//用户字段数据
private Map<String, Object> data;
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic;
import lombok.Data;
import org.springframework.data.annotation.Id;
import java.util.Map;
@Data
public class DynamicForm {
@Id
private String id;
//关联后台智能表单id
private String dynamicDataId;
//采集数据
private Map<String,Object> map;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.promotion.dal.mysql.repository;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData;
import org.apache.ibatis.annotations.Mapper;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
//@Repository
@Mapper
public interface DynamicDataRepository extends MongoRepository<DynamicData,String> {
List<DynamicData> findByTenantName(String tenantName);
@Query("{'_id': {'$eq': ?0}}")
DynamicData doFindById(ObjectId id);
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.promotion.dal.mysql.repository;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
//@Repository
@Mapper
public interface DynamicFormRepository extends MongoRepository<DynamicForm,String> {
Long countAllByDynamicDataId(String dynamicDataId);
List<DynamicForm> findByDynamicDataId(String id);
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.promotion.service.dynamic;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData;
import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicDataRepository;
import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicFormRepository;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
@Service
public class DynamicDataService {
@Autowired
private DynamicDataRepository dynamicDataRepository;
@Autowired
private DynamicFormRepository dynamicFormRepository;
//保存数据
public DynamicData doSaveDynamicData(Map<String, Object> requestData, HttpServletRequest httpServletRequest){
DynamicData dynamicData = new DynamicData();
//构造数据结构
String title = (String)requestData.get("title");
String pageView = (String)requestData.get("pageView");
String collectionQuantity = (String)requestData.get("collectionQuantity");
dynamicData.setTitle(title);
requestData.remove("title");
dynamicData.setPageView(pageView);
requestData.remove("pageView");
dynamicData.setCollectionQuantity(collectionQuantity);
requestData.remove("collectionQuantity");
ArrayList<String> inputarr = (ArrayList)requestData.get("inputarr");
for (String s : inputarr) {
requestData.put(s,null);
}
requestData.remove("inputarr");
dynamicData.setCreatePeople(getLoginUserId(httpServletRequest).toString());
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter);
dynamicData.setCreateTime(formattedDate);
dynamicData.setData(requestData);
dynamicData.setTenantName(httpServletRequest.getHeader("Tenant"));
return dynamicDataRepository.save(dynamicData);//插入dynamicData数据
}
//查询全部数据
public List<DynamicData> doSelectDynamicData(HttpServletRequest httpServletRequest){
//查询对应租户下的卡片列表数据
List<DynamicData> dynamicData = dynamicDataRepository.findByTenantName(httpServletRequest.getHeader("Tenant"));
for (DynamicData dynamicDatum : dynamicData) {
//查询对应卡片链接采集到数据的数量
Long count = dynamicFormRepository.countAllByDynamicDataId(dynamicDatum.getId());
dynamicDatum.setCollectionQuantity(count+"");
}
return dynamicData;
}
//根据id查询数据
public DynamicData doSelectDynamicDataById(String id){
ObjectId objectId = new ObjectId(id);
DynamicData dynamicData = dynamicDataRepository.doFindById(objectId);
dynamicData.setPageView(Long.parseLong(dynamicData.getPageView())+1+"");
return dynamicDataRepository.save(dynamicData);
}
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.promotion.service.dynamic;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm;
import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicFormRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class DynamicFormService {
@Autowired
private DynamicFormRepository dynamicFormRepository;
//查询对应卡片采集数据的数量
public Long findDynamicFormToCount(String id){
return dynamicFormRepository.countAllByDynamicDataId(id);
}
//采集数据
public void doCollectData(DynamicForm dynamicForm){
dynamicFormRepository.save(dynamicForm);
}
//根据卡片id查询对应采集数据的列表
public ArrayList<Object> doCollectDataList(String id){
List<DynamicForm> dynamicForms = dynamicFormRepository.findByDynamicDataId(id);
ArrayList<Object> list = new ArrayList<>();
for (DynamicForm dynamicForm : dynamicForms) {
list.add(dynamicForm.getMap());
}
return list;
}
}

View File

@ -256,3 +256,12 @@ justauth:
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
spring:
data:
mongodb:
uri: mongodb://root:123456@120.46.37.243:27017/admin?authMechanism=SCRAM-SHA-256
# uri: mongodb://root:123456@101.43.112.107:27017/admin?authMechanism=SCRAM-SHA-256
database: zy-crm