Commit 0e6830bc by 刘宇峰

特约店、围栏

1 parent f71572ab
......@@ -97,7 +97,7 @@ public class ElectricFenceController {
@GetMapping(value = "/change/info")
@ApiOperation(value = "查看修改围栏详情")
public R changeInfo(@RequestParam("fenceId") Long fenceId) {
ElectricFenceDetailsDTO detailsDTO = electricFenceService.getInfoById(fenceId);
ElectricFenceDetailsDTO detailsDTO = electricFenceService.getCopyInfoById(fenceId);
return R.ok().data(detailsDTO);
}
......
......@@ -3,7 +3,15 @@ package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.ElectricFenceSnsCopy;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface ElectricFenceSnsCopyMapper extends CommonBaseMapper<ElectricFenceSnsCopy> {
@Select("select * from t_electric_fence_sns_copy where fence_id=#{fenceId} and source=1")
List<ElectricFenceSnsCopy> selectByFenceId(@Param("fenceId") Long fenceId);
}
\ No newline at end of file
......@@ -87,4 +87,14 @@ public class ElectricFenceDetailsDTO {
*/
private List<ElectricFenceSnsDTO> snList = new ArrayList<>();
/**
* 特约店id
*/
private Long shopId;
/**
* 特约店名称
*/
private String shopName;
}
......@@ -19,6 +19,11 @@ public class ElectricFenceBO {
private Long id;
/**
* 特约店id(特约店账号)
*/
private Long shopId;
/**
* 围栏名称
*/
@NotBlank(message = "围栏名称不能为空")
......
......@@ -21,7 +21,9 @@ import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSearch;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.usercenter.api.dto.response.Organization;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import cn.com.glsx.usercenter.api.feign.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -63,6 +65,9 @@ public class ElectricFenceService {
private ApprovalService approvalService;
@Autowired
private UserService userService;
@Autowired
private OrganizationService organizationService;
@Autowired
......@@ -124,7 +129,11 @@ public class ElectricFenceService {
fence.setRecord("操作时间:" + DateUtils.formatNormal(new Date())
+ " 操作人:" + ShieldContextHolder.getAccount() + "(" + ShieldContextHolder.getUserId() + ")"
+ "<br/>");
fence.setCreatedBy(ShieldContextHolder.getUserId());
if (fenceBO.getShopId() != null) {
fence.setCreatedBy(fenceBO.getShopId());
} else {
fence.setCreatedBy(ShieldContextHolder.getUserId());
}
fence.setCreatedDate(new Date());
int insertCnt = electricFenceMapper.insertUseGeneratedKeys(fence);
......@@ -257,6 +266,45 @@ public class ElectricFenceService {
snsList.add(snsDTO);
});
detailsDTO.setSnList(snsList);
R<User> userR = userService.getById(electricFence.getCreatedBy());
User user = userR.getData(User.class);
if (user != null) {
detailsDTO.setShopId(user.getId());
detailsDTO.setShopName(user.getUsername());
} else {
detailsDTO.setShopId(electricFence.getCreatedBy());
}
}
return detailsDTO;
}
public ElectricFenceDetailsDTO getCopyInfoById(Long fenceId) {
ElectricFenceDetailsDTO detailsDTO = null;
ElectricFenceCopy fenceCopy = electricFenceCopyMapper.selectByFenceId(fenceId);
if (fenceCopy != null) {
detailsDTO = new ElectricFenceDetailsDTO();
BeanUtils.copyProperties(fenceCopy, detailsDTO);
List<ElectricFenceSnsDTO> snsList = Lists.newLinkedList();
List<ElectricFenceSnsCopy> fenceSnsList = electricFenceSnsCopyMapper.selectByFenceId(fenceId);
fenceSnsList.forEach(fs -> {
ElectricFenceSnsDTO snsDTO = new ElectricFenceSnsDTO();
BeanUtils.copyProperties(fs, snsDTO);
snsList.add(snsDTO);
});
detailsDTO.setSnList(snsList);
R<User> userR = userService.getById(fenceCopy.getCreatedBy());
User user = userR.getData(User.class);
if (user != null) {
detailsDTO.setShopId(user.getId());
detailsDTO.setShopName(user.getUsername());
} else {
detailsDTO.setShopId(fenceCopy.getCreatedBy());
}
}
return detailsDTO;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!