新增客户时给当前用户自动授权

This commit is contained in:
季圣华
2021-11-17 00:43:21 +08:00
parent fcdecf25a9
commit 08f2ccdd5a
3 changed files with 38 additions and 0 deletions

View File

@@ -30,4 +30,7 @@ public interface SupplierMapperEx {
@Param("telephone") String telephone);
int batchDeleteSupplierByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
Supplier getSupplierByName(
@Param("supplier") String supplier);
}

View File

@@ -14,7 +14,9 @@ import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
@@ -52,6 +54,10 @@ public class SupplierService {
private DepotHeadService depotHeadService;
@Resource
private AccountHeadService accountHeadService;
@Resource
private SystemConfigService systemConfigService;
@Resource
private UserBusinessService userBusinessService;
public Supplier getSupplier(long id)throws Exception {
Supplier result=null;
@@ -139,6 +145,28 @@ public class SupplierService {
try{
supplier.setEnabled(true);
result=supplierMapper.insertSelective(supplier);
//新增客户时给当前用户自动授权
if("客户".equals(supplier.getType())) {
Long userId = userService.getUserId(request);
Supplier sInfo = supplierMapperEx.getSupplierByName(supplier.getSupplier());
String ubKey = "[" + sInfo.getId() + "]";
List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserCustomer");
if(ubList ==null || ubList.size() == 0) {
JSONObject ubObj = new JSONObject();
ubObj.put("type", "UserCustomer");
ubObj.put("keyId", userId);
ubObj.put("value", ubKey);
userBusinessService.insertUserBusiness(ubObj, request);
} else {
UserBusiness ubInfo = ubList.get(0);
JSONObject ubObj = new JSONObject();
ubObj.put("id", ubInfo.getId());
ubObj.put("type", ubInfo.getType());
ubObj.put("keyId", ubInfo.getKeyId());
ubObj.put("value", ubInfo.getValue() + ubKey);
userBusinessService.updateUserBusiness(ubObj, request);
}
}
logService.insertLog("商家",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(supplier.getSupplier()).toString(),request);
}catch(Exception e){

View File

@@ -71,6 +71,7 @@
and ifnull(delete_flag,'0') !='1'
order by id desc
</select>
<update id="batchDeleteSupplierByIds">
update jsh_supplier
set delete_flag='1'
@@ -81,4 +82,10 @@
</foreach>
)
</update>
<select id="getSupplierByName" resultType="com.jsh.erp.datasource.entities.Supplier">
select *
from jsh_supplier
where supplier = #{supplier}
</select>
</mapper>