Просмотр исходного кода

[等级保存接口修改][修改]

release_toaliyun_real
Stormeye Wu 7 лет назад
Родитель
Сommit
1f7e2be00d
4 измененных файлов: 32 добавлений и 64 удалений
  1. +9
    -17
      mallinkAdmin/src/main/java/com/iformall/controller/WxLevelConfigController.java
  2. +0
    -45
      mallinkService/src/main/java/com/iformall/domain/dto/WxLevelConfigDto.java
  3. +8
    -2
      mallinkService/src/main/java/com/iformall/service/WxLevelConfigService.java
  4. +15
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxLevelConfigServiceImpl.java

+ 9
- 17
mallinkAdmin/src/main/java/com/iformall/controller/WxLevelConfigController.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.controller;

import com.iformall.common.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxLevelConfigDto;
import com.iformall.domain.po.WxLevelConfig;
import com.iformall.service.WxLevelConfigService;

@@ -22,6 +22,8 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.List;

@RestController
@RequestMapping("wxLevelConfig")
@Api(description="等级权益相关接口")
@@ -47,26 +49,16 @@ public class WxLevelConfigController extends BaseController {

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxLevelConfigDto dto) {
public ResultData add(@RequestBody List<WxLevelConfig> levelConfigs) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add");
//Assert.notNull(wxLevelConfig.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
String[] points = dto.getPoints().split("&");
String[] level = dto.getLevel().split("&");
String[] descs =dto.getDescription().split("&");
if (points.length != level.length) {
return new ResultData(Result.ERROR, "请同时设置成长值和等级");
}
String tenantId = getTenantId();
wxLevelConfigService.deleteAll(tenantId);
for(int i=0;i<points.length;i++) {
WxLevelConfig wxLevelConfig = new WxLevelConfig();
wxLevelConfig.setTenantId(tenantId);
wxLevelConfig.setPoints(Integer.parseInt(points[i]));
wxLevelConfig.setLevel(level[i]);
if (descs.length > 0 && i < descs.length)
wxLevelConfig.setDescription(descs[i]);
wxLevelConfigService.saveOrUpdate(wxLevelConfig);
try {
wxLevelConfigService.batchSave(tenantId, levelConfigs);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.DB_FAIL);
}
return new ResultData();
}


+ 0
- 45
mallinkService/src/main/java/com/iformall/domain/dto/WxLevelConfigDto.java Просмотреть файл

@@ -1,45 +0,0 @@
package com.iformall.domain.dto;

import java.io.Serializable;
/**
* 等级权益dto
* @author jinguo
*
*/
public class WxLevelConfigDto implements Serializable{

/**
*
*/
private static final long serialVersionUID = -8155943956044066653L;

/*成长值**/
@io.swagger.annotations.ApiModelProperty(value="成长值",name="points")
private String points;
/*等级**/
@io.swagger.annotations.ApiModelProperty(value="等级",name="level")
private String level;
/*描述**/
@io.swagger.annotations.ApiModelProperty(value="描述",name="description")
private String description;
public String getPoints() {
return points;
}
public void setPoints(String points) {
this.points = points;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

+ 8
- 2
mallinkService/src/main/java/com/iformall/service/WxLevelConfigService.java Просмотреть файл

@@ -31,14 +31,20 @@ public interface WxLevelConfigService {
* @return
*/
WxLevelConfig getById(Long id);
/**
/**
* 保存或更新实体
*
* @param record
*/
void saveOrUpdate(WxLevelConfig record);

/**
* 批量保存
*/
void batchSave(String tenantId, List<WxLevelConfig> records);


/**
* 根据Id删除实体
*


+ 15
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxLevelConfigServiceImpl.java Просмотреть файл

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

import java.util.Date;
import java.util.List;

@Service
@@ -55,6 +56,20 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService {
}
}

@Override
public void batchSave(String tenantId, List<WxLevelConfig> records) {
final IdWorker idWorker = IdWorker.get();
wxLevelConfigMapper.deleteAll(tenantId);
for(WxLevelConfig levelConfig: records) {
if(levelConfig.getId() == null) {
levelConfig.setId(idWorker.nextId());
levelConfig.setCreateDate(new Date());
}
levelConfig.setTenantId(tenantId);
}
wxLevelConfigMapper.insertList(records);
}

@Override
public void deleteById(Long id) {
wxLevelConfigMapper.deleteByPrimaryKey(id);


Загрузка…
Отмена
Сохранить