Guang 完成了套餐状态的修改
This commit is contained in:
parent
7a50f71928
commit
808e6d5133
@ -17,6 +17,7 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ import java.util.Map;
|
|||||||
* @author zyx
|
* @author zyx
|
||||||
* @since 1.0.0 2023-06-09
|
* @since 1.0.0 2023-06-09
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("takeout/setmeal")
|
@RequestMapping("takeout/setmeal")
|
||||||
@Api(tags="套餐")
|
@Api(tags="套餐")
|
||||||
@ -52,7 +55,6 @@ public class SetmealController {
|
|||||||
@RequiresPermissions("takeout:setmeal:page")
|
@RequiresPermissions("takeout:setmeal:page")
|
||||||
public Result<PageData<SetmealDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
public Result<PageData<SetmealDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
PageData<SetmealDTO> page = setmealService.page(params);
|
PageData<SetmealDTO> page = setmealService.page(params);
|
||||||
|
|
||||||
return new Result<PageData<SetmealDTO>>().ok(page);
|
return new Result<PageData<SetmealDTO>>().ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,4 +119,22 @@ public class SetmealController {
|
|||||||
ExcelUtils.exportExcelToTarget(response, null, list, SetmealExcel.class);
|
ExcelUtils.exportExcelToTarget(response, null, list, SetmealExcel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("updateStatus")
|
||||||
|
@ApiOperation("更新套餐状态")
|
||||||
|
@LogOperation("更新套餐状态")
|
||||||
|
@RequiresPermissions("takeout:setmeal:updateStatus")
|
||||||
|
@CacheEvict(value = "setmealCache", allEntries = true)
|
||||||
|
public Result updateStatus(@RequestParam Map<String, String> params) {
|
||||||
|
List<String> ids=new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
if (key != null && value != null) {
|
||||||
|
ids.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("ids=-={}",ids);
|
||||||
|
setmealService.updateStatus(ids);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ import io.renren.common.service.CrudService;
|
|||||||
import io.renren.modules.takeout.dto.SetmealDTO;
|
import io.renren.modules.takeout.dto.SetmealDTO;
|
||||||
import io.renren.modules.takeout.entity.SetmealEntity;
|
import io.renren.modules.takeout.entity.SetmealEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 套餐
|
* 套餐
|
||||||
*
|
*
|
||||||
@ -12,4 +14,7 @@ import io.renren.modules.takeout.entity.SetmealEntity;
|
|||||||
*/
|
*/
|
||||||
public interface SetmealService extends CrudService<SetmealEntity, SetmealDTO> {
|
public interface SetmealService extends CrudService<SetmealEntity, SetmealDTO> {
|
||||||
|
|
||||||
|
void updateStatus(int status, List<Long> ids);
|
||||||
|
|
||||||
|
void updateStatus(List<String> ids);
|
||||||
}
|
}
|
@ -1,14 +1,18 @@
|
|||||||
package io.renren.modules.takeout.service.impl;
|
package io.renren.modules.takeout.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import io.renren.common.service.impl.CrudServiceImpl;
|
import io.renren.common.service.impl.CrudServiceImpl;
|
||||||
import io.renren.modules.takeout.dao.SetmealDao;
|
import io.renren.modules.takeout.dao.SetmealDao;
|
||||||
import io.renren.modules.takeout.dto.SetmealDTO;
|
import io.renren.modules.takeout.dto.SetmealDTO;
|
||||||
import io.renren.modules.takeout.entity.SetmealEntity;
|
import io.renren.modules.takeout.entity.SetmealEntity;
|
||||||
import io.renren.modules.takeout.service.SetmealService;
|
import io.renren.modules.takeout.service.SetmealService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,6 +21,7 @@ import java.util.Map;
|
|||||||
* @author zyx
|
* @author zyx
|
||||||
* @since 1.0.0 2023-06-09
|
* @since 1.0.0 2023-06-09
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntity, SetmealDTO> implements SetmealService {
|
public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntity, SetmealDTO> implements SetmealService {
|
||||||
|
|
||||||
@ -31,4 +36,40 @@ public class SetmealServiceImpl extends CrudServiceImpl<SetmealDao, SetmealEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateStatus(int status, List<Long> ids) {
|
||||||
|
LambdaUpdateWrapper<SetmealEntity> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
wrapper.in(SetmealEntity::getId, ids).set(SetmealEntity::getStatus, status);
|
||||||
|
this.update(new SetmealEntity(), wrapper);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void updateStatus(List<String> ids) {
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
log.info("ids==null----");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ids.size()>1){
|
||||||
|
int index =Integer.parseInt(ids.get(0)) ;
|
||||||
|
log.info("index=={}",index);
|
||||||
|
for (int i = 1; i < ids.size(); i++) {
|
||||||
|
Long id =Long.parseLong(ids.get(i)) ;
|
||||||
|
SetmealEntity setmeal = this.selectById(id);
|
||||||
|
setmeal.setStatus(index);
|
||||||
|
this.updateById(setmeal);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
Long id =Long.parseLong(ids.get(0)) ;
|
||||||
|
SetmealEntity setmeal = this.selectById(id);
|
||||||
|
log.info("SetmealEntity111={}",setmeal);
|
||||||
|
if (setmeal.getStatus().equals(1)){
|
||||||
|
setmeal.setStatus(0);
|
||||||
|
this.updateById(setmeal);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setmeal.setStatus(1);
|
||||||
|
this.updateById(setmeal);
|
||||||
|
}
|
||||||
|
log.info("SetmealEntity222={}",setmeal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ spring:
|
|||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://localhost:3306/mt_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://localhost:3306/mt_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||||
username: root
|
username: root
|
||||||
password: zyx007
|
password: 123456
|
||||||
#达梦8
|
#达梦8
|
||||||
# driver-class-name: dm.jdbc.driver.DmDriver
|
# driver-class-name: dm.jdbc.driver.DmDriver
|
||||||
# url: jdbc:dm://192.168.10.10:5236/renren_security?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
# url: jdbc:dm://192.168.10.10:5236/renren_security?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||||
|
@ -7,6 +7,7 @@ server:
|
|||||||
min-spare: 30
|
min-spare: 30
|
||||||
port: 8080
|
port: 8080
|
||||||
servlet:
|
servlet:
|
||||||
|
# context-path: /renren-admin
|
||||||
context-path: /api
|
context-path: /api
|
||||||
session:
|
session:
|
||||||
cookie:
|
cookie:
|
||||||
|
@ -11,7 +11,7 @@ spring:
|
|||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://localhost:3306/mt_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://localhost:3306/mt_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||||
username: root
|
username: root
|
||||||
password: zyx007
|
password: 123456
|
||||||
#oracle配置
|
#oracle配置
|
||||||
# driverClassName: oracle.jdbc.OracleDriver
|
# driverClassName: oracle.jdbc.OracleDriver
|
||||||
# url: jdbc:oracle:thin:@192.168.10.10:1521:xe
|
# url: jdbc:oracle:thin:@192.168.10.10:1521:xe
|
||||||
|
Loading…
x
Reference in New Issue
Block a user