Guang 完成了套餐状态的修改
This commit is contained in:
parent
6599852bc9
commit
23f0499fae
@ -17,6 +17,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -34,6 +36,7 @@ import java.util.Map;
|
||||
* @author zyx
|
||||
* @since 1.0.0 2023-06-09
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("takeout/setmeal")
|
||||
@Api(tags="套餐")
|
||||
@ -52,7 +55,6 @@ public class SetmealController {
|
||||
@RequiresPermissions("takeout:setmeal:page")
|
||||
public Result<PageData<SetmealDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<SetmealDTO> page = setmealService.page(params);
|
||||
|
||||
return new Result<PageData<SetmealDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@ -117,4 +119,22 @@ public class SetmealController {
|
||||
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.entity.SetmealEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 套餐
|
||||
*
|
||||
@ -12,4 +14,7 @@ import io.renren.modules.takeout.entity.SetmealEntity;
|
||||
*/
|
||||
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;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.modules.takeout.dao.SetmealDao;
|
||||
import io.renren.modules.takeout.dto.SetmealDTO;
|
||||
import io.renren.modules.takeout.entity.SetmealEntity;
|
||||
import io.renren.modules.takeout.service.SetmealService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -17,6 +21,7 @@ import java.util.Map;
|
||||
* @author zyx
|
||||
* @since 1.0.0 2023-06-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ server:
|
||||
min-spare: 30
|
||||
port: 8080
|
||||
servlet:
|
||||
# context-path: /renren-admin
|
||||
context-path: /api
|
||||
session:
|
||||
cookie:
|
||||
|
Loading…
x
Reference in New Issue
Block a user