接口的开发:
查看全部患者对APP的满意及建议
-
其中设计到单张表(idea_satis表)
-
后台管理,直接显示出所有满意建议列表
-
Controller
-
/**
* 查询所有的满意度和建议
* @return
*/
@GetMapping()
private AjaxResult selectIdeaSatisfaction(){
List<IdeaSta> ideaStas = iTbIdeaService.selectIdeaSatisfaction();
int size = ideaStas.size();
List list1 = new ArrayList();
if (size!=0){
return AjaxResult.success("操作成功",ideaStas,size);
}else{
return AjaxResult.success("无此数据",list1,size);
}
}
-
-
ITbIdeaService
-
/**
* 查询所有的满意度和建议
* @return
*/
public List<IdeaSta> selectIdeaSatisfaction();
-
-
TbIdeaServiceImpl
-
/**
* 查询所有的满意度和建议
* @return
*/
@Override
public List<IdeaSta> selectIdeaSatisfaction() {
List<IdeaSatis> list = ideaSatisService.list(null);
List list1 = new ArrayList();
for (IdeaSatis ideaSatis : list) {
String idea = ideaSatis.getIdea();
String satisfaction = ideaSatis.getSatisfaction();
String ideaSatisfactionId = ideaSatis.getIdeaSatisfactionId();
IdeaSatis ideaSatis1 = new IdeaSatis();
ideaSatis1.setIdea(idea);
ideaSatis1.setSatisfaction(satisfaction);
ideaSatis1.setIdeaSatisfactionId(ideaSatisfactionId);
list1.add(ideaSatis1);
}
return list1;
}
-
模糊查询
-
其中设计到单张表(idea_satis表)
-
我在后台管理的中有一个功能是查询功能,这里就涉及到这个模糊的查询,填写的参数有一个
-
Controller
-
/**
* 模糊查询
* @return
*/
@GetMapping("/likeSelect")
private AjaxResult likeSelect(String satisfaction){
LambdaQueryWrapper<IdeaSatis> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.like(StringUtils.isNotBlank(satisfaction),IdeaSatis::getSatisfaction,satisfaction);
List<IdeaSatis> list = ideaSatisService.list(lambdaQueryWrapper);
List list1 = new ArrayList();
int size = list.size();
if (size!=0){
return AjaxResult.success("操作成功",list,size);
}else{
return AjaxResult.success("无此数据",list1,size);
}
}
-
删除满意建议
-
其中设计到单张表(idea_satis表)
-
后台管理的中有一个满意建议资料进行删除
-
Controller
-
/**
* 删除建议的后台管理
* @param ideaSatisfactionId
* @return
*/
@DeleteMapping()
private AjaxResult deleteIdea(Long ideaSatisfactionId){
LambdaQueryWrapper<IdeaSatis> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(IdeaSatis::getIdeaSatisfactionId,ideaSatisfactionId);
boolean remove = ideaSatisService.remove(lambdaQueryWrapper);
return AjaxResult.success(remove);
}
-
学习重点及理解
查询所有建议及满意度列表
-
satis.js
-
// 查询满意建议列表
export function listSatis(query) {
return request({
url: '/system/idea',
method: 'get',
params: query
})
}
-
-
satis.vue
-
/** 查询【请填写功能名称】列表 */
getList() {
this.loading = true;
listSatis(this.queryParams).then(response => {
this.satisList = response.data.slice((this.queryParams.pageNum-1)*this.queryParams.pageSize,(this.queryParams.pageNum-1)*this.queryParams.pageSize+this.queryParams.pageSize);
//累加满意度(-0是为转换为数值类型)
this.value=0;
for(let i in this.satisList){
this.value=this.value+(this.satisList[i].satisfaction-0)
}
this.total = response.total;
//满意度的平均值
this.value=this.value / this.total;
this.loading = false;
});
},
-
模糊查询
-
satis.js
-
// 查询满意建议详细
export function getSatis(params) {
return request({
url: '/system/idea/likeSelect',
method: 'get',
params
})
}
-
-
satis.vue
-
likeList(satisfaction){
this.loading = true;
getSatis({satisfaction: satisfaction}).then(response => {
this.satisList = response.data.slice((this.queryParams.pageNum-1)*this.queryParams.pageSize,(this.queryParams.pageNum-1)*this.queryParams.pageSize+this.queryParams.pageSize);
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.likeList(this.queryParams.satisfaction)
},
-
删除建议及满意度
-
satis.js
-
// 删除满意度
export function delSatis(params) {
return request({
url: '/system/idea',
method: 'delete',
params
})
}
-
-
satis.vue
-
/** 删除按钮操作 */
handleDelete(row) {
const ideaSatisfactionId = row.ideaSatisfactionId || this.ids;
this.$modal.confirm('是否确认删除编号为"' + ideaSatisfactionId + '"的数据项?').then(function() {
return delSatis({ideaSatisfactionId: ideaSatisfactionId});
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
-
扩展学习
星星评分
在查询所有列表中进行操作
将其中的满意度都读取累加起来,然后就是处于总数,出现平均的数值,返回给value
-
satis.vue
-
<!--满意度的星星 -->
<el-rate
v-model="value"
disabled
show-score
text-color="#ff9900"
score-template="{value}">
</el-rate>
export default {
name: "Satis",
data() {
return {
//满意度
value: 0,
},
// 表单参数
form: {},
// 表单校验
rules: {
},
};
},
methods: {
/** 查询【请填写功能名称】列表 */
getList() {
this.loading = true;
listSatis(this.queryParams).then(response => {
this.satisList = response.data.slice((this.queryParams.pageNum-1)*this.queryParams.pageSize,(this.queryParams.pageNum-1)*this.queryParams.pageSize+this.queryParams.pageSize);
//累加满意度(-0是为转换为数值类型)
this.value=0;
for(let i in this.satisList){
this.value=this.value+(this.satisList[i].satisfaction-0)
}
this.total = response.total;
//满意度的平均值
this.value=this.value / this.total;
this.loading = false;
});
},
}
-
总结
今天的学习状态是不错的,将建议反馈的后台管理及其接口的开发完成了,调用的接口不是很多,但是我新增了一个组件了就是反馈这种评分的星星来,直观看评分。
标签:satis,return,反馈,value,satisfaction,开发,接口,queryParams,size From: https://www.cnblogs.com/ikunba/p/17329893.html