|
|
|
@@ -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(); |
|
|
|
} |
|
|
|
|