Commit 5abf203f by 陶光胜

自定义字段关联

parent c3644fbf
......@@ -63,5 +63,5 @@ public interface StoreDictApiService {
* @param value
* @return
*/
ServiceResponse saveStoreField(Integer enterpriseId, String value);
ServiceResponse saveStoreField(Integer enterpriseId, String value, int type);
}
\ No newline at end of file
......@@ -63,4 +63,6 @@ public interface TabStoreDictMapper {
List<String> listStoreStatus(Integer enterpriseId);
List<String> listStoreField(Integer enterpriseId);
void deleteStoreField(Integer enterpriseId, String value);
}
\ No newline at end of file
......@@ -39,4 +39,6 @@ public interface StoreDictService {
List<String> listStoreField(Integer enterpriseId);
void saveStoreField(TabStoreDict tabStoreDict);
void deleteStoreField(Integer enterpriseId, String value);
}
......@@ -44,4 +44,9 @@ public class StoreDictServiceImpl implements StoreDictService {
tabStoreDict.setType("storeField");
this.tabStoreDictMapper.insert(tabStoreDict);
}
@Override
public void deleteStoreField(Integer enterpriseId, String value) {
this.tabStoreDictMapper.deleteStoreField(enterpriseId, value);
}
}
......@@ -119,18 +119,22 @@ public class StoreDictApiServiceImpl implements StoreDictApiService {
}
@Override
public ServiceResponse saveStoreField(Integer enterpriseId, String value) {
List<String> list = this.storeDictService.listStoreField(enterpriseId);
for(String s : list){
if(s.equals(value)){
return ServiceResponse.failure(ErrorCode.ERR_6.getCode(), ErrorCode.ERR_6.getMsg());
public ServiceResponse saveStoreField(Integer enterpriseId, String value, int type) {
if(type == 1){ //新增
List<String> list = this.storeDictService.listStoreField(enterpriseId);
for(String s : list){
if(s.equals(value)){
return ServiceResponse.failure(ErrorCode.ERR_6.getCode(), ErrorCode.ERR_6.getMsg());
}
}
TabStoreDict tabStoreDict = new TabStoreDict();
tabStoreDict.setEnterpriseId(enterpriseId);
tabStoreDict.setCreateTime(new Date());
tabStoreDict.setValue(value);
this.storeDictService.saveStoreField(tabStoreDict);
}else {
this.storeDictService.deleteStoreField(enterpriseId, value);
}
TabStoreDict tabStoreDict = new TabStoreDict();
tabStoreDict.setEnterpriseId(enterpriseId);
tabStoreDict.setCreateTime(new Date());
tabStoreDict.setValue(value);
this.storeDictService.saveStoreField(tabStoreDict);
return ServiceResponse.success();
}
......
......@@ -103,23 +103,31 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where store_dict_id = #{storeDictId,jdbcType=INTEGER}
</update>
<update id="deleteStoreField" >
update tab_store_dict
set status=0
where enterprise_id = #{enterpriseId,jdbcType=INTEGER},
type = 'storeField',
value = #{value,jdbcType=VARCHAR}
</update>
<select id="listStoreType" parameterType="java.lang.Integer" resultType="java.lang.String">
select
value
from tab_store_dict
where enterprise_id = #{enterpriseId,jdbcType=INTEGER} and type='storeType'
where enterprise_id = #{enterpriseId,jdbcType=INTEGER} and type='storeType' and status=1
</select>
<select id="listStoreStatus" parameterType="java.lang.Integer" resultType="java.lang.String">
select
value
from tab_store_dict
where enterprise_id = #{enterpriseId,jdbcType=INTEGER} and type='storeStatus'
where enterprise_id = #{enterpriseId,jdbcType=INTEGER} and type='storeStatus' and status=1
</select>
<select id="listStoreField" parameterType="java.lang.Integer" resultType="java.lang.String">
select
value
from tab_store_dict
where enterprise_id = #{enterpriseId,jdbcType=INTEGER} and type='storeField'
where enterprise_id = #{enterpriseId,jdbcType=INTEGER} and type='storeField' and status=1
</select>
</mapper>
\ No newline at end of file
......@@ -104,7 +104,7 @@ public class StoreDictController {
@RequestMapping("relevance-storefield")
@ResponseBody
public RestResponse setStoreField(String value){
public RestResponse setStoreField(String value, int type){
Integer enterpriseId = 1111;
if(StringUtils.isBlank(value)){
return EnterpriseRestResponse.failure(com.gic.enterprise.error.ErrorCode.ERR_2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment