Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -78,53 +78,4 @@ public class AdminAddressController {
|
||||
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallAddress address){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
String mobile = address.getMobile();
|
||||
if(!RegexUtil.isMobileExact(mobile)){
|
||||
return ResponseUtil.fail(403, "手机号格式不正确");
|
||||
}
|
||||
|
||||
address.setAddTime(LocalDateTime.now());
|
||||
addressService.add(address);
|
||||
|
||||
Map<String, Object> addressVo = toVo(address);
|
||||
return ResponseUtil.ok(addressVo);
|
||||
}
|
||||
|
||||
@GetMapping("/read")
|
||||
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
LitemallAddress address = addressService.findById(id);
|
||||
Map<String, Object> addressVo = toVo(address);
|
||||
return ResponseUtil.ok(addressVo);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallAddress address){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
addressService.updateById(address);
|
||||
Map<String, Object> addressVo = toVo(address);
|
||||
return ResponseUtil.ok(addressVo);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallAddress address){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
addressService.delete(address.getId());
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,53 +50,4 @@ public class AdminFeedbackController {
|
||||
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallFeedback feedback) {
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
String mobile = feedback.getMobile();
|
||||
if(!RegexUtil.isMobileExact(mobile)){
|
||||
return ResponseUtil.fail(403, "手机号格式不正确");
|
||||
}
|
||||
|
||||
feedback.setAddTime(LocalDateTime.now());
|
||||
feedbackService.add(feedback);
|
||||
|
||||
return ResponseUtil.ok(feedback);
|
||||
}
|
||||
|
||||
@GetMapping("/read")
|
||||
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
if(id == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallFeedback feedback = feedbackService.findById(id);
|
||||
return ResponseUtil.ok(feedback);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallFeedback feedback) {
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
feedbackService.updateById(feedback);
|
||||
return ResponseUtil.ok(feedback);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallFeedback feedback){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
feedbackService.delete(feedback.getId());
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,41 +45,4 @@ public class AdminFootprintController {
|
||||
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallFootprint footprint){
|
||||
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();
|
||||
}
|
||||
|
||||
LitemallFootprint footprint = footprintService.findById(id);
|
||||
return ResponseUtil.ok(footprint);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallFootprint footprint){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
footprintService.updateById(footprint);
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallFootprint footprint){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
footprintService.deleteById(footprint.getId());
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,45 +42,4 @@ public class AdminHistoryController {
|
||||
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallSearchHistory history){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
return ResponseUtil.unsupport();
|
||||
}
|
||||
|
||||
@GetMapping("/read")
|
||||
public Object read(@LoginAdmin Integer adminId, Integer id){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
if(id == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallSearchHistory history = searchHistoryService.findById(id);
|
||||
return ResponseUtil.ok(history);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallSearchHistory history){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
searchHistoryService.updateById(history);
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallSearchHistory history){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
searchHistoryService.deleteById(history.getId());
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class AdminOrderController {
|
||||
try {
|
||||
// 设置订单取消状态
|
||||
order.setOrderStatus(OrderUtil.STATUS_REFUND_CONFIRM);
|
||||
orderService.update(order);
|
||||
orderService.updateById(order);
|
||||
|
||||
// 商品货品数量增加
|
||||
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
|
||||
@@ -204,7 +204,7 @@ public class AdminOrderController {
|
||||
order.setShipSn(shipSn);
|
||||
order.setShipChannel(shipChannel);
|
||||
order.setShipTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
orderService.updateById(order);
|
||||
|
||||
//TODO 发送邮件和短信通知,这里采用异步发送
|
||||
// 发货会发送通知短信给用户
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listAddress(query) {
|
||||
return request({
|
||||
url: '/address/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createAddress(data) {
|
||||
return request({
|
||||
url: '/address/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function readAddress(data) {
|
||||
return request({
|
||||
url: '/address/read',
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateAddress(data) {
|
||||
return request({
|
||||
url: '/address/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteAddress(data) {
|
||||
return request({
|
||||
url: '/address/delete',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listCollect(query) {
|
||||
return request({
|
||||
url: '/collect/list',
|
||||
method: 'get',
|
||||
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
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listFeedback(query) {
|
||||
return request({
|
||||
url: '/feedback/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createFeedback(data) {
|
||||
return request({
|
||||
url: '/feedback/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function readFeedback(data) {
|
||||
return request({
|
||||
url: '/feedback/read',
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateFeedback(data) {
|
||||
return request({
|
||||
url: '/feedback/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteFeedback(data) {
|
||||
return request({
|
||||
url: '/feedback/delete',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listFootprint(query) {
|
||||
return request({
|
||||
url: '/footprint/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createFootprint(data) {
|
||||
return request({
|
||||
url: '/footprint/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function readFootprint(data) {
|
||||
return request({
|
||||
url: '/footprint/read',
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateFootprint(data) {
|
||||
return request({
|
||||
url: '/footprint/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteFootprint(data) {
|
||||
return request({
|
||||
url: '/footprint/delete',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listHistory(query) {
|
||||
return request({
|
||||
url: '/history/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createHistory(data) {
|
||||
return request({
|
||||
url: '/history/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function readHistory(data) {
|
||||
return request({
|
||||
url: '/history/read',
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateHistory(data) {
|
||||
return request({
|
||||
url: '/history/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteHistory(data) {
|
||||
return request({
|
||||
url: '/history/delete',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -31,3 +31,44 @@ export function updateUser(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function listAddress(query) {
|
||||
return request({
|
||||
url: '/address/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function listCollect(query) {
|
||||
return request({
|
||||
url: '/collect/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function listFeedback(query) {
|
||||
return request({
|
||||
url: '/feedback/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function listFootprint(query) {
|
||||
return request({
|
||||
url: '/footprint/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function listHistory(query) {
|
||||
return request({
|
||||
url: '/history/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入收货人名称" v-model="listQuery.name">
|
||||
</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>
|
||||
|
||||
@@ -38,12 +37,6 @@
|
||||
</template>
|
||||
</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>
|
||||
|
||||
<!-- 分页 -->
|
||||
@@ -53,57 +46,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="收货人名称" prop="name">
|
||||
<el-input v-model="dataForm.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="收获人手机" prop="mobile">
|
||||
<el-input v-model="dataForm.mobile"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="区域地址">
|
||||
<el-select v-model="dataForm.provinceId" placeholder="省" @change="provinceChange">
|
||||
<el-option v-for="item in provinces" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-select v-model="dataForm.cityId" placeholder="市" @change="cityChange">
|
||||
<el-option v-for="item in cities" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-select v-model="dataForm.areaId" placeholder="区" @change="areaChange">
|
||||
<el-option v-for="item in areas" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="详细地址" prop="address">
|
||||
<el-input v-model="dataForm.address"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否默认地址" prop="isDefault">
|
||||
<el-select v-model="dataForm.isDefault" placeholder="请选择">
|
||||
<el-option label="否" :value="false">
|
||||
</el-option>
|
||||
<el-option label="是" :value="true">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</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 { listAddress, createAddress, updateAddress, deleteAddress } from '@/api/address'
|
||||
import { listSubRegion } from '@/api/region'
|
||||
import { listAddress } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'UserAddress',
|
||||
@@ -120,41 +67,11 @@ export default {
|
||||
sort: 'add_time',
|
||||
order: 'desc'
|
||||
},
|
||||
provinces: {},
|
||||
cities: {},
|
||||
areas: {},
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
name: undefined,
|
||||
mobile: undefined,
|
||||
address: undefined,
|
||||
isDefault: undefined,
|
||||
provinceId: undefined,
|
||||
cityId: undefined,
|
||||
areaId: undefined
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '创建'
|
||||
},
|
||||
rules: {
|
||||
userId: [{ required: true, message: '用户ID不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '收货人名称不能为空', trigger: 'blur' }],
|
||||
mobile: [{ required: true, message: '收货人手机号码不能为空', trigger: 'blur' }],
|
||||
provinceId: [{ required: true, message: '收货人所在省不能为空', trigger: 'blur' }],
|
||||
cityId: [{ required: true, message: '收货人所在市不能为空', trigger: 'blur' }],
|
||||
areaId: [{ required: true, message: '收货人所在区不能为空', trigger: 'blur' }],
|
||||
address: [{ required: true, message: '收货人地址不能为空', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getProvinces()
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
@@ -168,36 +85,6 @@ export default {
|
||||
this.total = 0
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
getProvinces() {
|
||||
listSubRegion({ id: 0 }).then(response => {
|
||||
this.provinces = response.data.data
|
||||
})
|
||||
},
|
||||
provinceChange(val) {
|
||||
if (val === undefined) {
|
||||
return
|
||||
}
|
||||
this.cities = {}
|
||||
this.dataForm.cityId = undefined
|
||||
this.areas = {}
|
||||
this.dataForm.areaId = undefined
|
||||
listSubRegion({ id: val }).then(response => {
|
||||
this.cities = response.data.data
|
||||
})
|
||||
},
|
||||
cityChange(val) {
|
||||
if (val === undefined) {
|
||||
return
|
||||
}
|
||||
this.areas = {}
|
||||
this.dataForm.areaId = undefined
|
||||
listSubRegion({ id: val }).then(response => {
|
||||
this.areas = response.data.data
|
||||
})
|
||||
},
|
||||
areaChange(val) {
|
||||
|
||||
},
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1
|
||||
@@ -211,96 +98,6 @@ export default {
|
||||
this.listQuery.page = val
|
||||
this.getList()
|
||||
},
|
||||
resetForm() {
|
||||
this.dataForm = {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
name: undefined,
|
||||
mobile: undefined,
|
||||
address: undefined,
|
||||
isDefault: undefined,
|
||||
provinceId: undefined,
|
||||
cityId: undefined,
|
||||
areaId: undefined
|
||||
}
|
||||
},
|
||||
handleCreate() {
|
||||
this.resetForm()
|
||||
this.cities = {}
|
||||
this.areas = {}
|
||||
this.dialogStatus = 'create'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
createData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
createAddress(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.cities = {}
|
||||
this.areas = {}
|
||||
listSubRegion({ id: this.dataForm.provinceId }).then(response => {
|
||||
this.cities = response.data.data
|
||||
})
|
||||
listSubRegion({ id: this.dataForm.cityId }).then(response => {
|
||||
this.areas = response.data.data
|
||||
})
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
updateData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
updateAddress(this.dataForm).then(response => {
|
||||
const updatedAddress = response.data.data
|
||||
for (const v of this.list) {
|
||||
if (v.id === updatedAddress.id) {
|
||||
const index = this.list.indexOf(v)
|
||||
this.list.splice(index, 1, updatedAddress)
|
||||
break
|
||||
}
|
||||
}
|
||||
this.dialogFormVisible = false
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '更新成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(row) {
|
||||
deleteAddress(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 => {
|
||||
|
||||
@@ -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/user'
|
||||
|
||||
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 => {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入反馈ID" v-model="listQuery.id">
|
||||
</el-input>
|
||||
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
|
||||
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">添加</el-button>
|
||||
<el-button class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload" :loading="downloadLoading">导出</el-button>
|
||||
</div>
|
||||
|
||||
@@ -39,12 +38,6 @@
|
||||
<el-table-column align="center" label="时间" prop="addTime">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作" width="200" 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>
|
||||
|
||||
<!-- 分页 -->
|
||||
@@ -54,78 +47,14 @@
|
||||
</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="id">
|
||||
<el-input v-model="dataForm.id"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="dataForm.username"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="手机号码" prop="mobile">
|
||||
<el-input v-model="dataForm.mobile" type="textarea" :rows="1"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="反馈类型" prop="feedType">
|
||||
<el-input v-model="dataForm.feedType" type="textarea" :rows="4"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="反馈内容" prop="content">
|
||||
<el-input v-model="dataForm.content" type="textarea" :rows="4"></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-item label="反馈图片" prop="picUrls">
|
||||
<!-- <el-input v-model="dataForm.picUrls"></el-input> -->
|
||||
<el-upload action="#" list-type="picture" :headers="headers" :show-file-list="false" :limit="5" :http-request="uploadPicUrls">
|
||||
<el-button size="small" type="primary">点击上传</el-button>
|
||||
</el-upload>
|
||||
</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>
|
||||
|
||||
<style>
|
||||
.demo-table-expand {
|
||||
font-size: 0;
|
||||
}
|
||||
.demo-table-expand label {
|
||||
width: 200px;
|
||||
color: #99a9bf;
|
||||
}
|
||||
.demo-table-expand .el-form-item {
|
||||
margin-right: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { listFeedback, createFeedback, updateFeedback, deleteFeedback } from '@/api/Feedback'
|
||||
import { createStorage } from '@/api/storage'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { listFeedback } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'Feedback',
|
||||
computed: {
|
||||
headers() {
|
||||
return {
|
||||
'Admin-Token': getToken()
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: undefined,
|
||||
@@ -138,26 +67,6 @@ export default {
|
||||
sort: 'add_time',
|
||||
order: 'desc'
|
||||
},
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
username: undefined,
|
||||
mobile: undefined,
|
||||
feedType: undefined,
|
||||
content: undefined,
|
||||
hasPicture: false,
|
||||
picUrls: []
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '创建'
|
||||
},
|
||||
rules: {
|
||||
username: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
||||
// valueId: [{ required: true, message: '反馈ID不能为空', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '反馈内容不能为空', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false
|
||||
}
|
||||
},
|
||||
@@ -189,92 +98,6 @@ export default {
|
||||
this.listQuery.page = val
|
||||
this.getList()
|
||||
},
|
||||
resetForm() {
|
||||
this.dataForm = {
|
||||
id: undefined,
|
||||
username: undefined,
|
||||
mobile: undefined,
|
||||
feedType: undefined,
|
||||
content: undefined,
|
||||
picUrls: []
|
||||
}
|
||||
},
|
||||
handleCreate() {
|
||||
this.resetForm()
|
||||
this.dialogStatus = 'create'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
uploadPicUrls(item) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', item.file)
|
||||
createStorage(formData).then(res => {
|
||||
this.dataForm.picUrls.push(res.data.data.url)
|
||||
this.dataForm.hasPicture = true
|
||||
}).catch(() => {
|
||||
this.$message.error('上传失败,请重新上传')
|
||||
})
|
||||
},
|
||||
createData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
createFeedback(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) {
|
||||
updateFeedback(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) {
|
||||
deleteFeedback(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 => {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入商品ID" v-model="listQuery.goodsId">
|
||||
</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="goodsId">
|
||||
<el-input v-model="dataForm.goodsId"></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 { listFootprint, createFootprint, updateFootprint, deleteFootprint } from '@/api/footprint'
|
||||
import { listFootprint } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'FootPrint',
|
||||
@@ -83,22 +55,6 @@ export default {
|
||||
sort: 'add_time',
|
||||
order: 'desc'
|
||||
},
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
userId: '',
|
||||
goodsId: '',
|
||||
addTime: undefined
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '创建'
|
||||
},
|
||||
rules: {
|
||||
userId: [{ required: true, message: '用户ID不能为空', trigger: 'blur' }],
|
||||
goodsId: [{ required: true, message: '商品ID不能为空', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false
|
||||
}
|
||||
},
|
||||
@@ -130,80 +86,6 @@ export default {
|
||||
this.listQuery.page = val
|
||||
this.getList()
|
||||
},
|
||||
resetForm() {
|
||||
this.dataForm = {
|
||||
id: undefined,
|
||||
userId: '',
|
||||
goodsId: '',
|
||||
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) {
|
||||
createFootprint(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) {
|
||||
updateFootprint(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) {
|
||||
deleteFootprint(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 => {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入搜索历史关键字" v-model="listQuery.keyword">
|
||||
</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>
|
||||
|
||||
@@ -40,32 +39,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="关键字" prop="keyword">
|
||||
<el-input v-model="dataForm.keyword"></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 { listHistory, createHistory, updateHistory, deleteHistory } from '@/api/history'
|
||||
import { listHistory } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'History',
|
||||
@@ -82,26 +60,6 @@ export default {
|
||||
sort: 'add_time',
|
||||
order: 'desc'
|
||||
},
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
userId: '',
|
||||
keyword: '',
|
||||
addTime: undefined
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '创建'
|
||||
},
|
||||
rules: {
|
||||
userId: [
|
||||
{ required: true, message: '用户ID不能为空', trigger: 'blur' }
|
||||
],
|
||||
keyword: [
|
||||
{ required: true, message: '搜索关键字不能为空', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
downloadLoading: false
|
||||
}
|
||||
},
|
||||
@@ -133,80 +91,6 @@ export default {
|
||||
this.listQuery.page = val
|
||||
this.getList()
|
||||
},
|
||||
resetForm() {
|
||||
this.dataForm = {
|
||||
id: undefined,
|
||||
userId: '',
|
||||
goodsId: '',
|
||||
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) {
|
||||
createHistory(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) {
|
||||
updateHistory(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) {
|
||||
deleteHistory(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 => {
|
||||
|
||||
@@ -56,8 +56,8 @@ public class LitemallAdService {
|
||||
return (int) adMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallAd ad) {
|
||||
adMapper.updateByPrimaryKeySelective(ad);
|
||||
public int updateById(LitemallAd ad) {
|
||||
return adMapper.updateWithVersionByPrimaryKeySelective(ad.getVersion(), ad);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class LitemallAddressService {
|
||||
}
|
||||
|
||||
public int update(LitemallAddress address) {
|
||||
return addressMapper.updateByPrimaryKeySelective(address);
|
||||
return addressMapper.updateWithVersionByPrimaryKeySelective(address.getVersion(), address);
|
||||
}
|
||||
|
||||
public void delete(Integer id) {
|
||||
@@ -85,8 +85,4 @@ public class LitemallAddressService {
|
||||
|
||||
return (int)addressMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallAddress address) {
|
||||
addressMapper.updateByPrimaryKeySelective(address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public class LitemallAdminService {
|
||||
return (int)adminMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallAdmin admin) {
|
||||
adminMapper.updateByPrimaryKeySelective(admin);
|
||||
public int updateById(LitemallAdmin admin) {
|
||||
return adminMapper.updateWithVersionByPrimaryKeySelective(admin.getVersion(), admin);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -76,8 +76,8 @@ public class LitemallBrandService {
|
||||
return (int) brandMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallBrand brand) {
|
||||
brandMapper.updateByPrimaryKeySelective(brand);
|
||||
public int updateById(LitemallBrand brand) {
|
||||
return brandMapper.updateWithVersionByPrimaryKeySelective(brand.getVersion(), brand);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -25,8 +25,8 @@ public class LitemallCartService {
|
||||
cartMapper.insertSelective(cart);
|
||||
}
|
||||
|
||||
public void update(LitemallCart cart) {
|
||||
cartMapper.updateByPrimaryKey(cart);
|
||||
public int update(LitemallCart cart) {
|
||||
return cartMapper.updateWithVersionByPrimaryKeySelective(cart.getVersion(), cart);
|
||||
}
|
||||
|
||||
public List<LitemallCart> queryByUid(int userId) {
|
||||
@@ -42,12 +42,6 @@ public class LitemallCartService {
|
||||
return cartMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<LitemallCart> queryByUidAndSid(int userId, String sessionId) {
|
||||
LitemallCartExample example = new LitemallCartExample();
|
||||
example.or().andUserIdEqualTo(userId).andDeletedEqualTo(false);
|
||||
return cartMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public int delete(List<Integer> productIdList, int userId) {
|
||||
LitemallCartExample example = new LitemallCartExample();
|
||||
example.or().andUserIdEqualTo(userId).andProductIdIn(productIdList);
|
||||
|
||||
@@ -86,8 +86,8 @@ public class LitemallCategoryService {
|
||||
return (int)categoryMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallCategory category) {
|
||||
categoryMapper.updateByPrimaryKeySelective(category);
|
||||
public int updateById(LitemallCategory category) {
|
||||
return categoryMapper.updateWithVersionByPrimaryKeySelective(category.getVersion(), category);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LitemallCommentService {
|
||||
example.or().andValueIdEqualTo(valueId).andTypeEqualTo(type).andHasPictureEqualTo(true).andDeletedEqualTo(false);
|
||||
}
|
||||
else{
|
||||
Assert.state(false, "showType不支持");
|
||||
throw new RuntimeException("showType不支持");
|
||||
}
|
||||
PageHelper.startPage(offset, limit);
|
||||
return commentMapper.selectByExample(example);
|
||||
@@ -55,21 +55,15 @@ public class LitemallCommentService {
|
||||
example.or().andValueIdEqualTo(valueId).andTypeEqualTo(type).andHasPictureEqualTo(true).andDeletedEqualTo(false);
|
||||
}
|
||||
else{
|
||||
Assert.state(false, "");
|
||||
throw new RuntimeException("showType不支持");
|
||||
}
|
||||
return (int)commentMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public Integer save(LitemallComment comment) {
|
||||
public int save(LitemallComment comment) {
|
||||
return commentMapper.insertSelective(comment);
|
||||
}
|
||||
|
||||
|
||||
public void update(LitemallComment comment) {
|
||||
commentMapper.updateByPrimaryKeySelective(comment);
|
||||
}
|
||||
|
||||
|
||||
public List<LitemallComment> querySelective(String userId, String valueId, Integer page, Integer size, String sort, String order) {
|
||||
LitemallCommentExample example = new LitemallCommentExample();
|
||||
example.setOrderByClause(LitemallComment.Column.addTime.desc());
|
||||
@@ -106,19 +100,8 @@ public class LitemallCommentService {
|
||||
return (int)commentMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallComment comment) {
|
||||
commentMapper.updateByPrimaryKeySelective(comment);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
commentMapper.logicalDeleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void add(LitemallComment comment) {
|
||||
commentMapper.insertSelective(comment);
|
||||
}
|
||||
|
||||
public LitemallComment findById(Integer id) {
|
||||
return commentMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ public class LitemallFeedbackService {
|
||||
@Autowired
|
||||
private LitemallFeedbackMapper feedbackMapper;
|
||||
|
||||
//提交
|
||||
public Integer add(LitemallFeedback feedback) {
|
||||
return feedbackMapper.insertSelective(feedback);
|
||||
}
|
||||
@@ -57,16 +56,4 @@ public class LitemallFeedbackService {
|
||||
criteria.andDeletedEqualTo(false);
|
||||
return (int)feedbackMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public LitemallFeedback findById(Integer id) {
|
||||
return feedbackMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void updateById(LitemallFeedback feedback) {
|
||||
feedbackMapper.updateByPrimaryKeySelective(feedback);
|
||||
}
|
||||
|
||||
public void delete(Integer id) {
|
||||
feedbackMapper.logicalDeleteByPrimaryKey(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,4 @@ public class LitemallFootprintService {
|
||||
|
||||
return (int)footprintMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallFootprint collect) {
|
||||
footprintMapper.updateByPrimaryKeySelective(collect);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,14 +20,6 @@ public class LitemallGoodsAttributeService {
|
||||
return goodsAttributeMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallGoodsAttribute goodsAttribute) {
|
||||
goodsAttributeMapper.updateByPrimaryKeySelective(goodsAttribute);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
goodsAttributeMapper.logicalDeleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void add(LitemallGoodsAttribute goodsAttribute) {
|
||||
goodsAttributeMapper.insertSelective(goodsAttribute);
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@ public class LitemallGoodsService {
|
||||
return (int) goodsMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallGoods goods) {
|
||||
goodsMapper.updateByPrimaryKeySelective(goods);
|
||||
public int updateById(LitemallGoods goods) {
|
||||
return goodsMapper.updateWithVersionByPrimaryKeySelective(goods.getVersion(), goods);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -27,14 +27,6 @@ public class LitemallGoodsSpecificationService {
|
||||
return goodsSpecificationMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void updateById(LitemallGoodsSpecification goodsSpecification) {
|
||||
goodsSpecificationMapper.updateByPrimaryKeySelective(goodsSpecification);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
goodsSpecificationMapper.logicalDeleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void deleteByGid(Integer gid) {
|
||||
LitemallGoodsSpecificationExample example = new LitemallGoodsSpecificationExample();
|
||||
example.or().andGoodsIdEqualTo(gid);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class LitemallGrouponRulesService {
|
||||
mapper.logicalDeleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void update(LitemallGrouponRules grouponRules) {
|
||||
mapper.updateByPrimaryKeySelective(grouponRules);
|
||||
public int update(LitemallGrouponRules grouponRules) {
|
||||
return mapper.updateWithVersionByPrimaryKeySelective(grouponRules.getVersion(), grouponRules);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public class LitemallGrouponService {
|
||||
return (int) mapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void update(LitemallGroupon groupon) {
|
||||
mapper.updateByPrimaryKey(groupon);
|
||||
public int update(LitemallGroupon groupon) {
|
||||
return mapper.updateWithVersionByPrimaryKeySelective(groupon.getVersion(), groupon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,8 +58,8 @@ public class LitemallIssueService {
|
||||
return (int)issueMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallIssue issue) {
|
||||
issueMapper.updateByPrimaryKeySelective(issue);
|
||||
public int updateById(LitemallIssue issue) {
|
||||
return issueMapper.updateWithVersionByPrimaryKeySelective(issue.getVersion(), issue);
|
||||
}
|
||||
|
||||
public LitemallIssue findById(Integer id) {
|
||||
|
||||
@@ -15,12 +15,6 @@ public class LitemallKeywordService {
|
||||
@Resource
|
||||
private LitemallKeywordMapper keywordsMapper;
|
||||
|
||||
public List<LitemallKeyword> queryDefaults() {
|
||||
LitemallKeywordExample example = new LitemallKeywordExample();
|
||||
example.or().andIsDefaultEqualTo(true).andDeletedEqualTo(false);
|
||||
return keywordsMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public LitemallKeyword queryDefault() {
|
||||
LitemallKeywordExample example = new LitemallKeywordExample();
|
||||
example.or().andIsDefaultEqualTo(true).andDeletedEqualTo(false);
|
||||
@@ -85,8 +79,8 @@ public class LitemallKeywordService {
|
||||
return keywordsMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void updateById(LitemallKeyword keywords) {
|
||||
keywordsMapper.updateByPrimaryKeySelective(keywords);
|
||||
public int updateById(LitemallKeyword keywords) {
|
||||
return keywordsMapper.updateWithVersionByPrimaryKeySelective(keywords.getVersion(), keywords);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -24,8 +24,8 @@ public class LitemallProductService {
|
||||
return productMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void updateById(LitemallProduct product) {
|
||||
productMapper.updateByPrimaryKeySelective(product);
|
||||
public int updateById(LitemallProduct product) {
|
||||
return productMapper.updateWithVersionByPrimaryKeySelective(product.getVersion(), product);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -32,19 +32,6 @@ public class LitemallSearchHistoryService {
|
||||
searchHistoryMapper.logicalDeleteByExample(example);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
LitemallSearchHistory searchHistory = searchHistoryMapper.selectByPrimaryKey(id);
|
||||
if(searchHistory == null){
|
||||
return;
|
||||
}
|
||||
searchHistory.setDeleted(true);
|
||||
searchHistoryMapper.logicalDeleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void add(LitemallSearchHistory searchHistory) {
|
||||
searchHistoryMapper.insertSelective(searchHistory);
|
||||
}
|
||||
|
||||
public List<LitemallSearchHistory> querySelective(String userId, String keyword, Integer page, Integer size, String sort, String order) {
|
||||
LitemallSearchHistoryExample example = new LitemallSearchHistoryExample();
|
||||
LitemallSearchHistoryExample.Criteria criteria = example.createCriteria();
|
||||
@@ -79,12 +66,4 @@ public class LitemallSearchHistoryService {
|
||||
|
||||
return (int)searchHistoryMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallSearchHistory collect) {
|
||||
searchHistoryMapper.updateByPrimaryKeySelective(collect);
|
||||
}
|
||||
|
||||
public LitemallSearchHistory findById(Integer id) {
|
||||
return searchHistoryMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,23 +25,16 @@ public class LitemallStorageService {
|
||||
storageMapper.insertSelective(storageInfo);
|
||||
}
|
||||
|
||||
public LitemallStorage findByName(String filename) {
|
||||
LitemallStorageExample example = new LitemallStorageExample();
|
||||
example.or().andNameEqualTo(filename).andDeletedEqualTo(false);
|
||||
return storageMapper.selectOneByExample(example);
|
||||
}
|
||||
|
||||
public LitemallStorage findByKey(String key) {
|
||||
LitemallStorageExample example = new LitemallStorageExample();
|
||||
example.or().andKeyEqualTo(key).andDeletedEqualTo(false);
|
||||
return storageMapper.selectOneByExample(example);
|
||||
}
|
||||
|
||||
public void update(LitemallStorage storageInfo) {
|
||||
storageMapper.updateByPrimaryKeySelective(storageInfo);
|
||||
public int update(LitemallStorage storageInfo) {
|
||||
return storageMapper.updateWithVersionByPrimaryKeySelective(storageInfo.getVersion(), storageInfo);
|
||||
}
|
||||
|
||||
|
||||
public LitemallStorage findById(Integer id) {
|
||||
return storageMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@@ -13,23 +13,9 @@ public class LitemallSystemConfigService {
|
||||
@Resource
|
||||
private LitemallSystemMapper systemMapper;
|
||||
|
||||
public void add(LitemallSystem litemallSystem) {
|
||||
systemMapper.insert(litemallSystem);
|
||||
}
|
||||
|
||||
public List<LitemallSystem> queryAll() {
|
||||
LitemallSystemExample example = new LitemallSystemExample();
|
||||
example.or();
|
||||
return systemMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public LitemallSystem queryByKeyName(String keyName, String groupName) {
|
||||
LitemallSystemExample example = new LitemallSystemExample();
|
||||
example.or().andKeyNameEqualTo(keyName);
|
||||
return systemMapper.selectOneByExample(example);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
systemMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,10 +91,10 @@ public class LitemallTopicService {
|
||||
return (int) topicMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void updateById(LitemallTopic topic) {
|
||||
public int updateById(LitemallTopic topic) {
|
||||
LitemallTopicExample example = new LitemallTopicExample();
|
||||
example.or().andIdEqualTo(topic.getId());
|
||||
topicMapper.updateByExampleWithBLOBs(topic, example);
|
||||
return topicMapper.updateWithVersionByExampleWithBLOBs(topic.getVersion(), topic, example);
|
||||
}
|
||||
|
||||
public void deleteById(Integer id) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class LitemallUserFormIdService {
|
||||
//更新或者删除缓存
|
||||
if (userFormid.getIsprepay() && userFormid.getUseamount() > 1) {
|
||||
userFormid.setUseamount(userFormid.getUseamount() - 1);
|
||||
formidMapper.updateByPrimaryKey(userFormid);
|
||||
formidMapper.updateWithVersionByPrimaryKey(userFormid.getVersion(), userFormid);
|
||||
} else {
|
||||
formidMapper.deleteByPrimaryKey(userFormid.getId());
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ public class LitemallUserService {
|
||||
userMapper.insertSelective(user);
|
||||
}
|
||||
|
||||
public void update(LitemallUser user) {
|
||||
userMapper.updateByPrimaryKeySelective(user);
|
||||
public int update(LitemallUser user) {
|
||||
return userMapper.updateWithVersionByPrimaryKeySelective(user.getVersion(), user);
|
||||
}
|
||||
|
||||
public List<LitemallUser> querySelective(String username, String mobile, Integer page, Integer size, String sort, String order) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.linlinjava.litemall.db;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.linlinjava.litemall.db.dao.LitemallSystemMapper;
|
||||
import org.linlinjava.litemall.db.domain.LitemallSystem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@WebAppConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest
|
||||
public class MapperReturnTest {
|
||||
|
||||
@Autowired
|
||||
private LitemallSystemMapper systemMapper;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
LitemallSystem system = new LitemallSystem();
|
||||
system.setKeyName("test-system-key");
|
||||
system.setKeyValue("test-system-value");
|
||||
int updates = systemMapper.insertSelective(system);
|
||||
Assert.assertEquals(updates, 1);
|
||||
|
||||
updates = systemMapper.deleteByPrimaryKey(system.getId());
|
||||
Assert.assertEquals(updates, 1);
|
||||
|
||||
updates = systemMapper.updateByPrimaryKey(system);
|
||||
Assert.assertEquals(updates, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.linlinjava.litemall.db;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.linlinjava.litemall.db.dao.LitemallSystemMapper;
|
||||
import org.linlinjava.litemall.db.domain.LitemallSystem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
/*
|
||||
main线程先select,然后睡眠1s,最后做update
|
||||
another线程则是先select,然后做update
|
||||
|
||||
main: select update 2
|
||||
another: select update 3
|
||||
|
||||
如果没有乐观锁,那么最后main线程的update操作是成功的,最终数据库保存的值是2;
|
||||
如果设置乐观锁,那么最后main线程的update操作是失败的,最终数据库保存的值是3。
|
||||
|
||||
在一些业务过程中,需要采用乐观锁,这样可以保证数据更新时不会出现问题。
|
||||
*/
|
||||
@WebAppConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest
|
||||
public class OptimisticLockTest {
|
||||
|
||||
@Autowired
|
||||
private LitemallSystemMapper systemMapper;
|
||||
|
||||
private Integer unlockId;
|
||||
private Integer lockId;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
LitemallSystem unlockSystemConfig = new LitemallSystem();
|
||||
unlockSystemConfig.setKeyName("test-unlocksystem-key");
|
||||
unlockSystemConfig.setKeyValue("test-unlocksystem-value-1");
|
||||
systemMapper.insertSelective(unlockSystemConfig);
|
||||
unlockId = unlockSystemConfig.getId();
|
||||
|
||||
LitemallSystem lockSystemConfig = new LitemallSystem();
|
||||
lockSystemConfig.setKeyName("test-locksystem-key");
|
||||
lockSystemConfig.setKeyValue("test-locksystem-value-1");
|
||||
systemMapper.insertSelective(lockSystemConfig);
|
||||
lockId = lockSystemConfig.getId();
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
systemMapper.deleteByPrimaryKey(unlockId);
|
||||
unlockId = null;
|
||||
systemMapper.deleteByPrimaryKey(lockId);
|
||||
lockId = null;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void runWithOptimisticLock() {
|
||||
LitemallSystem mainSystem = systemMapper.selectByPrimaryKey(lockId);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LitemallSystem anotherSystem = systemMapper.selectByPrimaryKey(lockId);
|
||||
|
||||
anotherSystem.setKeyValue("test-locksystem-value-3");
|
||||
systemMapper.updateWithVersionByPrimaryKey(anotherSystem.getVersion(), anotherSystem);
|
||||
}
|
||||
}).start();
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mainSystem.setKeyValue("test-locksystem-value-2");
|
||||
int updates = systemMapper.updateWithVersionByPrimaryKey(mainSystem.getVersion(), mainSystem);
|
||||
Assert.assertEquals(updates, 0);
|
||||
|
||||
mainSystem = systemMapper.selectByPrimaryKey(lockId);
|
||||
Assert.assertNotEquals(mainSystem.getKeyValue(), "test-locksystem-value-2");
|
||||
Assert.assertEquals(mainSystem.getKeyValue(), "test-locksystem-value-3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWithoutOptimisticLock() {
|
||||
LitemallSystem mainSystem = systemMapper.selectByPrimaryKey(unlockId);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LitemallSystem anotherSystem = systemMapper.selectByPrimaryKey(unlockId);
|
||||
|
||||
anotherSystem.setKeyValue("test-unlocksystem-value-3");
|
||||
systemMapper.updateByPrimaryKey(anotherSystem);
|
||||
}
|
||||
}).start();
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mainSystem.setKeyValue("test-unlocksystem-value-2");
|
||||
int updates = systemMapper.updateByPrimaryKey(mainSystem);
|
||||
Assert.assertEquals(updates, 1);
|
||||
|
||||
mainSystem = systemMapper.selectByPrimaryKey(unlockId);
|
||||
Assert.assertEquals(mainSystem.getKeyValue(), "test-unlocksystem-value-2");
|
||||
Assert.assertNotEquals(mainSystem.getKeyValue(), "test-unlocksystem-value-3");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ public class WxOrderController {
|
||||
// 设置订单已取消状态
|
||||
order.setOrderStatus(OrderUtil.STATUS_CANCEL);
|
||||
order.setEndTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
orderService.updateById(order);
|
||||
|
||||
// 商品货品数量增加
|
||||
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
|
||||
@@ -733,7 +733,7 @@ public class WxOrderController {
|
||||
|
||||
// 设置订单申请退款状态
|
||||
order.setOrderStatus(OrderUtil.STATUS_REFUND);
|
||||
orderService.update(order);
|
||||
orderService.updateById(order);
|
||||
|
||||
//TODO 发送邮件和短信通知,这里采用异步发送
|
||||
// 有用户申请退款,邮件通知运营人员
|
||||
@@ -778,7 +778,7 @@ public class WxOrderController {
|
||||
|
||||
order.setOrderStatus(OrderUtil.STATUS_CONFIRM);
|
||||
order.setConfirmTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
orderService.updateById(order);
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// 以下是业务服务器API地址
|
||||
// 本机开发时使用
|
||||
var WxApiRoot = 'http://localhost:8082/wx/';
|
||||
var WxApiRoot = 'http://localhost:8080/wx/';
|
||||
// 局域网测试使用
|
||||
// var WxApiRoot = 'http://192.168.0.101:8080/wx/';
|
||||
// 云平台部署时使用
|
||||
// var WxApiRoot = 'http://122.152.206.172:8080/wx/';
|
||||
// 云平台上线时使用
|
||||
//var WxApiRoot = 'https://www.menethil.com.cn/wx/';
|
||||
// var WxApiRoot = 'https://www.menethil.com.cn/wx/';
|
||||
|
||||
module.exports = {
|
||||
IndexUrl: WxApiRoot + 'home/index', //首页数据接口
|
||||
|
||||
Reference in New Issue
Block a user