Commit 8f2ca076 authored by Junling Bu's avatar Junling Bu
Browse files

重构:管理后台不支持管理员对用户的收藏数据进行crud操作

parent a797cb65
......@@ -45,45 +45,4 @@ public class AdminCollectController {
return ResponseUtil.ok(data);
}
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallCollect collect){
if(adminId == null){
return ResponseUtil.unlogin();
}
return ResponseUtil.unsupport();
}
@GetMapping("/read")
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id){
if(adminId == null){
return ResponseUtil.unlogin();
}
if(id == null){
return ResponseUtil.badArgument();
}
LitemallCollect collect = collectService.findById(id);
return ResponseUtil.ok(collect);
}
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallCollect collect){
if(adminId == null){
return ResponseUtil.unlogin();
}
collectService.updateById(collect);
return ResponseUtil.ok();
}
@PostMapping("/delete")
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallCollect collect){
if(adminId == null){
return ResponseUtil.unlogin();
}
collectService.deleteById(collect.getId());
return ResponseUtil.ok();
}
}
......@@ -7,35 +7,3 @@ export function listCollect(query) {
params: query
})
}
export function createCollect(data) {
return request({
url: '/collect/create',
method: 'post',
data
})
}
export function readCollect(data) {
return request({
url: '/collect/read',
method: 'get',
data
})
}
export function updateCollect(data) {
return request({
url: '/collect/update',
method: 'post',
data
})
}
export function deleteCollect(data) {
return request({
url: '/collect/delete',
method: 'post',
data
})
}
......@@ -8,7 +8,6 @@
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入商品ID" v-model="listQuery.valueId">
</el-input>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
<el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
<el-button class="filter-item" type="primary" :loading="downloadLoading" icon="el-icon-download" @click="handleDownload">导出</el-button>
</div>
......@@ -26,12 +25,6 @@
<el-table-column align="center" min-width="100px" label="添加时间" prop="addTime">
</el-table-column>
<el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
......@@ -41,32 +34,11 @@
</el-pagination>
</div>
<!-- 添加或修改对话框 -->
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
<el-form-item label="用户ID" prop="userId">
<el-input v-model="dataForm.userId"></el-input>
</el-form-item>
<el-form-item label="商品ID" prop="valueId">
<el-input v-model="dataForm.valueId"></el-input>
</el-form-item>
<el-form-item label="添加时间" prop="addTime">
<el-date-picker v-model="dataForm.addTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">确定</el-button>
<el-button v-else type="primary" @click="updateData">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCollect, createCollect, updateCollect, deleteCollect } from '@/api/collect'
import { listCollect } from '@/api/collect'
export default {
name: 'Collect',
......@@ -83,22 +55,6 @@ export default {
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,
userId: '',
valueId: '',
addTime: undefined
},
dialogFormVisible: false,
dialogStatus: '',
textMap: {
update: '编辑',
create: '创建'
},
rules: {
userId: [{ required: true, message: '用户ID不能为空', trigger: 'blur' }],
valueId: [{ required: true, message: '商品ID不能为空', trigger: 'blur' }]
},
downloadLoading: false
}
},
......@@ -138,72 +94,6 @@ export default {
addTime: undefined
}
},
handleCreate() {
this.resetForm()
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
createCollect(this.dataForm).then(response => {
this.list.unshift(response.data.data)
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
})
}
})
},
handleUpdate(row) {
this.dataForm = Object.assign({}, row)
this.dialogStatus = 'update'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
updateData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
updateCollect(this.dataForm).then(() => {
for (const v of this.list) {
if (v.id === this.dataForm.id) {
const index = this.list.indexOf(v)
this.list.splice(index, 1, this.dataForm)
break
}
}
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '更新成功',
type: 'success',
duration: 2000
})
})
}
})
},
handleDelete(row) {
deleteCollect(row).then(response => {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
})
const index = this.list.indexOf(row)
this.list.splice(index, 1)
})
},
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
......
......@@ -83,12 +83,4 @@ public class LitemallCollectService {
return (int)collectMapper.countByExample(example);
}
public void updateById(LitemallCollect collect) {
collectMapper.updateByPrimaryKeySelective(collect);
}
public LitemallCollect findById(Integer id) {
return collectMapper.selectByPrimaryKey(id);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment