修改参数

This commit is contained in:
ryoeiken 2020-12-31 14:14:30 +08:00
parent 2eff99e3c0
commit 6cb636ca40
3 changed files with 150 additions and 58 deletions

View File

@ -1,41 +1,38 @@
package com.ruoyi.system.fantang.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.util.List;
import java.util.Arrays;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.fantang.domain.FtConfigDao;
import com.ruoyi.system.fantang.service.IFtConfigDaoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* 饭堂参数Controller
*
*
* @author ft
* @date 2020-12-07
*/
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/fantang/fantangConfig" )
@RequestMapping("/fantang/fantangConfig")
public class FtConfigDaoController extends BaseController {
private final IFtConfigDaoService iFtConfigDaoService;
@ -45,21 +42,20 @@ public class FtConfigDaoController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:list')")
@GetMapping("/list")
public TableDataInfo list(FtConfigDao ftConfigDao)
{
public TableDataInfo list(FtConfigDao ftConfigDao) {
startPage();
LambdaQueryWrapper<FtConfigDao> lqw = Wrappers.lambdaQuery(ftConfigDao);
if (ftConfigDao.getCorpId() != null){
lqw.eq(FtConfigDao::getCorpId ,ftConfigDao.getCorpId());
if (ftConfigDao.getCorpId() != null) {
lqw.eq(FtConfigDao::getCorpId, ftConfigDao.getCorpId());
}
if (StringUtils.isNotBlank(ftConfigDao.getConfigKey())){
lqw.eq(FtConfigDao::getConfigKey ,ftConfigDao.getConfigKey());
if (StringUtils.isNotBlank(ftConfigDao.getConfigKey())) {
lqw.eq(FtConfigDao::getConfigKey, ftConfigDao.getConfigKey());
}
if (StringUtils.isNotBlank(ftConfigDao.getConfigValue())){
lqw.eq(FtConfigDao::getConfigValue ,ftConfigDao.getConfigValue());
if (StringUtils.isNotBlank(ftConfigDao.getConfigValue())) {
lqw.eq(FtConfigDao::getConfigValue, ftConfigDao.getConfigValue());
}
if (ftConfigDao.getFlag() != null){
lqw.eq(FtConfigDao::getFlag ,ftConfigDao.getFlag());
if (ftConfigDao.getFlag() != null) {
lqw.eq(FtConfigDao::getFlag, ftConfigDao.getFlag());
}
List<FtConfigDao> list = iFtConfigDaoService.list(lqw);
return getDataTable(list);
@ -68,30 +64,30 @@ public class FtConfigDaoController extends BaseController {
/**
* 导出饭堂参数列表
*/
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:export')" )
@Log(title = "饭堂参数" , businessType = BusinessType.EXPORT)
@GetMapping("/export" )
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:export')")
@Log(title = "饭堂参数", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(FtConfigDao ftConfigDao) {
LambdaQueryWrapper<FtConfigDao> lqw = new LambdaQueryWrapper<FtConfigDao>(ftConfigDao);
List<FtConfigDao> list = iFtConfigDaoService.list(lqw);
ExcelUtil<FtConfigDao> util = new ExcelUtil<FtConfigDao>(FtConfigDao. class);
return util.exportExcel(list, "fantangConfig" );
ExcelUtil<FtConfigDao> util = new ExcelUtil<FtConfigDao>(FtConfigDao.class);
return util.exportExcel(list, "fantangConfig");
}
/**
* 获取饭堂参数详细信息
*/
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:query')" )
@GetMapping(value = "/{id}" )
public AjaxResult getInfo(@PathVariable("id" ) Long id) {
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(iFtConfigDaoService.getById(id));
}
/**
* 新增饭堂参数
*/
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:add')" )
@Log(title = "饭堂参数" , businessType = BusinessType.INSERT)
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:add')")
@Log(title = "饭堂参数", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody FtConfigDao ftConfigDao) {
return toAjax(iFtConfigDaoService.save(ftConfigDao) ? 1 : 0);
@ -100,8 +96,8 @@ public class FtConfigDaoController extends BaseController {
/**
* 修改饭堂参数
*/
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:edit')" )
@Log(title = "饭堂参数" , businessType = BusinessType.UPDATE)
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:edit')")
@Log(title = "饭堂参数", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody FtConfigDao ftConfigDao) {
return toAjax(iFtConfigDaoService.updateById(ftConfigDao) ? 1 : 0);
@ -110,10 +106,56 @@ public class FtConfigDaoController extends BaseController {
/**
* 删除饭堂参数
*/
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:remove')" )
@Log(title = "饭堂参数" , businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}" )
@PreAuthorize("@ss.hasPermi('fantang:fantangConfig:remove')")
@Log(title = "饭堂参数", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(iFtConfigDaoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
}
@PostMapping("/updateDinnerTime")
public AjaxResult updateDinnerTime(@RequestBody JSONObject params) {
StringBuilder configValue = new StringBuilder();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
JSONArray breakfastJson = params.getJSONArray("breakfast");
JSONArray lunchJson = params.getJSONArray("lunch");
JSONArray dinnerJson = params.getJSONArray("dinner");
List<Date> breakfastTime = breakfastJson.toJavaList(Date.class);
for (Date date : breakfastTime) {
String time = sdf.format(date);
System.out.println(time);
configValue.append(time).append(",");
}
List<Date> lunchTime = lunchJson.toJavaList(Date.class);
for (Date date : lunchTime) {
String time = sdf.format(date);
System.out.println(time);
configValue.append(time).append(",");
}
List<Date> dinnerTime = dinnerJson.toJavaList(Date.class);
for (int i = 0; i < dinnerTime.size(); i++) {
String time = sdf.format(dinnerTime.get(i));
configValue.append(time);
if (i != dinnerTime.size() - 1) {
configValue.append(",");
}
}
UpdateWrapper<FtConfigDao> wrapper = new UpdateWrapper<>();
wrapper.eq("id", params.getLong("id"));
FtConfigDao ftConfigDao = new FtConfigDao();
ftConfigDao.setConfigValue(configValue.toString());
iFtConfigDaoService.update(ftConfigDao, wrapper);
System.out.println(params);
return null;
}
}

View File

@ -26,6 +26,14 @@ export function addFantangConfig(data) {
})
}
export function updateDinnerTime(data) {
return request({
url: '/fantang/fantangConfig/updateDinnerTime',
method: 'post',
data: data
})
}
// 修改饭堂参数
export function updateFantangConfig(data) {
return request({
@ -50,4 +58,4 @@ export function exportFantangConfig(query) {
method: 'get',
params: query
})
}
}

View File

@ -2,7 +2,7 @@
<div class="app-container">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="最大补贴金额">
<el-input v-model="formInline.price" placeholder="请输入最大补贴金额"></el-input>
<el-input v-model="formInline.configValue" placeholder="请输入最大补贴金额"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">提交</el-button>
@ -15,6 +15,8 @@
<el-time-picker
is-range
v-model="dinnerForm.breakfast"
value-format="HH:mm"
@change="changeBreakfast"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
@ -29,6 +31,8 @@
<el-time-picker
is-range
v-model="dinnerForm.lunch"
value-format="HH:mm"
@change="changeLunch"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
@ -43,6 +47,8 @@
<el-time-picker
is-range
v-model="dinnerForm.dinner"
value-format="HH:mm"
@change="changeDinner"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
@ -67,6 +73,7 @@ import {
exportFantangConfig,
getFantangConfig,
listFantangConfig,
updateDinnerTime,
updateFantangConfig
} from "@/api/fantang/fantangConfig";
@ -75,13 +82,16 @@ export default {
components: {},
data() {
return {
timeArr: [],
formInline: {
price: null,
configValue: null,
id: null,
},
dinnerForm: {
breakfast: null,
lunch: null,
dinner: null,
breakfast: [],
lunch: [],
dinner: [],
id: 7,
},
};
},
@ -89,13 +99,39 @@ export default {
this.getList();
},
methods: {
changeBreakfast(e) {
if (e != null) {
this.timeArr[0] = e[0];
this.timeArr[1] = e[1];
}
},
changeLunch(e) {
if (e != null) {
this.timeArr[2] = e[0];
this.timeArr[3] = e[1];
}
},
changeDinner(e) {
if (e != null) {
this.timeArr[4] = e[0];
this.timeArr[5] = e[1];
}
},
/** 查询饭堂参数列表 */
getList() {
this.loading = true;
listFantangConfig(this.queryParams).then(response => {
this.fantangConfigList = response.rows;
this.total = response.total;
this.loading = false;
listFantangConfig().then(response => {
this.formInline.configValue = response.rows[7].configValue
this.formInline.id = response.rows[7].id
console.log("数据库获取--------", response.rows[6].configValue.split(','))
this.timeArr = response.rows[6].configValue.split(',')
this.dinnerForm.breakfast[0] = new Date(2016, 9, 1, this.timeArr[0].split(':')[0], this.timeArr[0].split(':')[1])
this.dinnerForm.breakfast[1] = new Date(2016, 9, 1, this.timeArr[1].split(':')[0], this.timeArr[1].split(':')[1])
this.dinnerForm.lunch[0] = new Date(2016, 9, 1, this.timeArr[2].split(':')[0], this.timeArr[2].split(':')[1])
this.dinnerForm.lunch[1] = new Date(2016, 9, 1, this.timeArr[3].split(':')[0], this.timeArr[3].split(':')[1])
this.dinnerForm.dinner[0] = new Date(2016, 9, 1, this.timeArr[4].split(':')[0], this.timeArr[4].split(':')[1])
this.dinnerForm.dinner[1] = new Date(2016, 9, 1, this.timeArr[5].split(':')[0], this.timeArr[5].split(':')[1])
});
},
//
@ -148,14 +184,20 @@ export default {
},
//
submitDinnerForm(){
submitDinnerForm() {
console.log(this.dinnerForm)
updateDinnerTime(this.dinnerForm).then(response => {
this.msgSuccess("修改成功")
})
},
//
onSubmit(){
onSubmit() {
console.log(this.formInline)
if (this.formInline.configValue != null || this.formInline.configValue !== '')
updateFantangConfig(this.formInline).then(response => {
this.msgSuccess("修改成功")
})
},
/** 提交按钮 */