把商品扩展字段表改为带租户id的模式
This commit is contained in:
@@ -54,9 +54,8 @@ public class TenantConfig {
|
||||
Long tenantId = Tools.getTenantIdByToken(token);
|
||||
if (tenantId!=0L) {
|
||||
// 这里可以判断是否过滤表
|
||||
if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName)
|
||||
|| "jsh_function".equals(tableName) || "jsh_platform_config".equals(tableName)
|
||||
|| "jsh_tenant".equals(tableName)) {
|
||||
if ("jsh_sequence".equals(tableName) || "jsh_function".equals(tableName)
|
||||
|| "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) {
|
||||
res = true;
|
||||
} else {
|
||||
res = false;
|
||||
|
||||
@@ -27,8 +27,8 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @Author: qiankunpingtai
|
||||
* @Date: 2019/3/29 15:24
|
||||
* @Author: jsh
|
||||
* @Date: 2025/3/25 15:24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/materialProperty")
|
||||
@@ -79,6 +79,23 @@ public class MaterialPropertyController extends BaseController {
|
||||
return returnStr(objectMap, update);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/addOrUpdate")
|
||||
@ApiOperation(value = "新增或修改")
|
||||
public String addOrUpdate(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
String nativeName = obj.getString("nativeName");
|
||||
String anotherName = obj.getString("anotherName");
|
||||
boolean exist = materialPropertyService.checkIsNativeNameExist(nativeName);
|
||||
int res;
|
||||
if(!exist) {
|
||||
obj.put("id", null);
|
||||
res = materialPropertyService.insertMaterialProperty(obj, request);
|
||||
} else {
|
||||
res = materialPropertyService.updateMaterialPropertyByNativeName(nativeName, anotherName);
|
||||
}
|
||||
return returnStr(objectMap, res);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete")
|
||||
@ApiOperation(value = "删除")
|
||||
public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
|
||||
|
||||
@@ -11,6 +11,8 @@ public class MaterialProperty {
|
||||
|
||||
private String anotherName;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String deleteFlag;
|
||||
|
||||
public Long getId() {
|
||||
@@ -53,6 +55,14 @@ public class MaterialProperty {
|
||||
this.anotherName = anotherName == null ? null : anotherName.trim();
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(Long tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String getDeleteFlag() {
|
||||
return deleteFlag;
|
||||
}
|
||||
|
||||
@@ -434,6 +434,66 @@ public class MaterialPropertyExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNull() {
|
||||
addCriterion("tenant_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNotNull() {
|
||||
addCriterion("tenant_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdEqualTo(Long value) {
|
||||
addCriterion("tenant_id =", value, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdNotEqualTo(Long value) {
|
||||
addCriterion("tenant_id <>", value, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdGreaterThan(Long value) {
|
||||
addCriterion("tenant_id >", value, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("tenant_id >=", value, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdLessThan(Long value) {
|
||||
addCriterion("tenant_id <", value, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("tenant_id <=", value, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIn(List<Long> values) {
|
||||
addCriterion("tenant_id in", values, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdNotIn(List<Long> values) {
|
||||
addCriterion("tenant_id not in", values, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdBetween(Long value1, Long value2) {
|
||||
addCriterion("tenant_id between", value1, value2, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("tenant_id not between", value1, value2, "tenantId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDeleteFlagIsNull() {
|
||||
addCriterion("delete_flag is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -13,4 +13,10 @@ public interface MaterialPropertyMapperEx {
|
||||
@Param("name") String name);
|
||||
|
||||
int batchDeleteMaterialPropertyByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||
|
||||
int getCountByNativeName(@Param("nativeName") String nativeName);
|
||||
|
||||
void updateMaterialPropertyByNativeName(
|
||||
@Param("nativeName") String nativeName,
|
||||
@Param("anotherName") String anotherName);
|
||||
}
|
||||
@@ -18,8 +18,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class MaterialPropertyService {
|
||||
@@ -58,11 +57,34 @@ public class MaterialPropertyService {
|
||||
}
|
||||
|
||||
public List<MaterialProperty> select(String name)throws Exception {
|
||||
List<MaterialProperty> list=null;
|
||||
List<MaterialProperty> list = new ArrayList<>();
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
PageUtils.startPage();
|
||||
list = materialPropertyMapperEx.selectByConditionMaterialProperty(name);
|
||||
MaterialProperty mp1 = new MaterialProperty();
|
||||
MaterialProperty mp2 = new MaterialProperty();
|
||||
MaterialProperty mp3 = new MaterialProperty();
|
||||
mp1.setId(1L);
|
||||
mp1.setNativeName("扩展1");
|
||||
mp1.setAnotherName("扩展1");
|
||||
list.add(mp1);
|
||||
mp2.setId(2L);
|
||||
mp2.setNativeName("扩展2");
|
||||
mp2.setAnotherName("扩展2");
|
||||
list.add(mp2);
|
||||
mp3.setId(3L);
|
||||
mp3.setNativeName("扩展3");
|
||||
mp3.setAnotherName("扩展3");
|
||||
list.add(mp3);
|
||||
PageUtils.startPage();
|
||||
List<MaterialProperty> mpList = materialPropertyMapperEx.selectByConditionMaterialProperty(name);
|
||||
Map<String, String> mpMap = new HashMap<>();
|
||||
for(MaterialProperty mp: mpList) {
|
||||
mpMap.put(mp.getNativeName(), mp.getAnotherName());
|
||||
}
|
||||
//给list里面的别名和排序做更新
|
||||
for(MaterialProperty item: list) {
|
||||
if(mpMap.get(item.getNativeName())!=null) {
|
||||
item.setAnotherName(mpMap.get(item.getNativeName()));
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
@@ -75,11 +97,9 @@ public class MaterialPropertyService {
|
||||
MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class);
|
||||
int result=0;
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
result = materialPropertyMapper.insertSelective(materialProperty);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request);
|
||||
}
|
||||
result = materialPropertyMapper.insertSelective(materialProperty);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
@@ -91,11 +111,9 @@ public class MaterialPropertyService {
|
||||
MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class);
|
||||
int result=0;
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request);
|
||||
}
|
||||
result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
@@ -118,12 +136,10 @@ public class MaterialPropertyService {
|
||||
String [] idArray=ids.split(",");
|
||||
int result=0;
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
result = materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
}
|
||||
result = materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
@@ -133,4 +149,14 @@ public class MaterialPropertyService {
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean checkIsNativeNameExist(String nativeName) {
|
||||
int count = materialPropertyMapperEx.getCountByNativeName(nativeName);
|
||||
return count>0;
|
||||
}
|
||||
|
||||
public int updateMaterialPropertyByNativeName(String nativeName, String anotherName) {
|
||||
materialPropertyMapperEx.updateMaterialPropertyByNativeName(nativeName, anotherName);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user