|
@@ -1,125 +1,37 @@
|
|
|
package com.pj.tb_purchaser_address;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import com.pj.current.dto.APPLoginUserInfo;
|
|
|
-import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
-import com.pj.tb_purchaser_address.param.TbPurchaserAddressParam;
|
|
|
+import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import com.pj.utils.sg.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Service: tb_purchaser_address -- 收购商个人地址管理表
|
|
|
- * @author qzy
|
|
|
+ *
|
|
|
+ * @author qzy
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
-public class TbPurchaserAddressService extends ServiceImpl<TbPurchaserAddressMapper, TbPurchaserAddress> implements IService<TbPurchaserAddress>{
|
|
|
-
|
|
|
- /** 底层 Mapper 对象 */
|
|
|
- @Autowired
|
|
|
- TbPurchaserAddressMapper tbPurchaserAddressMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MethodPurchaserAddressService methodPurchaserService;
|
|
|
-
|
|
|
- /** 增 */
|
|
|
- void add(TbPurchaserAddress t){
|
|
|
- save(t);
|
|
|
- }
|
|
|
-
|
|
|
- /** 删 */
|
|
|
- void delete(Long id){
|
|
|
- removeById(id);
|
|
|
- }
|
|
|
-
|
|
|
- /** 改 */
|
|
|
- void update(TbPurchaserAddress t){
|
|
|
- updateById(t);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /** 查 */
|
|
|
- TbPurchaserAddress getById(Integer id){
|
|
|
- return super.getById(id);
|
|
|
- }
|
|
|
-
|
|
|
- /** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
|
|
|
- List<TbPurchaserAddress> getList(SoMap so) {
|
|
|
- return tbPurchaserAddressMapper.getList(so);
|
|
|
- }
|
|
|
-
|
|
|
- /** 查集合 - 仅查询当前登陆人的地址信息 */
|
|
|
- List<TbPurchaserAddress> selectOwnAddress(SoMap so) {
|
|
|
- //获取当前登陆人ID
|
|
|
- APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
- if(appLoginInfo == null)throw new RuntimeException("当前登录账号信息已失效!");
|
|
|
- so.set("owner",appLoginInfo.getLoginId());
|
|
|
- return tbPurchaserAddressMapper.getList(so);
|
|
|
- }
|
|
|
-
|
|
|
- /** app增地址 */
|
|
|
- boolean appAdd(TbPurchaserAddressParam t){
|
|
|
- //获取当前登陆人ID
|
|
|
- APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
- if(appLoginInfo == null)throw new RuntimeException("当前登录账号信息已失效!");
|
|
|
- TbPurchaserAddress tbPurchaserAddress = new TbPurchaserAddress();
|
|
|
- BeanUtils.copyProperties(t,tbPurchaserAddress);
|
|
|
- //地址所属人
|
|
|
- tbPurchaserAddress.setOwner(appLoginInfo.getLoginId());
|
|
|
- //地址全称 省 市 镇/区 街道 楼号 邮编
|
|
|
- String addressString = methodPurchaserService.addressString(tbPurchaserAddress);
|
|
|
- tbPurchaserAddress.setAddressName(addressString);
|
|
|
- boolean save = save(tbPurchaserAddress);
|
|
|
- return save;
|
|
|
- }
|
|
|
-
|
|
|
+public class TbPurchaserAddressService extends ServiceImpl<TbPurchaserAddressMapper, TbPurchaserAddress> implements IService<TbPurchaserAddress> {
|
|
|
|
|
|
- /** app改地址 */
|
|
|
- void appUpdate(TbPurchaserAddressParam t){
|
|
|
- //获取当前登陆人ID
|
|
|
- APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
- if(appLoginInfo == null)throw new RuntimeException("当前登录账号信息已失效!");
|
|
|
- //安全判定
|
|
|
- if(!appLoginInfo.getLoginId().toString().equals(t.getOwner().toString())){
|
|
|
- throw new RuntimeException("非法操作!");
|
|
|
- }
|
|
|
- //数据拷贝
|
|
|
- TbPurchaserAddress tbPurchaserAddress = new TbPurchaserAddress();
|
|
|
- BeanUtils.copyProperties(t,tbPurchaserAddress);
|
|
|
- //拼接详细地址
|
|
|
- String addressString = methodPurchaserService.addressString(tbPurchaserAddress);
|
|
|
- //保存
|
|
|
- t.setAddressName(addressString);
|
|
|
- updateById(tbPurchaserAddress);
|
|
|
+ /**
|
|
|
+ * 底层 Mapper 对象
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ TbPurchaserAddressMapper tbPurchaserAddressMapper;
|
|
|
|
|
|
- }
|
|
|
|
|
|
- /** 删 */
|
|
|
- void appDelete(List<Long> ids){
|
|
|
- if(ids.size() == 0)return;
|
|
|
- //获取登陆人
|
|
|
- APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
- if(appLoginInfo == null)throw new RuntimeException("当前登录账号信息已失效!");
|
|
|
- //查询验证
|
|
|
- ids.forEach(item -> {
|
|
|
- TbPurchaserAddress tbPurchaserAddress = tbPurchaserAddressMapper.selectById(item);
|
|
|
- if(tbPurchaserAddress != null){
|
|
|
- //验证
|
|
|
- if(tbPurchaserAddress.getOwner().toString().equals(appLoginInfo.getLoginId().toString())){
|
|
|
- //验证通过删除
|
|
|
- removeById(item);
|
|
|
- }
|
|
|
- throw new RuntimeException("非法操作!");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ /** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
|
|
|
+ List<TbPurchaserAddress> getList(SoMap so) {
|
|
|
+ return tbPurchaserAddressMapper.getList(so);
|
|
|
+ }
|
|
|
|
|
|
+ boolean deleteByIdAndUserId(TbPurchaserAddress address) {
|
|
|
+ return tbPurchaserAddressMapper.deleteByIdAndUserId(address);
|
|
|
+ }
|
|
|
|
|
|
}
|